<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Harun R Rayhan</title>
    <description>The latest articles on DEV Community by Harun R Rayhan (@harunrrayhan).</description>
    <link>https://dev.to/harunrrayhan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F396534%2Ff7bd70b8-4228-41af-a500-4a98417a9670.jpg</url>
      <title>DEV Community: Harun R Rayhan</title>
      <link>https://dev.to/harunrrayhan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harunrrayhan"/>
    <language>en</language>
    <item>
      <title>First 3 things I always do after creating a new AWS account</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Wed, 06 Jul 2022 14:24:50 +0000</pubDate>
      <link>https://dev.to/aws-builders/first-3-things-i-always-do-after-creating-a-new-aws-account-4cap</link>
      <guid>https://dev.to/aws-builders/first-3-things-i-always-do-after-creating-a-new-aws-account-4cap</guid>
      <description>&lt;p&gt;As part of my job, I create AWS accounts frequently. I do lots of things depending on account needs before starting to use it. I found 3 common things I do with all of the new AWS accounts. I made a checklist. Nowadays I do these 3 things first and then everything else. &lt;/p&gt;

&lt;p&gt;Let's make your account more secure and more protected than ever. 🔐&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Budget with Alerts
&lt;/h2&gt;

&lt;p&gt;One of the common issues with AWS is bills. People gets surprising bills because of misconfiguration or keep expensive services running unknowingly. Although, budget and alerts can NOT fix these issues but help keep bills tidy. And gives alerts if crosses the budget almost instantly.&lt;/p&gt;

&lt;p&gt;Let's set a budget and a couple of alerts. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Go to &lt;a href="https://console.aws.amazon.com/billing/home#/budgets"&gt;&lt;strong&gt;Budget Console&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click on the "&lt;strong&gt;Create Budget&lt;/strong&gt;" button.&lt;/li&gt;
&lt;li&gt;Choose the first option, "&lt;strong&gt;Cost budget - Recommended&lt;/strong&gt;" from the next page.&lt;/li&gt;
&lt;li&gt;From the next page: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FBuTXtiK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1656945288308/bIPTXFqTW.png" alt="CleanShot 2022-07-04 at 20.33.25@2x.png" width="880" height="1073"&gt;

&lt;ul&gt;
&lt;li&gt;A. Give it a name.&lt;/li&gt;
&lt;li&gt;B. Set the Period as &lt;strong&gt;Month&lt;/strong&gt; for this demo, but you can choose any other period.&lt;/li&gt;
&lt;li&gt;C. Set Budget renewal type as &lt;strong&gt;Recurring budget&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;D. Choose &lt;strong&gt;Fixed&lt;/strong&gt; from the Budgeting method.&lt;/li&gt;
&lt;li&gt;E. Give a real budget amount to your need, mine is a demo account so $10 is fine for me. Let me iterate again, choose a real amount.&lt;/li&gt;
&lt;li&gt;F. From the bottom-right of the page click "Next"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;From the next page, click on the "&lt;strong&gt;Add an alert threshold&lt;/strong&gt;. Going to set a couple of alerts. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R6yXNK5W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1656945969434/yGqNrA0Eu.png" alt="CleanShot 2022-07-04 at 20.43.58@2x.png" width="880" height="421"&gt;
&lt;/li&gt;
&lt;li&gt;Let's set an actual budget alert: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T-ntL3uC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1656946180091/ic5styUxa.png" alt="CleanShot 2022-07-04 at 20.48.00@2x.png" width="880" height="554"&gt;

&lt;ul&gt;
&lt;li&gt;A. Choose &lt;strong&gt;80&lt;/strong&gt; from the threshold.&lt;/li&gt;
&lt;li&gt;B. Select &lt;strong&gt;Actual&lt;/strong&gt; from the trigger&lt;/li&gt;
&lt;li&gt;C. Put as many real and active emails as necessary. (⚠️ please add active email to save yourself from disaster).&lt;/li&gt;
&lt;li&gt;D. Let's add another one.
&lt;em&gt;Actual budget alert only sends notifications when you spent threshold amount. For example, it will send an email to me after spending $8 (80% of 10$). So, we need something else together with it.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now set a forecasted budget alert:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uhmAExAx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1656946633128/jTqCv7R6K.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uhmAExAx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1656946633128/jTqCv7R6K.png" alt="CleanShot 2022-07-04 at 20.55.35@2xa.png" width="880" height="459"&gt;&lt;/a&gt;&lt;br&gt;
Everything is the same as the first alert, only change Trigger to &lt;strong&gt;Forecasted&lt;/strong&gt;. So, it will send you an alert if AWS forecast that you will spend more than your threshold.   After configuring it, click the &lt;strong&gt;Next&lt;/strong&gt; button from the bottom of the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the &lt;strong&gt;Next&lt;/strong&gt; again from the next page. And then click the &lt;strong&gt;Create Budget&lt;/strong&gt; button from the final page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And you are done with, you probably going to be saved from a disaster by email notifications.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Add Multi-Factor Authentication (MFA)
&lt;/h2&gt;

&lt;p&gt;You should use MFA for all IAM accounts including the root account. If not possible, at least apply it to root and privileged accounts. Login to the account (root or IAM) and let's protect it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://console.aws.amazon.com/iam/home#/security_credentials%24mfa"&gt;&lt;strong&gt;Security Credentials of IAM Console&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click on the "Assign MFA device" 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---mMecMS0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1657111562695/G47bzXcts.png" alt="CleanShot 2022-07-06 at 18.45.13@2x.png" width="880" height="552"&gt;
&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Virtual MFA device&lt;/strong&gt; from the popup&lt;/li&gt;
&lt;li&gt;You can choose either of these apps: Authy, Duo Mobile, LastPass Authenticator, Microsoft Authenticator, Google Authenticator, Symantec VIP. My personal choice is Authy.&lt;/li&gt;
&lt;li&gt;Click on the "Show QR code" from the next popup and scan it from your MFA app. Then enter two codes (one after another). And then click the "Assign MFA" button. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JTB-0UNV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1657112093771/vyB0BX5om.png" alt="CleanShot 2022-07-06 at 18.52.42@2x.png" width="880" height="898"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  (bonus) Set Alias for the Account
&lt;/h2&gt;

&lt;p&gt;Account ID or Alias is required to log in IAM account. Account ID is a long number. Humans are bad with a long number. A meaningful alias can save you from the trouble of remembering the account ID. Let's set an alias for your account: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://console.aws.amazon.com/iamv2"&gt;&lt;strong&gt;IAM Console&lt;/strong&gt;&lt;/a&gt; after login into the root account.&lt;/li&gt;
&lt;li&gt;You will see a &lt;strong&gt;Create&lt;/strong&gt; button in the right sidebar under the account alias. &lt;/li&gt;
&lt;li&gt;Choose a unique and memorable alias for your account and click "Save changes". &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use the alias instead of account ID next time you are logging into an IAM account.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Create IAM account(s) for Day-to-Day tasks
&lt;/h2&gt;

&lt;p&gt;You need the root account for a few &lt;a href="https://docs.aws.amazon.com/accounts/latest/reference/root-user-tasks.html"&gt;tasks&lt;/a&gt;. Other than that you should not use the Root account. Perhaps, not for day-to-day tasks, lunching, and provisioning services. &lt;/p&gt;

&lt;p&gt;I always create an IAM account with admin permission. I do all of the tasks from this account except those tasks that require the root account. So, let's create an admin IAM account. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="//console.aws.amazon.com/iamv2/home#/users"&gt;&lt;strong&gt;Users page of IAM Console&lt;/strong&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Add users&lt;/strong&gt; button from top-right corner. &lt;/li&gt;
&lt;li&gt;You will be in this page: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gfC_Lyaf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1657115139748/qnRC-GFHY.png" alt="CleanShot 2022-07-06 at 19.42.16@2x.png" width="880" height="769"&gt;

&lt;ul&gt;
&lt;li&gt;A. Choose an username&lt;/li&gt;
&lt;li&gt;B. Chosse access type. I need both CLI and AWS Console access. (UPDATE: Don’t choose CLI, if not necessary. You can create different IAM users for CLI actions.)&lt;/li&gt;
&lt;li&gt;C. You can enter your custom password or choose auto generated.&lt;/li&gt;
&lt;li&gt;D. It's better to require reset password to choose it's own.&lt;/li&gt;
&lt;li&gt;E. Click on the &lt;strong&gt;Next: Permission&lt;/strong&gt; button from the bottom-right&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You are in the permission page: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_B0bYUEG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1657115468984/bHYj1c_6X.png" alt="CleanShot 2022-07-06 at 19.50.04@2x.png" width="880" height="753"&gt;

&lt;ul&gt;
&lt;li&gt;A. Choose &lt;strong&gt;Attach existing policies directly&lt;/strong&gt; from the top options&lt;/li&gt;
&lt;li&gt;B. Search for the &lt;strong&gt;AdministratorAccess&lt;/strong&gt; role&lt;/li&gt;
&lt;li&gt;C. Choose the &lt;strong&gt;AdministratorAccess&lt;/strong&gt; role&lt;/li&gt;
&lt;li&gt;D. Click on the &lt;strong&gt;Next: Tags&lt;/strong&gt; button&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You are in the tags page. You can add you tag(s) if you want but it's optional. Click in the &lt;strong&gt;Next: Review&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;Take a look on everything and check if it's matches to mine. And then click on the &lt;strong&gt;Create user&lt;/strong&gt; button. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bNGuH8XK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1657115746019/M_4JaTtXY.png" alt="CleanShot 2022-07-06 at 19.55.22@2x.png" width="880" height="732"&gt;
&lt;/li&gt;
&lt;li&gt;Now we are in the final page: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SilNQTnY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1657115912225/AwtCueh_h.png" alt="CleanShot 2022-07-06 at 19.57.03@2x.png" width="880" height="408"&gt;

&lt;ul&gt;
&lt;li&gt;A. The link to login to the console&lt;/li&gt;
&lt;li&gt;B &amp;amp; C. Username &amp;amp; Password to login to the console&lt;/li&gt;
&lt;li&gt;D &amp;amp; E. Access key &amp;amp; secret to login via CLI or App&lt;/li&gt;
&lt;li&gt;F. You can download the .csv file with credentails. You can save it in safer place for later use. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;There are more things to do to save bills and tighten security of your account. But these are the first 3 things I do and doesn't require much technical knowledge. &lt;/p&gt;

&lt;p&gt;You can subscribe to my newsletter in &lt;a href="https://blog.harun.dev"&gt;my blog&lt;/a&gt;. Follow me on &lt;a href="https://twitter.com/HarunRRayhan"&gt;Twitter&lt;/a&gt;, &lt;a href="https://dev.to/harunrrayhan"&gt;Dev.to&lt;/a&gt;, and &lt;a href="https://hashnode.com/@HarunRRayhan"&gt;Hashnode&lt;/a&gt; for regular updates. Don't hesitate to show your love by clicking Like 👍 button.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Install Cloud Watch Agent in Amazon Lightsail instance for Monitoring, Logging &amp; Debugging</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Sat, 04 Jun 2022 04:51:10 +0000</pubDate>
      <link>https://dev.to/aws-builders/install-cloud-watch-agent-in-amazon-lightsail-instance-for-monitoring-logging-debugging-18kj</link>
      <guid>https://dev.to/aws-builders/install-cloud-watch-agent-in-amazon-lightsail-instance-for-monitoring-logging-debugging-18kj</guid>
      <description>&lt;p&gt;Use the Cloud Watch agent to send logging and debugging to Cloud Watch. You can check logs without logging into instances. It's accessible even after the instance is terminated.&lt;/p&gt;

&lt;p&gt;Life is far from perfect, and so does Amazon Lightsail instances. It can be frustrating if there is an error and you don't know how to debug it. The server itself and applications installed in it produces log files. And server stats can be helpful in monitoring, logging, and debugging.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;It would help if you had an existing Amazon Lightsail instance. You can create a new instance by following "&lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail"&gt;&lt;strong&gt;Deploy WordPress App to Amazon Lightsail&lt;/strong&gt;&lt;/a&gt;" or "&lt;a href="https://blog.harun.dev/deploy-laravel-application-to-amazon-lightsail"&gt;&lt;strong&gt;Deploy Laravel Application to Amazon Lightsail&lt;/strong&gt;&lt;/a&gt;". &lt;/p&gt;

&lt;p&gt;Let's go 🏃‍♂️&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an IAM User
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://console.aws.amazon.com/iam/"&gt;IAM Console&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click on the &lt;strong&gt;Users&lt;/strong&gt; menu from the navigation panel and then click on the &lt;strong&gt;Add Users&lt;/strong&gt; button.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ybNn9kt2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654260503965/iecpnlBpe.png" alt="CleanShot 2022-06-03 at 18.45.52@2x.png" width="880" height="281"&gt;
&lt;/li&gt;
&lt;li&gt;You will be in the &lt;strong&gt;Add user&lt;/strong&gt; screen: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q0X30J2t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654260634422/FtOVvkhW4.png" alt="CleanShot 2022-06-03 at 18.49.18@2x.png" width="880" height="765"&gt;

&lt;ul&gt;
&lt;li&gt;A. Give it a name. For me, it's &lt;strong&gt;LightsailCloudWatchAgent&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;B. Check the &lt;strong&gt;Access key - Programmatic access&lt;/strong&gt; option&lt;/li&gt;
&lt;li&gt;C. Click on the &lt;strong&gt;Next: Permissions&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;You will be in the &lt;strong&gt;Set permissions&lt;/strong&gt; page:
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SLfMrI-A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654261010738/ebCVaRI33.png" alt="CleanShot 2022-06-03 at 18.53.25@2x.png" width="880" height="771"&gt;

&lt;ul&gt;
&lt;li&gt;A. Select the &lt;strong&gt;Attach existing policies directly&lt;/strong&gt; option.&lt;/li&gt;
&lt;li&gt;B. Search for &lt;strong&gt;CloudWatchAgentServerPolicy&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;C. Select &lt;strong&gt;CloudWatchAgentServerPolicy&lt;/strong&gt;, and&lt;/li&gt;
&lt;li&gt;D. Click the &lt;strong&gt;Next: Tags&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Tags are optional. You can choose your tags. Click on the &lt;strong&gt;Next: Review&lt;/strong&gt; after you are done.&lt;/li&gt;
&lt;li&gt;From review page you can check if everything alright and then click the &lt;strong&gt;Create user&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;Your account is created and you will be in this screen: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--60qemEJM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654262147682/a1Y5zvdjy.png" alt="CleanShot 2022-06-03 at 19.15.00@2x.png" width="880" height="421"&gt;

&lt;ul&gt;
&lt;li&gt;A. &amp;amp; B. Copy &lt;strong&gt;Access Key ID&lt;/strong&gt; and &lt;strong&gt;Secret access key&lt;/strong&gt; in somewhere safe, or,&lt;/li&gt;
&lt;li&gt;C. Download the csv file.
We will need this access later. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Configure AWS Access
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Check if AWS CLI is installed by running &lt;code&gt;aws --version&lt;/code&gt;. You should see the current version. If you get an error, CLI probably is not installed. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ignore this if AWS CLI is already installed. Run this on ubuntu:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="s2"&gt;"awscliv2.zip"&lt;/span&gt;
unzip awscliv2.zip
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./aws/install
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./aws/install &lt;span class="nt"&gt;--bin-dir&lt;/span&gt; /usr/bin &lt;span class="nt"&gt;--install-dir&lt;/span&gt; /usr/local/aws-cli &lt;span class="nt"&gt;--update&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow this &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"&gt;instruction to install on other servers&lt;/a&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now, we are going to configure the AWS access generated in the last step. Run this
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;aws configure &lt;span class="nt"&gt;--profile&lt;/span&gt; AmazonCloudWatchAgent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter Access Key and Secret Like this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5xV7dQOT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654264842166/88TunGI6p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5xV7dQOT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654264842166/88TunGI6p.png" alt="CleanShot 2022-06-03 at 19.59.18@2x.png" width="880" height="199"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Install the Cloudwatch Agent
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You need to SSH into your instance. Here is &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail#heading-connect-to-the-instance-using-ssh"&gt;how you can SSH into your Amazon Lightsail Instance&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now, let's install the agent. I'm using ubuntu, you can just run this command&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download the agent&lt;/span&gt;
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
&lt;span class="c"&gt;# Install the agent&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; ./amazon-cloudwatch-agent.deb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Now run this command configure the agent.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Input your choices as I did. Check the arrow mark. You can choose your own or follow mine.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oQ2Buy1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654315524093/sOZrTU36D.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oQ2Buy1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654315524093/sOZrTU36D.png" alt="CleanShot 2022-06-04 at 10.03.13@2x.png" width="880" height="2369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Give AWS Access to the Agent. Run this:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Paste this in the bottom of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[credentials]
shared_credential_profile = "AmazonCloudWatchAgent"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now hit &lt;strong&gt;ESC&lt;/strong&gt; and then &lt;strong&gt;:wq!&lt;/strong&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start the agent:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;amazon-cloudwatch-agent-ctl &lt;span class="nt"&gt;-c&lt;/span&gt; file:/opt/aws/amazon-cloudwatch-agent/bin/config.json &lt;span class="nt"&gt;-a&lt;/span&gt; fetch-config &lt;span class="nt"&gt;-s&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Check the status of the agent by using:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;amazon-cloudwatch-agent-ctl &lt;span class="nt"&gt;-a&lt;/span&gt; status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see something like this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TJZcvRzn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654266165471/XM2e620Sv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TJZcvRzn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654266165471/XM2e620Sv.png" alt="CleanShot 2022-06-03 at 20.21.53@2x.png" width="880" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify metrics on CloudWatch
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to the &lt;a href="https://console.aws.amazon.com/cloudwatch"&gt;Cloudwatch Console&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;On the left navigation panel, choose &lt;strong&gt;Metrics&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under “&lt;strong&gt;Custom Namespaces&lt;/strong&gt;”, You should see a link for “CWAgent”.&lt;/li&gt;
&lt;li&gt;Choose CWAgent.&lt;/li&gt;
&lt;li&gt;Choose any &lt;strong&gt;ImageId, InstanceId, InstanceType&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the checkbox to display metrics on the graph. Here is mine: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t17w0fA2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1654315784361/SZyZfXUjn.png" alt="CleanShot 2022-06-04 at 10.08.02@2x.png" width="880" height="411"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope you enjoyed this article. This is the last article of the Amazon Lightsail series.  You can ask me any Lightsail-related question in the comments or on social media.&lt;/p&gt;

&lt;p&gt;You can subscribe to my newsletter to get blog updates every week. Follow me on &lt;a href="https://twitter.com/HarunRRayhan"&gt;Twitter&lt;/a&gt;, &lt;a href="https://dev.to/harunrrayhan"&gt;Dev.to&lt;/a&gt;, and &lt;a href="https://hashnode.com/@HarunRRayhan"&gt;Hashnode&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Connect Redis/Elasticache to application in Amazon Lightsail instance</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Sat, 28 May 2022 14:32:18 +0000</pubDate>
      <link>https://dev.to/aws-builders/connect-rediselasticache-to-application-in-amazon-lightsail-instance-4hfb</link>
      <guid>https://dev.to/aws-builders/connect-rediselasticache-to-application-in-amazon-lightsail-instance-4hfb</guid>
      <description>&lt;p&gt;You can create Redis/Elasticache even though Amazon Lightsail doesn't offer it. You can create an Elasticache for Redis cluster in AWS and connect using VPC Peering. &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;An Amazon Lightsail instance. To create a new instance follow &lt;a href="https://blog.harun.dev/deploy-laravel-application-to-amazon-lightsail"&gt;&lt;strong&gt;Deploy Laravel Application to Amazon Lightsail&lt;/strong&gt;&lt;/a&gt; or &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail"&gt;&lt;strong&gt;Deploy WordPress App to Amazon Lightsail&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Be a little familiar with AWS Console.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Create Elasticache for Redis
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to &lt;a href="https://us-east-1.console.aws.amazon.com/elasticache/home?/dashboard&amp;amp;region=us-east-1#/dashboard?getStarted=expand"&gt;&lt;strong&gt;Elasticache for Redis console&lt;/strong&gt;&lt;/a&gt;. Change the region that you want to launch it. I selected &lt;strong&gt;us-east-1&lt;/strong&gt; as my Lightsail Instance(s) are there. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the &lt;strong&gt;Create Redis cluster&lt;/strong&gt; button from the center of the page (or wherever you see it)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m7FX4_zD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653740823924/ayTfyM9Sc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m7FX4_zD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653740823924/ayTfyM9Sc.png" alt="CleanShot 2022-05-28 at 18.24.04@2x.png" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You will land in this screen 👇&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c_hlPXnr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653741612053/kUlxh7BaC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c_hlPXnr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653741612053/kUlxh7BaC.png" alt="CleanShot 2022-05-28 at 18.38.27@2x.png" width="800" height="3092"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A. Choose &lt;strong&gt;Configure and create a new cluster&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;B. Choose cluster mode &lt;strong&gt;Disabled&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;C. Give it a name&lt;/li&gt;
&lt;li&gt;D. Uncheck &lt;strong&gt;Multi-AZ&lt;/strong&gt; Enable&lt;/li&gt;
&lt;li&gt;E. Uncheck &lt;strong&gt;Auto-failover&lt;/strong&gt; Enable&lt;/li&gt;
&lt;li&gt;F. Select a free-tier node type. Currently it's "cache.t3.micro" and "cache.t2.micro".&lt;/li&gt;
&lt;li&gt;G. Do not need any replica for this demo. Make it &lt;strong&gt;"0"&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;H. Give subnet groups a name&lt;/li&gt;
&lt;li&gt;I. Select your VPC&lt;/li&gt;
&lt;li&gt;J. And then clieck the &lt;strong&gt;Next&lt;/strong&gt; button from the bottom.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will be on the second page. Just uncheck &lt;strong&gt;Enable automatic backup&lt;/strong&gt; and click the &lt;strong&gt;Next&lt;/strong&gt; button from the bottom of the page. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sIAcA_uC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653742318231/ahAMqpjdB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sIAcA_uC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653742318231/ahAMqpjdB.png" alt="CleanShot 2022-05-28 at 18.50.07@2x.png" width="800" height="1648"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Review everything on the 3rd and final page. And then click the &lt;strong&gt;Create&lt;/strong&gt; button from the bottom of the page. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It will take a few minutes to get created. Wait for status changes to &lt;strong&gt;Available&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7GcVjJUJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743046013/ETHuHBu8T.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7GcVjJUJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743046013/ETHuHBu8T.png" alt="CleanShot 2022-05-28 at 19.03.41@2x.png" width="800" height="134"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;now, click on the Cluster name. And you will be on the details page. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sg96wFVT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743211659/IfsLDKS_6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sg96wFVT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743211659/IfsLDKS_6.png" alt="CleanShot 2022-05-28 at 19.05.38@2x.png" width="800" height="369"&gt;&lt;/a&gt;&lt;br&gt;
Copy the &lt;strong&gt;Primary endpoint&lt;/strong&gt; in your clipboard or somewhere safe. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Configure Security Group for Redis cluster
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the &lt;a href="https://us-east-1.console.aws.amazon.com/vpc/home?region=us-east-1#securityGroups:"&gt;&lt;strong&gt;Security groups&lt;/strong&gt;&lt;/a&gt; of VPS Console. Make sure you are in the same region as the Redis cluster. And then click the &lt;strong&gt;Create security group&lt;/strong&gt; from the top-right corner. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u4Pzr-Nj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653744863578/l7kjpTUOR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u4Pzr-Nj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653744863578/l7kjpTUOR.png" alt="CleanShot 2022-05-28 at 19.33.08@2x.png" width="800" height="178"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You are in create Security Group page&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aFlw632A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653745388466/tlEobrLnW.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aFlw632A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653745388466/tlEobrLnW.png" alt="CleanShot 2022-05-28 at 19.41.30@2x.png" width="800" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A. Give it a name&lt;/li&gt;
&lt;li&gt;B. Click on the &lt;strong&gt;Add rule&lt;/strong&gt; button of the Inbound rules section.&lt;/li&gt;
&lt;li&gt;C. Select 6379 as Custom TCP Port&lt;/li&gt;
&lt;li&gt;D. Add your Amazon Lightsail VPC IP range. To generate it, check your instance's Private IP address. Mine is 172.26.3.157. Replace the last two sections with 0 and add /16. So, mine became 172.26.0.0/16. &lt;/li&gt;
&lt;li&gt;E. Optionally, you can add a description&lt;/li&gt;
&lt;li&gt;F. Then hit the &lt;strong&gt;Create security group&lt;/strong&gt; button from the bottom of the page.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now go to the &lt;strong&gt;Network and security&lt;/strong&gt; tab of your Redis cluster and click the &lt;strong&gt;Modify&lt;/strong&gt; button from the &lt;strong&gt;Security groups&lt;/strong&gt; section.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YuU6thAK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746258674/GFFV32uHF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YuU6thAK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746258674/GFFV32uHF.png" alt="CleanShot 2022-05-28 at 19.55.02@2x.png" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the &lt;strong&gt;Manage&lt;/strong&gt; button from the next screen&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DU-pb72U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746332691/9RL95yIIC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DU-pb72U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746332691/9RL95yIIC.png" alt="CleanShot 2022-05-28 at 19.58.02@2x.png" width="800" height="624"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the correct security group from the pop and then click on the &lt;strong&gt;Choose&lt;/strong&gt; button. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YgKNYmVB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746443378/yYbIwHuCh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YgKNYmVB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746443378/yYbIwHuCh.png" alt="CleanShot 2022-05-28 at 19.59.19@2x.png" width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click &lt;strong&gt;Modify&lt;/strong&gt; button from the bottom of the page.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M0he_8ew--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746505482/U9cm147ER.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0he_8ew--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653746505482/U9cm147ER.png" alt="CleanShot 2022-05-28 at 20.00.47@2x.png" width="800" height="845"&gt;&lt;/a&gt;&lt;br&gt;
It will take a few minutes to complete the modification. Wait until the status changes to &lt;strong&gt;Available&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  VPC Peering
&lt;/h2&gt;

&lt;p&gt;The important part of this tutorial. We need to peer VPC between Lightsail and Redis cluster's VPC to connect it. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the homepage of the Amazon Lightsail console. Click the &lt;strong&gt;Account&lt;/strong&gt; from the Account menu dropdown. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--thvaAQaT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743506780/Kkbk-kt5P.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--thvaAQaT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743506780/Kkbk-kt5P.png" alt="CleanShot 2022-05-28 at 19.10.54@2x.png" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the &lt;strong&gt;Advanced&lt;/strong&gt; tab from the Account settings page. You will see a list of your VPCs. Connect the one that resides in your Redis cluster. For me, it's *&lt;em&gt;Virginia (us-east-1)&lt;br&gt;
*&lt;/em&gt;. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QQUVNtl2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743731968/0hJH7OqKe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QQUVNtl2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653743731968/0hJH7OqKe.png" alt="CleanShot 2022-05-28 at 19.12.35@2x.png" width="800" height="666"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Connect to the Redis cluster from the Lightsail instance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Using CLI
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Connect to the instance using SSH. &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail#heading-connect-to-the-instance-using-ssh"&gt;Follow this&lt;/a&gt; to connect to SSH.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install Redis CLI &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A. On Amazon Linux 2
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;amazon-linux-extras &lt;span class="nb"&gt;install &lt;/span&gt;epel &lt;span class="nt"&gt;-y&lt;/span&gt;
  &lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;gcc jemalloc-devel openssl-devel tcl tcl-devel &lt;span class="nt"&gt;-y&lt;/span&gt;
  &lt;span class="nb"&gt;sudo &lt;/span&gt;wget http://download.redis.io/redis-stable.tar.gz
  &lt;span class="nb"&gt;sudo tar &lt;/span&gt;xvzf redis-stable.tar.gz
  &lt;span class="nb"&gt;cd &lt;/span&gt;redis-stable
  &lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nv"&gt;BUILD_TLS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;B. on Ubuntu
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;redis-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now connect to the Redis cluster. The moment of truth.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;redis-cli &lt;span class="nt"&gt;-h&lt;/span&gt; &amp;lt;redis_endpoint&amp;gt; &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 6379
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;redis_endpoint&amp;gt;&lt;/code&gt; with your Primary endpoint of Redis you copied in the clipboard. Remove port (":6379") from the endpoint URL. You will see this screen if successful 👇 &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--08JkTR6C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653747050113/8YFSWvlOm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--08JkTR6C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1653747050113/8YFSWvlOm.png" alt="CleanShot 2022-05-28 at 20.10.24@2x.png" width="800" height="219"&gt;&lt;/a&gt;&lt;br&gt;
You can use the &lt;code&gt;ping&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;, and &lt;code&gt;get&lt;/code&gt; commands to test it out. &lt;/p&gt;

&lt;h3&gt;
  
  
  Connect to Application
&lt;/h3&gt;

&lt;p&gt;You will get packages for most of the Applications, languages, and Frameworks. Check docs. For Laravel, you just have to configure it in the &lt;code&gt;.env&lt;/code&gt; file.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope you enjoyed this short article. You can subscribe to my newsletter, and follow me on &lt;a href="https://twitter.com/HarunRRayhan"&gt;Twitter&lt;/a&gt;, &lt;a href="https://dev.to/harunrrayhan"&gt;Dev.to&lt;/a&gt;, and &lt;a href="https://hashnode.com/@HarunRRayhan"&gt;Hashnode&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>redis</category>
      <category>vpc</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Add Lightsail Load Balancer to Application hosted in Amazon Lightsail instance(s)</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Sat, 28 May 2022 11:12:16 +0000</pubDate>
      <link>https://dev.to/aws-builders/add-lightsail-load-balancer-to-application-hosted-in-amazon-lightsail-instances-3eh</link>
      <guid>https://dev.to/aws-builders/add-lightsail-load-balancer-to-application-hosted-in-amazon-lightsail-instances-3eh</guid>
      <description>&lt;p&gt;Lightsail offers Load Balancer. It's very easy to provision one and attach one or multiple instances to it. Let's create one and attach instances to it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You need one or more Amazon Lightsail instances to attach to the load balancer in the same region. You can create it by following &lt;a href="https://blog.harun.dev/deploy-laravel-application-to-amazon-lightsail"&gt;&lt;strong&gt;Deploy Laravel Application to Amazon Lightsail&lt;/strong&gt;&lt;/a&gt; or  &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail"&gt;&lt;strong&gt;Deploy WordPress App to Amazon Lightsail&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ Warning: Amazon Light Load Balancer going to cost you &lt;strong&gt;USD$18/month&lt;/strong&gt;. It has no pre-tier available. Be sure before going to provision one. You can check the whole article before creating.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Provision a Load Balanced
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the homepage of the Amazon Lightsail console. Click on the &lt;strong&gt;Networking&lt;/strong&gt; tab and click on the &lt;strong&gt;Create load balancer&lt;/strong&gt; button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iFj8GU34--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653732192960/YhPj7TMSKh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iFj8GU34--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653732192960/YhPj7TMSKh.png" alt="CleanShot 2022-05-28 at 16.02.40@2x.png" width="880" height="551"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You are in the Create a Load balancer screen like this 👇&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rtAQKB2z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653732418229/ZhwhaDAYk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rtAQKB2z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653732418229/ZhwhaDAYk.png" alt="CleanShot 2022-05-28 at 16.04.46@2x.png" width="880" height="1174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A. Change your region to where your instances are. My instances are in Virginia.&lt;/li&gt;
&lt;li&gt;B. Give it a name, and&lt;/li&gt;
&lt;li&gt;C. Hit the &lt;strong&gt;Create load balancer&lt;/strong&gt; button from the bottom.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load balancer will be created in a moment and you should land on the Load balancer page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Attach instances to the Load balance
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the homepage again and then click the &lt;strong&gt;Networking&lt;/strong&gt; tab. You should see Loadbalancer(s) including the one just created. Click on the name of the Load balancer.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ACtH1Y2d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653732814943/IrgiatFzx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ACtH1Y2d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653732814943/IrgiatFzx.png" alt="CleanShot 2022-05-28 at 16.13.01@2x.png" width="880" height="631"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Our load balancer doesn't have any attached instance(s) yet, we are going to attach one or more. Select your instance in the Target instances section. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ojs9SjLX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653733100321/tow7uBR8v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ojs9SjLX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653733100321/tow7uBR8v.png" alt="CleanShot 2022-05-28 at 16.15.02@2x.png" width="880" height="743"&gt;&lt;/a&gt;&lt;br&gt;
I just have one in this region. You should see all of the instances you have in the region where the load balancer is provisioned. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Confirm the attachment of your instance&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXD6pnlk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653733242717/-HlrPCaJl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXD6pnlk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653733242717/-HlrPCaJl.png" alt="CleanShot 2022-05-28 at 16.19.15@2x.png" width="880" height="703"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do the same process until you attached all of your target instances. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to Load balancer URL (&lt;strong&gt;DNS name&lt;/strong&gt;) and you should see your application. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FdJiMGCj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653733608361/h0TDAs9G8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FdJiMGCj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653733608361/h0TDAs9G8.png" alt="CleanShot 2022-05-28 at 16.26.00@2x.png" width="880" height="240"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;ℹ️ If you don't see the desired page, check your application or other tools (Apache, Nginx, etc.) setting. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Add Domain or Sub-Domain
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You can create DNS Zone in Lightsail for your domain and configure it. &lt;a href="https://lightsail.aws.amazon.com/ls/docs/en_us/articles/add-alias-record-for-lightsail-load-balancer"&gt;Follow this to add your domain/sub-domain&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can add the Load balancer URL (&lt;strong&gt;DNS name&lt;/strong&gt;) as A record in your domain's DNS control panel.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Enable HTTPS
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to the &lt;strong&gt;Inbound traffic&lt;/strong&gt; tab of your Load balancer setting. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KYS-QMim--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1653734254772/badvd2GAs.png" alt="CleanShot 2022-05-28 at 16.35.34@2x.png" width="880" height="704"&gt;

&lt;ul&gt;
&lt;li&gt;A. Create an SSL certificate for your domain by clicking the &lt;strong&gt;Create certificate +&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;B. You should see all of the created certificates in the &lt;strong&gt;SSL/TLS certificate&lt;/strong&gt; list and select the one you just created. &lt;/li&gt;
&lt;li&gt;C. Optionally, you can Redirect from HTTP to HTTPS. (After enabling the HTTPS).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope you enjoyed this short article. You can subscribe to my newsletter, and follow me on &lt;a href="https://twitter.com/HarunRRayhan"&gt;Twitter&lt;/a&gt;, &lt;a href="https://dev.to/harunrrayhan"&gt;Dev.to&lt;/a&gt;, and &lt;a href="https://hashnode.com/@HarunRRayhan"&gt;Hashnode&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>lightsail</category>
      <category>ec2</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Add Database to Application hosted in Amazon Lightsail</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Mon, 23 May 2022 14:04:33 +0000</pubDate>
      <link>https://dev.to/aws-builders/add-database-to-application-hosted-in-amazon-lightsail-1lgk</link>
      <guid>https://dev.to/aws-builders/add-database-to-application-hosted-in-amazon-lightsail-1lgk</guid>
      <description>&lt;p&gt;Amazon Lightsail offers dedicated Databases. You can make use of it instead of an on-instance database. It's easy, managed, secure, and most importantly it's not tied to the instance. So, your database will be safe even if instance crashes.&lt;/p&gt;

&lt;p&gt;In "&lt;strong&gt;&lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail" rel="noopener noreferrer"&gt;Deploy WordPress App to Amazon Lightsail&lt;/a&gt;&lt;/strong&gt;, the database is installed in the instance. In this article, we are to cover the dedicated databases.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ Warning: Dedicated Lightsail Databases are going to cost $$$. It has a 3-month free tier at this time of writing. Check your plan before creating a database.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, what are you waiting for? Let's dive right in 🏃‍♂️&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Database Instance
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to your Amazon Lightsail home page. And then click on the &lt;strong&gt;Databases&lt;/strong&gt; tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now click on the &lt;strong&gt;Create database&lt;/strong&gt; button&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653131872710%2FgEcI9vj3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653131872710%2FgEcI9vj3t.png" alt="CleanShot 2022-05-21 at 17.17.16@2x.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now you are on the database creation page: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653132301734%2Fu04toFGII.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653132301734%2Fu04toFGII.png" alt="CleanShot 2022-05-21 at 17.23.57@2x.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(A) Select AWS Region and Availablity Zone (AZ). for me Virginia and Zone A are perfect.&lt;/li&gt;
&lt;li&gt;(B) Choose the Database engine and version. I selected MySQL 8.&lt;/li&gt;
&lt;li&gt;(C) Click on &lt;strong&gt;Specify login credentials&lt;/strong&gt;, and&lt;/li&gt;
&lt;li&gt;(D) Click on &lt;strong&gt;Specify the master database name&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Scroll down a little and configure this: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653134742780%2FDRvaNLKt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653134742780%2FDRvaNLKt4.png" alt="CleanShot 2022-05-21 at 18.03.04@2x.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(A) Choose Database username&lt;/li&gt;
&lt;li&gt;(B) Password. I'm okay with the generated password, but you can choose yours.&lt;/li&gt;
&lt;li&gt;(C) The first/master database. You can create more later.&lt;/li&gt;
&lt;li&gt;(D &amp;amp; E) Choose your plan type and the actual plan. You can choose the free-tier option like me.&lt;/li&gt;
&lt;li&gt;(F) Give it a name, and&lt;/li&gt;
&lt;li&gt;(G) Hit the &lt;strong&gt;Create database&lt;/strong&gt; button
Your database should be created within a few minutes. Please wait for it until it's &lt;strong&gt;Running&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Database Credentials
&lt;/h2&gt;

&lt;p&gt;You already know your database username and master database. For everything else, go to your database and click on the &lt;strong&gt;Connect&lt;/strong&gt; tab. You should see your credentials like this:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653135919053%2Fo9bP5UDl4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653135919053%2Fo9bP5UDl4.png" alt="CleanShot 2022-05-21 at 18.24.30@2x.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(A) DB Username&lt;/li&gt;
&lt;li&gt;(B) DB Password&lt;/li&gt;
&lt;li&gt;(C) DB Endpoint&lt;/li&gt;
&lt;li&gt;(D) DB Port&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Connect to the database
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Instance CLI
&lt;/h3&gt;

&lt;p&gt;You can &lt;a href="https://blog.harun.dev/deploy-laravel-application-to-amazon-lightsail#heading-connect-to-the-instance-using-ssh" rel="noopener noreferrer"&gt;SSH into your instance&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Install MySQL using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;mysql-server &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start mysql.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then connect to MySQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;--host&lt;/span&gt; &amp;lt;db_endpoint&amp;gt; &lt;span class="nt"&gt;--user&lt;/span&gt; &amp;lt;db_username&amp;gt; &lt;span class="nt"&gt;--password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be asked for your DB password. If successful, you will see this screen:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653136540334%2FgIFUYhIHz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1653136540334%2FgIFUYhIHz.png" alt="CleanShot 2022-05-21 at 18.35.21@2x.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  SQL Client App over SSH (SSH Tunneling)
&lt;/h3&gt;

&lt;p&gt;Most modern SQL Client applications (ex &lt;a href="https://docs.tableplus.com/gui-tools/manage-connections#ssh-tunneling" rel="noopener noreferrer"&gt;TablePlus&lt;/a&gt;, MySQL Workbench) have the option to connect Database via SSH. You can connect using that option. &lt;/p&gt;

&lt;h2&gt;
  
  
  Add Database to your application
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Laravel and NodeJS
&lt;/h3&gt;

&lt;p&gt;You can update your application's &lt;code&gt;.env&lt;/code&gt; file with Database credentials.&lt;/p&gt;

&lt;h3&gt;
  
  
  WordPress
&lt;/h3&gt;

&lt;p&gt;Update your &lt;code&gt;wp-config.php&lt;/code&gt; file with the database credentials.&lt;/p&gt;

&lt;h3&gt;
  
  
  Any other app
&lt;/h3&gt;

&lt;p&gt;Update your database credential in your application's configuration and/or environment file. Check your application's documentation for that. Or it's custom, you know where to put it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thanks for reading the article. Adding dedicated databases to Amazon Lightsail instance is not that hard. You can follow me to get instant updates on my posts. You can also subscribe to &lt;a href="https://blog.harun.dev" rel="noopener noreferrer"&gt;my newsletter&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>lightsail</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Deploy Laravel Application to Amazon Lightsail</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Thu, 19 May 2022 15:06:43 +0000</pubDate>
      <link>https://dev.to/aws-builders/deploy-laravel-application-to-amazon-lightsail-5e8g</link>
      <guid>https://dev.to/aws-builders/deploy-laravel-application-to-amazon-lightsail-5e8g</guid>
      <description>&lt;p&gt;Beginners friendly step-by-step guide to deploy any application to Amazon Lightsail. This article demos a Laravel app but the idea is the same for all kind of applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Amazon Lightsail is a fixed monthly priced VPS service offered by AWS. Once you install the OS of your choice, you can run almost any application. In this application, I'm showing how to deploy one of my favorite backend frameworks called Laravel. Which most of you might hear of. Let's deploy it.&lt;/p&gt;

&lt;h2&gt;
  
  
  I don't like/know Laravel
&lt;/h2&gt;

&lt;p&gt;It's totally fine if you don't like or know Laravel. Laravel is just the framework I choose to demo but it can be any app. It can be Node.js, Python, Django, Fast API, Ruby on Rails, or any other app. The idea is the same, but some of the steps in deployment will be different.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You need a Laravel app to deploy. Don't worry if you don't have one, I have to best &lt;a href="https://github.com/HarunRay/laravel-to-lightsail"&gt;Laravel (v9) app&lt;/a&gt; you can find in the internet (pun intended).&lt;/p&gt;

&lt;p&gt;Let's deploy our Laravel app. 📦👉☁️&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Amazon Lightsail Instance
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to Lightsail homepage. Click on the &lt;strong&gt;Create instance&lt;/strong&gt; button under &lt;strong&gt;Instances&lt;/strong&gt; tab.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3AxVpBKU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652881692076/hLgNOWXsk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3AxVpBKU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652881692076/hLgNOWXsk.png" alt="CleanShot 2022-05-18 at 19.44.36@2x.png" width="880" height="424"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will land on the Create instance page. We will use Ubuntu for this demo but you are open to choosing the OS of your choice. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lfzBjBLQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652882301357/kHB-fJG9L.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lfzBjBLQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652882301357/kHB-fJG9L.png" alt="CleanShot 2022-05-18 at 19.51.37@2x.png" width="880" height="2522"&gt;&lt;/a&gt;&lt;br&gt;
(A) Change the AWS Region and Availablity Zone (AZ) of your choice if not the correct one selected. (B) Select &lt;strong&gt;Linux/Unix&lt;/strong&gt; platform. (C) Select &lt;strong&gt;Ubuntu (20.04 LTS)&lt;/strong&gt; as OS. The blueprint should be &lt;strong&gt;OS Only&lt;/strong&gt;. (D) Choose a plan. (E) Give it a name, and (F) Hit the &lt;strong&gt;Create instance&lt;/strong&gt; button from the bottom of the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your instance is in the &lt;strong&gt;Pending&lt;/strong&gt; state. Will be &lt;strong&gt;Running&lt;/strong&gt; in a few minutes. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Assign a static IP
&lt;/h2&gt;

&lt;p&gt;Read &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail#heading-assign-a-static-ip-optional"&gt;&lt;strong&gt;how to assign a Static IP to an Amazon Lightsail Instance&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect to the instance using SSH
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;ℹ️ I described in detail &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail#heading-connect-to-the-instance-using-ssh"&gt;How to connect to an Amazon Lightsail instance using SSH&lt;/a&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the instance page by clicking on the name. And go to the &lt;strong&gt;Connect&lt;/strong&gt; tab. We need these 3 things: (A) Public IP, (B) SSH Username, and (C) Download the SSH Key. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vOS_v6cq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652883714529/oW0f4b2AO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vOS_v6cq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652883714529/oW0f4b2AO.png" alt="CleanShot 2022-05-18 at 20.21.12@2x.png" width="880" height="797"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Change permission of Key file:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Change "path/to/keyfile.pem" with your key file name&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;400 path/to/keyfile.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Connect to the SSH
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#format &lt;/span&gt;
ssh &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"path/to/keyfile.pem"&lt;/span&gt; &amp;lt;username&amp;gt;@&amp;lt;ip_address&amp;gt;
&lt;span class="c"&gt;# Should look like this with your own value&lt;/span&gt;
&lt;span class="c"&gt;# ssh -i "LightsailDefaultKey-us-east-1.pem" ubuntu@52.201.59.133&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;If you are asked to add IP to known hosts, type &lt;code&gt;yes&lt;/code&gt; and you should be logged in. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Installing Necessary Scripts
&lt;/h2&gt;

&lt;p&gt;Our server is created and it's empty. You can install any script you want, depending on what you need. In this demo, we are going to use Laravel. You can follow along even if you have a different app/stack.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update package information
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Some packages
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;curl git unzip &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Install PHP 
I love the latest PHP 8.1. It's not officially available in Ubuntu 20.04 yet. We will enable the PHP Repository to install PHP 8.1.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;software-properties-common &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;add-apt-repository ppa:ondrej/php &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;php8.1-fpm php8.1-cli php8.1-mysql php8.1-curl php-xml php-mbstring &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check php version by using &lt;code&gt;php --version&lt;/code&gt; command. You should see something like this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gZzy_Ygu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652886148738/mv58j3RPp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gZzy_Ygu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652886148738/mv58j3RPp.png" alt="CleanShot 2022-05-18 at 21.02.08@2x.png" width="880" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Composer
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download the bin file&lt;/span&gt;
curl &lt;span class="nt"&gt;-sS&lt;/span&gt; https://getcomposer.org/installer | php
&lt;span class="c"&gt;# Move it to correct path&lt;/span&gt;
&lt;span class="nb"&gt;sudo mv &lt;/span&gt;composer.phar /usr/local/bin/composer
&lt;span class="c"&gt;# Make it executeable&lt;/span&gt;
&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; +x /usr/local/bin/composer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Install Nginx &amp;amp; configure nginx
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nginx &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Clone your application repo
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# go to www directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /var/www/html
&lt;span class="c"&gt;# clone the git repo&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;git clone https://github.com/HarunRay/laravel-to-lightsail.git
&lt;span class="c"&gt;# go to application directory&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;laravel-to-lightsail
&lt;span class="c"&gt;# copy .env.example file&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
&lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;composer &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Create a nginx config file
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /etc/nginx/sites-available/laravel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Paste this code. Change &lt;code&gt;52.201.59.133&lt;/code&gt; to your IP address and save.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="s"&gt;[::]:80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="s"&gt;.201.59.133&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;root&lt;/span&gt; &lt;span class="n"&gt;/var/www/html/laravel-to-lightsail/public&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;add_header&lt;/span&gt; &lt;span class="s"&gt;X-Frame-Options&lt;/span&gt; &lt;span class="s"&gt;"SAMEORIGIN"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;add_header&lt;/span&gt; &lt;span class="s"&gt;X-Content-Type-Options&lt;/span&gt; &lt;span class="s"&gt;"nosniff"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;index&lt;/span&gt; &lt;span class="s"&gt;index.php&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;charset&lt;/span&gt; &lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;try_files&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="n"&gt;/index.php?&lt;/span&gt;&lt;span class="nv"&gt;$query_string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;/favicon.ico&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kn"&gt;access_log&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="kn"&gt;log_not_found&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;/robots.txt&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kn"&gt;access_log&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="kn"&gt;log_not_found&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kn"&gt;error_page&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt; &lt;span class="n"&gt;/index.php&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="p"&gt;~&lt;/span&gt; &lt;span class="sr"&gt;\.php$&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;fastcgi_pass&lt;/span&gt; &lt;span class="s"&gt;unix:/var/run/php/php8.1-fpm.sock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;fastcgi_param&lt;/span&gt; &lt;span class="s"&gt;SCRIPT_FILENAME&lt;/span&gt; &lt;span class="nv"&gt;$realpath_root$fastcgi_script_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;include&lt;/span&gt; &lt;span class="s"&gt;fastcgi_params&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="p"&gt;~&lt;/span&gt; &lt;span class="sr"&gt;/\.(?!well-known).*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;deny&lt;/span&gt; &lt;span class="s"&gt;all&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, run this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# link nginx config &lt;/span&gt;
&lt;span class="nb"&gt;sudo ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start nginx
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Set Laravel App Permission
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Go to your laravel app directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /var/www/html/laravel-to-lightsail/
&lt;span class="c"&gt;# Add files &amp;amp; folder www-data user &amp;amp; group&lt;/span&gt;
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; www-data:www-data &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="c"&gt;# Add your ubuntu to group&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-G&lt;/span&gt; www-data ubuntu
&lt;span class="c"&gt;# Set file(s) permission&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;chmod &lt;/span&gt;644 &lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="se"&gt;\;&lt;/span&gt;
&lt;span class="c"&gt;# Set folder(s) permission&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; d &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;chmod &lt;/span&gt;755 &lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="se"&gt;\;&lt;/span&gt;
&lt;span class="c"&gt;# Set cache directory permission&lt;/span&gt;
&lt;span class="nb"&gt;sudo chgrp&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; www-data storage bootstrap/cache
&lt;span class="nb"&gt;sudo chmod&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; ug+rwx storage bootstrap/cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Generate app key
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;php artisan key:generate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Update the &lt;code&gt;.env&lt;/code&gt; file
Open file
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /var/www/html/laravel-to-lightsail/.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, change these values;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;APP_ENV=production
# Change IP to yours
APP_URL=http://52.201.59.133
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go to your public IP address. Mine is &lt;code&gt;http://52.201.59.133&lt;/code&gt;. You should see this welcome page. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T8cR8Egb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652971832893/zcqFK0B3U.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T8cR8Egb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652971832893/zcqFK0B3U.png" alt="CleanShot 2022-05-19 at 20.50.16@2x.png" width="880" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, your Laravel app launched on Amazon Lightsail instance. 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In the next few articles, we are going to configure the database, load balancer &amp;amp; Redis (Elasticache). Follow me and subscribe to &lt;a href="https://blog.harun.dev"&gt;my newsletter&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>lightsail</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Snapshot and Restore of Lightsail Instance to Lightsail/EC2</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Thu, 12 May 2022 14:31:04 +0000</pubDate>
      <link>https://dev.to/aws-builders/snapshot-and-restore-of-lightsail-instance-to-lightsailec2-l0j</link>
      <guid>https://dev.to/aws-builders/snapshot-and-restore-of-lightsail-instance-to-lightsailec2-l0j</guid>
      <description>&lt;p&gt;Taking regular backup/snapshots of a production application is important. It is one of the main requirements of a disaster recovery(DR) plan. But snapshots are not only for DR, you can use them to move/clone instances to different regions or availability zone(AZ). Maybe move to a higher spec instance. Or maybe you want to move to Amazon EC2 altogether. &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;You just need an existing Amazon Lightsail instance. Don't worry if you don't have one, follow how to &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail"&gt;&lt;strong&gt;Deploy WordPress App to Amazon Lightsail&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Take Snapshot (Backup)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on the instance name you want to take a snapshot. All of the instances are listed under the &lt;strong&gt;Instances&lt;/strong&gt; tab of the home page. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LaM1t_UD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652276595201/R3KWMrmbY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LaM1t_UD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652276595201/R3KWMrmbY.png" alt="Amazon Lightsail Instances" width="880" height="376"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the &lt;strong&gt;Snapshots&lt;/strong&gt; tab of your instance page. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3Tt9FY_2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652276809173/QeAJzi5B9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3Tt9FY_2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652276809173/QeAJzi5B9.png" alt="Amazon Lightsail Instance Snapshot" width="880" height="548"&gt;&lt;/a&gt;&lt;br&gt;
(B) We are going to create a manual snapshot. This one will take a snapshot instantly.&lt;br&gt;
(C) Optionally, you can set up an automatic snapshot too. It will take daily snapshots. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;em&gt;**For production instance, always set up an automatic snapshot. *&lt;/em&gt;*&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give it a name and click &lt;strong&gt;Create&lt;/strong&gt;. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--abmZ5V5z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652277314811/vY0klcQ0u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--abmZ5V5z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652277314811/vY0klcQ0u.png" alt="Amazon Lightsail Instance Snapshot" width="880" height="386"&gt;&lt;/a&gt;&lt;br&gt;
It will take some time if this is the first snapshot of the instance, size is another factor. Subsequent snapshots are faster, as it takes incremental backups, only changes from the last snapshot. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upon completion, it will look like this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uZ_WrMAd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652277636707/z3QUzzdTY.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uZ_WrMAd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652277636707/z3QUzzdTY.png" alt="Amazon Lightsail Instance Snapshot" width="880" height="375"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will find all of the snapshots in the &lt;strong&gt;Snapshots&lt;/strong&gt; tab of the homepage. I have just one: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pEUSSkMB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652277823766/xBicTLwpc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pEUSSkMB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652277823766/xBicTLwpc.png" alt="Amazon Lightsail all snapshots" width="880" height="408"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Restore to new Amazon Lightsail instance
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on these 👇 three dots: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lU3QY7ES--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652278253575/66DQ_Myis.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lU3QY7ES--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652278253575/66DQ_Myis.png" alt="Lightsail Snapshot restore menu" width="880" height="437"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click on &lt;strong&gt;Create new instance&lt;/strong&gt; from this menu: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ELkHlh5t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652278347973/Lb09a0P_tP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ELkHlh5t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652278347973/Lb09a0P_tP.png" alt="Lightsail Snapshot restore menu" width="880" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ℹ️ You can click on the second item, &lt;strong&gt;Copy to another Region&lt;/strong&gt; to literally copy to another region and restore to a new instance there. Snapshot stored in an S3 bucket in the same region where the instance launched. You can't access the S3 bucket as it's managed by AWS. To restore a snapshot to a new instance in another region, you have to copy it first.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The page looks familiar, right? It's the same create instance page.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0vifeO9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652279009412/Z5_gktIsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0vifeO9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652279009412/Z5_gktIsy.png" alt="Create an instance from a snapshot in Amazon Lightsail" width="880" height="1662"&gt;&lt;/a&gt;&lt;br&gt;
(A) You can change the availability zone(AZ) if you want. It's great if you are using multiple instances for horizontal scaling, gives high availability(HA). &lt;br&gt;
(B) Choose an instance the same size or larger than the source. Choose larger for vertical scaling. If you need a larger instance than you originally have, this is the way.&lt;br&gt;
(C) Give it a name, and &lt;br&gt;
(D) Click the &lt;strong&gt;Create instance&lt;/strong&gt; button from the bottom of the page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Wait a moment, maybe a few minutes. Congratulations 🎉 you just restored your instance. &lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  Copy to another Region
&lt;/h2&gt;

&lt;p&gt;Snapshot stored in an S3 bucket in the same region where the instance launched. You can't access the S3 bucket as it's managed by AWS. To restore a snapshot to a new instance in another region, you have to copy it first. Let's copy it to another region.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the &lt;strong&gt;Snapshots&lt;/strong&gt; tab of the homepage. Find your instance and snapshot. Click the three dots. And then click &lt;strong&gt;Copy to another Region&lt;/strong&gt;:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NPBxA8NF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652280120596/KG3CA5XoC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NPBxA8NF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652280120596/KG3CA5XoC.png" alt="Copy snapshot to another Region in Amazon Lightsail" width="880" height="529"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(A) Choose the region you want to copy the snapshot, (B) give it a name, and (C) click the &lt;strong&gt;Copy snapshot&lt;/strong&gt; button from the bottom of the page. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cjE2WP1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652279993049/8ENAFcW2C.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cjE2WP1f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652279993049/8ENAFcW2C.png" alt="Copy snapshot to another Region in Amazon Lightsail" width="880" height="1044"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It will take a few minutes to copy the snapshot.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  Restore/Export to Amazon EC2 instance
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click three dots from the snapshot menu you want to restore to EC2 and click the &lt;strong&gt;Export to Amazon EC2&lt;/strong&gt; menu item &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BNrUr_GG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281038616/V9usMFaL7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BNrUr_GG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281038616/V9usMFaL7.png" alt="Export to Amazon EC2" width="880" height="697"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the &lt;strong&gt;Yes, continue&lt;/strong&gt; button in the popup. Click &lt;strong&gt;Acknowledge&lt;/strong&gt; in the next popup.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GBlKWHdP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281327886/UOQteEtmX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GBlKWHdP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281327886/UOQteEtmX.png" alt="Export to Amazon EC2" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ If you are not in the free-tier or cross the free-tier limit, you may get charged for this. If you are not sure, don't do it. Just follow my demo.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will see a task running like this ↓. Wait for a while to finish. A small snapshot wouldn't take much time. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nWzuDZ7H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281563424/lc_Mz-K0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nWzuDZ7H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281563424/lc_Mz-K0d.png" alt="Export to Amazon EC2" width="880" height="336"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the copy task is completed, go to &lt;a href="https://us-east-1.console.aws.amazon.com/ec2/v2/home?region=us-east-1#Snapshots:"&gt;Snapshots of EC2 Management Console&lt;/a&gt;. Choose the correct region. You should see your snapshot there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the snapshot and click the &lt;strong&gt;Create image from snapshot&lt;/strong&gt; from the &lt;strong&gt;Actions&lt;/strong&gt; menu &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z5xFAZqc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281992820/AGSDZSL0V.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z5xFAZqc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652281992820/AGSDZSL0V.png" alt="Snapshots on EC2 Management Console" width="880" height="208"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give the name of the image and click the &lt;strong&gt;Create image&lt;/strong&gt; button from the bottom of the page&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D4XO1G61--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652282168870/rem3kb_a1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D4XO1G61--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652282168870/rem3kb_a1.png" alt="Snapshots on EC2 Management Console" width="880" height="785"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now go to &lt;a href="https://us-east-1.console.aws.amazon.com/ec2/v2/home?region=us-east-1#Images:visibility=owned-by-me"&gt;AMIs page of EC2 Management Console&lt;/a&gt;. Choose the correct region, N. Virginia (us-east-1) in my case. You should see all of your AMIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the AMIs you just created and click the &lt;strong&gt;Lunch Instance from AMI&lt;/strong&gt; button in the top right corner. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z4xi5LzI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652362498403/WWWDZ_9xk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z4xi5LzI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652362498403/WWWDZ_9xk.png" alt="CleanShot 2022-05-12 at 19.34.19@2x.png" width="880" height="223"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will see a traditional EC2 Lunch page: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K7-VljkS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652363162708/wxsZxlGt6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K7-VljkS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652363162708/wxsZxlGt6.png" alt="CleanShot 2022-05-12 at 19.44.03@2x.png" width="880" height="2603"&gt;&lt;/a&gt;&lt;br&gt;
(A) Give your instance a name. (B) Choose an instance type, for my case, it's free tier eligible t2.micro. (C) Choose existing key pair or create a new one. You need it to log in via SSH. (D) Check the ports you want to open, in my case I selected all of them. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, click the &lt;strong&gt;Lunch instance&lt;/strong&gt; button from the right sidebar. Wait for a while to instance state to become &lt;strong&gt;&lt;em&gt;Running&lt;/em&gt;&lt;/strong&gt; and Status check &lt;strong&gt;&lt;em&gt;2/2 checks passed&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You will see the EC2 Instances page like this:
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z78OuhGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1652363823997/TMySzalyO.png" alt="CleanShot 2022-05-12 at 19.56.19@2x.png" width="880" height="473"&gt;
Select the instance. Copy the public IP address and try it in the browser. You should see the same page as Amazon Lightsail instance. &lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;ℹ️ Manual snapshots will not be deleted even if you delete the instance. So, don't forget to delete unnecessary snapshots to save bills.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope you enjoyed this article. Ask your questions in the comment. Subscribe to my newsletter to get weekly updates. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>ec2</category>
      <category>lightsail</category>
    </item>
    <item>
      <title>Add (Cloudfront) CDN Distribution to WordPress Application hosted on Amazon Lightsail</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Tue, 10 May 2022 12:15:16 +0000</pubDate>
      <link>https://dev.to/aws-builders/add-cloudfront-cdn-distribution-to-wordpress-application-hosted-on-amazon-lightsail-4hlh</link>
      <guid>https://dev.to/aws-builders/add-cloudfront-cdn-distribution-to-wordpress-application-hosted-on-amazon-lightsail-4hlh</guid>
      <description>&lt;p&gt;It's not very hard to add CDN Distribution to a WordPress app hosted on Amazon Lightsail. But if you are new, it can be cumbersome. This article is to demonstrate how to do it easily. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should I use CDN distribution?
&lt;/h2&gt;

&lt;p&gt;You might hear about Content Delivery Network (CDN). If not, here is an article explaining "&lt;a href="https://www.cloudflare.com/en-gb/learning/cdn/what-is-a-cdn/" rel="noopener noreferrer"&gt;what is CDN?&lt;/a&gt;". &lt;/p&gt;

&lt;p&gt;If you are not interested to read a long article, here is TL;DR: &lt;br&gt;
In CDN, Lots of small servers run closer to your customer. Content gets cached there and served from the closer server(s) of your customer. In that way, ease the pressure from the main servers. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is CDN Distribution?
&lt;/h2&gt;

&lt;p&gt;It is the Amazon Lightsail CDN service. Under the hood, it uses Amazon Cloudfront. It has 300+ points of presence to deliver content closer to your customers. On top of that, it comes with AWS Shield, which protects infrastructure from DDoS attacks. &lt;/p&gt;

&lt;p&gt;Are you excited to create your first CDN Distribution? Let's go 🏃‍♂️&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;h3&gt;
  
  
  WordPress Application
&lt;/h3&gt;

&lt;p&gt;You need to have an existing WordPress application for this tutorial. Don't worry if you don't have one. I covered How to &lt;strong&gt;&lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail" rel="noopener noreferrer"&gt;Deploy WordPress Application to Amazon Lightsail&lt;/a&gt;&lt;/strong&gt; in the first part of this series. &lt;/p&gt;

&lt;h3&gt;
  
  
  Attach a Static IP to WordPress Instance
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to the &lt;strong&gt;Networking&lt;/strong&gt; tab  and then click on &lt;strong&gt;Create static IP&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652105796032%2FZIYg4ZWz8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652105796032%2FZIYg4ZWz8.png" alt="Create static IP on Amazon Lightsail"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(A) Select the WP App instance. (B) Give it a meaningful name and (C) Hit &lt;strong&gt;Create&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652106216696%2FZDKxefs2H.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652106216696%2FZDKxefs2H.png" alt="Create static IP on Amazon Lightsail 2"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we are ready to create our first distributions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create CDN Distribution
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Go to &lt;a href="https://lightsail.aws.amazon.com/ls/webapp/home/networking" rel="noopener noreferrer"&gt;home page&lt;/a&gt; of Lightsail. Go to &lt;strong&gt;Network&lt;/strong&gt; tab again. This time hit the &lt;strong&gt;Create distribution&lt;/strong&gt; button. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652106732159%2FUaCC5eSiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652106732159%2FUaCC5eSiv.png" alt="Create CDN Distribution on Amazon Lightsail"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the WordPress Instance as Origin &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652106891069%2FW12TgIi-k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652106891069%2FW12TgIi-k.png" alt="Amazon Lightsail CDN Distribution Origin"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hit &lt;strong&gt;Yes, apply&lt;/strong&gt; to apply the predefined WordPress settings&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652107873667%2FpiEvwljg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652107873667%2FpiEvwljg1.png" alt="Amazon Lightsail CDN Distribution WordPress"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now, (A) choose a plan. (B) Give it a name and (C) Hit &lt;strong&gt;Create Distribution&lt;/strong&gt; button&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652107795929%2FSf65bVVmN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652107795929%2FSf65bVVmN.png" alt="CleanShot 2022-05-09 at 20.37.34@2x.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Woohoo 🎉 Your first distribution is created. Wait for a while to be available. After getting done, you will see this 👇 &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652108794268%2F3BeQBMUzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1652108794268%2F3BeQBMUzu.png" alt="Amazon Lightsail CDN Cloudfront Distribution "&gt;&lt;/a&gt;&lt;br&gt;
(A) Your domain for the distribution. You can access the site using this URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Domain
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Update the Domain in DB
&lt;/h3&gt;

&lt;p&gt;Login to your WordPress application's database, you may follow &lt;a href="https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail#heading-import-database" rel="noopener noreferrer"&gt;this&lt;/a&gt;. Update the &lt;code&gt;siteurl&lt;/code&gt; and &lt;code&gt;home&lt;/code&gt; to your &lt;code&gt;wp_options&lt;/code&gt; table to your distribution domain. &lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You can use a custom domain instead of CloudFront's sub-domain. You may follow &lt;a href="https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-enabling-distribution-custom-domains" rel="noopener noreferrer"&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can add Object Storage to your WordPress app with a CDN distribution by following &lt;a href="https://aws.amazon.com/getting-started/hands-on/object-storage-cdn/" rel="noopener noreferrer"&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope you enjoyed this simple article and created your first CDN distribution. Ask your questions in the comment. Subscribe to get the next blog post. Thanks 🙏 &lt;/p&gt;

</description>
      <category>aws</category>
      <category>wordpress</category>
      <category>cloud</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Deploy WordPress App to Amazon Lightsail</title>
      <dc:creator>Harun R Rayhan</dc:creator>
      <pubDate>Sun, 08 May 2022 11:02:48 +0000</pubDate>
      <link>https://dev.to/aws-builders/deploy-wordpress-app-to-amazon-lightsail-48i</link>
      <guid>https://dev.to/aws-builders/deploy-wordpress-app-to-amazon-lightsail-48i</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;AWS Lightsail can be the easiest entry to the AWS Cloud. It has fixed monthly pricing unlike most other services, so you don't have to worry about a huge monthly bill. &lt;/p&gt;

&lt;p&gt;Lightsail is really great for small to medium apps. It has out-of-the-box support for &lt;strong&gt;WordPress&lt;/strong&gt;, Magento, Joomla, Prestashop, Drupal, Ghost, and Django apps. &lt;/p&gt;

&lt;p&gt;It provides pre-configured stacks like LAMP, NGINX, MEAN, and Node.js. You can also launch pre-configured Plesk, WHM &amp;amp; cPanel in just a few clicks. &lt;/p&gt;

&lt;p&gt;But that's not all. You can launch any Linux-based and Windows OS instance. My personal favorites are &lt;strong&gt;Ubuntu&lt;/strong&gt; and &lt;strong&gt;Amazon Linux 2&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Need a valid AWS account to deploy the WP app. If you don't have one, just create one from &lt;a href="https://portal.aws.amazon.com/billing/signup"&gt;here&lt;/a&gt;. Before starting to deploy your app read about &lt;a href="https://aws.amazon.com/lightsail/pricing/"&gt;Amazon Lightsail Pricing and Free-Tier&lt;/a&gt;. Don't worry, I will try to keep everything within the free tier. At this time of writing, you can run a Lightsail instance for free for 3 months.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install WordPress App
&lt;/h2&gt;

&lt;p&gt;Login to your AWS account if not already. Go to &lt;a href="https://lightsail.aws.amazon.com"&gt;Lightsail homepage&lt;/a&gt;. You should see a page like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hqo0rXi3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651060787414/7TgXRwaI1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hqo0rXi3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651060787414/7TgXRwaI1.png" alt="CleanShot 2022-04-27 at 17.59.20@2x.png" width="880" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you seeing this? Let's go 🏃‍♂️&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Instance
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Now click on the big &lt;strong&gt;Create Instance&lt;/strong&gt; button. If you don't see one, follow this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---jpR4jh6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651061181136/t7Kzr_AGl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---jpR4jh6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651061181136/t7Kzr_AGl.png" alt="CleanShot 2022-04-27 at 18.04.31@2x.png" width="880" height="476"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's choose &lt;strong&gt;Instance location&lt;/strong&gt;, &lt;strong&gt;platform&lt;/strong&gt;, and &lt;strong&gt;blueprint&lt;/strong&gt;:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7IgmK_6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651064483874/SsoaPiAKt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7IgmK_6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651064483874/SsoaPiAKt.png" alt="CleanShot 2022-04-27 at 18.20.07@2x.png" width="880" height="853"&gt;&lt;/a&gt;&lt;br&gt;
A. Click the link to change location and availability zone (AZ) if not what you want. I recommend selecting a location closer to your customers.&lt;br&gt;
B. Choose the &lt;strong&gt;Linux/Unix&lt;/strong&gt; platform.&lt;br&gt;
C. Select the &lt;strong&gt;Apps + OS&lt;/strong&gt; from the blueprint.&lt;br&gt;
D. Now choose &lt;strong&gt;WordPress&lt;/strong&gt; from the app list. &lt;em&gt;Not the multisite one&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now scroll down to &lt;strong&gt;Choose your instance plan&lt;/strong&gt; section. I chose a free-tier plan and only one instance. Here is my setup:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--23ThIqt2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651065101157/8eZaPa-e5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--23ThIqt2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651065101157/8eZaPa-e5.png" alt="CleanShot 2022-04-27 at 19.04.37@2x.png" width="880" height="820"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally scroll to the bottom of the page and click the &lt;strong&gt;Create instance&lt;/strong&gt; button. Wait for the status to become &lt;strong&gt;&lt;em&gt;Running&lt;/em&gt;&lt;/strong&gt;. Congratulations, your instance has launched 🚀&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Assign a Static IP (optional)
&lt;/h3&gt;

&lt;p&gt;AWS Lightsail Instance comes with public (and private) IP. Which changes every time Stop and Start the instance.  My Public IP was this when I launched the instance: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hKXcf_mV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651065976006/xngXQF1qF.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hKXcf_mV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651065976006/xngXQF1qF.png" alt="CleanShot 2022-04-27 at 19.24.43@2x.png" width="880" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After Stop and Start the instance, it got a new Public IP address: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DL4hrcbS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651066336570/qlxGqkjSB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DL4hrcbS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651066336570/qlxGqkjSB.png" alt="CleanShot 2022-04-27 at 19.31.30@2x.png" width="880" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have to fix that. So, let's create and assign a &lt;strong&gt;Static IP&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on your application instance name to see the details of your instance. &lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;+ Create static IP&lt;/strong&gt; from here:
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--88e-0XT9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651066765698/qL0v8VIuH.png" alt="CleanShot 2022-04-27 at 19.35.25@2x.png" width="880" height="588"&gt;
&lt;/li&gt;
&lt;li&gt;Add a meaningful name and click Create:
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W-2lSNpg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651067026152/wMDiRyzMD.png" alt="CleanShot 2022-04-27 at 19.42.36@2x.png" width="880" height="844"&gt;
&amp;gt; ⚠️ Warning: You are allowed to assign 5 static IPs for free. You will be charged for static IP that is not attached to a running instance. &lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Connect to the instance using SSH
&lt;/h3&gt;

&lt;p&gt;You can connect to an instance in two ways: &lt;/p&gt;
&lt;h4&gt;
  
  
  Using browser
&lt;/h4&gt;

&lt;p&gt;That's the easiest. Go to the &lt;strong&gt;Connect&lt;/strong&gt; tab and click &lt;strong&gt;Connect using SSH&lt;/strong&gt;:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sL-594Ow--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651068506979/ofhpf4_1M.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sL-594Ow--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651068506979/ofhpf4_1M.png" alt="CleanShot 2022-04-27 at 20.07.41@2x.png" width="880" height="793"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Using SSH Client
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Download the SSH key from here: 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ISIs1EaD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651068654032/OKPX9IZfO.png" alt="CleanShot 2022-04-27 at 20.10.12@2x.png" width="880" height="778"&gt;
&lt;/li&gt;
&lt;li&gt;If you are using PuTTY you can &lt;a href="https://lightsail.aws.amazon.com/ls/docs/en_us/articles/lightsail-how-to-set-up-putty-to-connect-using-ssh"&gt;follow this tutorial&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;If you are using a terminal in macOS or Linux, run this command on where you downloaded the SSH key.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run for the first time to fix the permission&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;400 &amp;lt;path/to/your-lightsail-ssh-key&amp;gt;.pem

&lt;span class="c"&gt;# Connect to your Lightsail instance&lt;/span&gt;
&lt;span class="c"&gt;# Username and Public IP can be found in "Connect" tab&lt;/span&gt;
ssh &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;path/to/your-lightsail-key&amp;gt;.pem"&lt;/span&gt; &amp;lt;username&amp;gt;@&amp;lt;public_ip&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Get Admin Username and Password
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;You can get the username from the &lt;strong&gt;Connect&lt;/strong&gt; tab. The username is &lt;strong&gt;user&lt;/strong&gt; for this stack.&lt;/li&gt;
&lt;li&gt;To get the password, log in to SSH and run this command
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;bitnami_application_password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GU9YsZnf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651069453965/Ehgt_JWU7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GU9YsZnf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651069453965/Ehgt_JWU7.png" alt="CleanShot 2022-04-27 at 20.23.35@2x.png" width="880" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now open a browser tab and go to &lt;code&gt;http://&amp;lt;public_ip&amp;gt;/wp-admin&lt;/code&gt;. Enter username and password above. You should see the WP Admin dashboard like me.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Add a Domain
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to the &lt;strong&gt;Home&lt;/strong&gt; page. Click on the &lt;strong&gt;Networking&lt;/strong&gt; tab and then hit &lt;strong&gt;Create DNS zone&lt;/strong&gt; button
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AY7Al_xP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651100514891/POkz7myRi.png" alt="CleanShot 2022-04-28 at 04.57.42@2x.png" width="880" height="742"&gt;
&lt;/li&gt;
&lt;li&gt;Add your domain name. Scroll to the bottom and click the &lt;strong&gt;Create DNS zone&lt;/strong&gt; button
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5WipL2lG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651100878512/fz1N3wW4u.png" alt="CleanShot 2022-04-28 at 05.03.10@2x.png" width="880" height="1090"&gt;
&lt;/li&gt;
&lt;li&gt;Add these name server records in your domain control panel (ex. Namecheap, GoDaddy). You might have different records than mine
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--koOrPb6A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651101055794/Y_EVt8m18.png" alt="CleanShot 2022-04-28 at 05.09.00@2x.png" width="880" height="646"&gt;
&lt;/li&gt;
&lt;li&gt;Now to the good part. Click &lt;strong&gt;+ Add Record&lt;/strong&gt; button. Add your instance and click on tick icon to save. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kWDSWYSD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651101295885/pp15TFvIg.png" alt="CleanShot 2022-04-28 at 05.13.07@2x.png" width="880" height="717"&gt;
&amp;gt; ⚠️ It may take few minutes to days to propagate DNS records. &lt;/li&gt;
&lt;li&gt;Now update the domain name in &lt;code&gt;siteurl&lt;/code&gt; and &lt;code&gt;home&lt;/code&gt; rows of &lt;code&gt;wp_options&lt;/code&gt; table.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Import Existing App
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Import Database
&lt;/h3&gt;

&lt;p&gt;You may have an existing database. You can import your database to the Lightsail instance. You can use a Database client app like TablePlus, MySQL Workbench, or even just the terminal. &lt;/p&gt;

&lt;p&gt;Your database credentials exist in &lt;code&gt;wp-config.php&lt;/code&gt; file. Connect to your instance via SSH and run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;stack/wordpress/wp-config.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use DB credentials to connect to DB, and replace &lt;code&gt;localhost&lt;/code&gt; with the instance's public IP. Connect to your DB via SSH (recommended) or add the &lt;code&gt;3306&lt;/code&gt; port here: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M2gH2kAv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651070563015/vdJ8wmLh2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M2gH2kAv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1651070563015/vdJ8wmLh2.png" alt="CleanShot 2022-04-27 at 20.40.01@2x.png" width="880" height="728"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ℹ️ Don't forget to change the domain name in &lt;code&gt;siteurl&lt;/code&gt; and &lt;code&gt;home&lt;/code&gt; rows of &lt;code&gt;wp_options&lt;/code&gt; table.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Import existing files
&lt;/h3&gt;

&lt;p&gt;Application folder located in &lt;code&gt;stack/wordpress&lt;/code&gt;. You can upload files in two ways: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SFTP Client: You can use SFTP clients like FileZilla or Transmit to upload files. Use the same SSH credential to upload files. &lt;/li&gt;
&lt;li&gt;Git: Connect to your instance via SSH. Install git by using this command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now pull your files from git using the git clone/pull command. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This is just the first step toward deploying your WordPress app to Amazon Lightsail instance. There are lot more you can do. You are welcome to ask your questions, give me feedback, or any improvement request. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>lightsail</category>
      <category>wordpress</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
