Question: How do I install the Certbot package in my Lightsail instance for Let's Encrypt certificate installation?

I want to install a Let's Encrypt certificate on my Amazon Lightsail instance. How do I install the Certbot package in my instance so that I can install the certificate?Short descriptionLightsail instances with Bitnami stacks, such as WordPress, LAMP, and so on, have their own installation tool called bncert-tool. This tool is used for installing the Let's Encrypt certificate. Blueprints such as cPanel and Plesk also have their own tools for this purpose. These instances don't need the Certbot package.However, installation on other Lightsail instance blueprints, such as Ubuntu, Amazon Linux 2, and so on, require the Certbot package.For information on installing a Let's Encrypt certificate after installing the Certbot package, see How do I install a standard Let's Encrypt SSL certificate in a Lightsail instance?ResolutionAll Linux distributions except Amazon Linux 2 and FreeBSD can use snapd to install the Certbot tool. If you have any Certbot packages installed using an OS package manager such as apt, dnf, or yum, remove them before installing the Certbot snap. This makes sure that when you run the Certbot command, the snap is used rather than the installation from your OS package manager. The exact command you need to run to do this depends on your OS. The following are common examples of the command that you can use to remove Certbot package:sudo apt-get remove certbotsudo dnf remove certbotsudo yum remove certbotRun the following commands to install the Certbot tool:Amazon Linux 2sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmsudo yum install -y certbotNote: If you're using Method 1 to install a wildcard Let's Encrypt SSL certificate, then run the following commands as well to install the DNS plugin. In the following command, replace route53 with your domain's DNS provider. To review the list of supported DNS providers, see DNS Plugins.sudo yum install -y python2-certbot-dns-route53If you get botocore compatibility errors while running the Certbot command, then reinstall boto-core with pip.sudo pip uninstall botocore boto3 && sudo pip install boto3Ubuntu 16.04, 18.04 and 20.04sudo snap install core;sudo snap refresh core;sudo snap install --classic certbotNote: If you're using Method 1 to install a wildcard Let's Encrypt SSL certificate, then run the following commands as well to install the DNS plugin. In the following command, replace route53 with your domain's DNS provider. To review the list of supported DNS providers, see DNS Plugins.sudo snap set certbot trust-plugin-with-root=oksudo snap install --beta certbot-dns-route53sudo snap connect certbot:plugin certbot-dns-route53Debian 10.8, 9.13, 8.7sudo apt install snapd -ysudo snap install core;sudo snap install --classic certbotsudo ln -s /snap/bin/certbot /sbin/certbotNote: If you're using Method 1 to install a wildcard Let's Encrypt SSL certificate, then run the following commands to install the DNS plugin. In the following command, replace route53 with your domain's DNS provider. To review the list of supported DNS providers, see DNS Plugins.sudo snap install --beta --classic certbotsudo snap set certbot trust-plugin-with-root=oksudo snap install --beta certbot-dns-route53sudo snap connect certbot:plugin certbot-dns-route53CentOS 7.9sudo yum install epel-releasesudo yum-config-manager --enable crsudo yum install snapdsudo systemctl enable --now snapd.socketsudo ln -s /var/lib/snapd/snap /snapsudo snap install --classic certbotsudo ln -s /var/lib/snapd/snap/bin/certbot /sbin/certbotNote: If you're using Method 1 to install a Wildcard Let's Encrypt SSL certificate, then run the following commands to install the DNS plugin. In the following command, replace route53 with your domain's DNS provider. To review the list of supported DNS providers, see DNS Plugins.sudo snap set certbot trust-plugin-with-root=oksudo snap install --beta certbot-dns-route53sudo snap connect certbot:plugin certbot-dns-route53CentOS 8.2sudo dnf install epel-releasesudo dnf upgradesudo dnf config-manager --enable crsudo yum install snapdsudo systemctl enable --now snapd.socketsudo ln -s /var/lib/snapd/snap /snapsudo snap install --classic certbotsudo ln -s /var/lib/snapd/snap/bin/certbot /sbin/certbotNote: If you're using Method 1 to install a wildcard Let's Encrypt SSL certificate, then run the following commands to install the DNS plugin. In the following command, replace route53 with your domain's DNS provider. To review the list of supported DNS providers, see DNS Plugins.sudo snap set certbot trust-plugin-with-root=oksudo snap install --beta certbot-dns-route53sudo snap connect certbot:plugin certbot-dns-route53OpenSUSE 15.2sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.2 snappysudo zypper --gpg-auto-import-keys refreshsudo zypper dup --from snappysudo zypper install snapdsudo systemctl enable --now snapdsudo zypper in -t pattern apparmorsudo snap install core;sudo snap refresh core;sudo snap install --classic certbotsudo ln -s /snap/bin/certbot /usr/bin/certbotNote: If you're using Method 1 to install a wildcard Let's Encrypt SSL certificate, then run the following commands to install the DNS plugin. In the following command, replace route53 with your domain's DNS provider. To review the list of supported DNS providers, see DNS Plugins.sudo snap set certbot trust-plugin-with-root=oksudo snap install --beta certbot-dns-route53sudo snap connect certbot:plugin certbot-dns-route53FreeBSD 12.2supkg install py38-certbotNote: If you're using Method 1 to install a wildcard Let's Encrypt SSL certificate, then run the following commands to install the DNS plugin. In the following command, replace route53 with your domain's DNS provider. To review the list of supported DNS providers, see DNS Plugins.pkg install py38-certbot-dns-route53