Using AWS CLI - Automating my post on - AWS SSM to Setup a LAMP Web Server & Hosting a Blog on it - Quick check ;)
Tags: aws, wordpress, linux, devops
Published: 2020-02-19 02:11:59

## How To Execute [Post](https://dev.to/dineshrathee12/aws-systems-manager-automation-to-install-a-lamp-web-server-hosting-a-wordpress-blog-on-amazon-linux-or-amazon-linux-2-5d0d) using AWS CLI

We've followed AWS Console Steps for Installing a LAMP Web Server & then Hosting a WordPress Blog on Amazon Linux or Amazon Linux 2.

***To check console steps , please click below link  :***
**[+]** [https://dev.to/dineshrathee12/aws-systems-manager-automation-to-install-a-lamp-web-server-hosting-a-wordpress-blog-on-amazon-linux-or-amazon-linux-2-5d0d](https://dev.to/dineshrathee12/aws-systems-manager-automation-to-install-a-lamp-web-server-hosting-a-wordpress-blog-on-amazon-linux-or-amazon-linux-2-5d0d)


Now, I will be explaining you on AWS CLI commands to achieve it in just simple steps:
<< *Make sure you have AWS CLI setup and you've enough permissions to use SSM to execute these documents.* >>
**If you have admin privileges , it will be great !**


***

## Steps Using AWS CLI:

***

<div><span style="font-weight: 700; color: rgb(68, 68, 68); font-family: &quot;Amazon Ember&quot;, Helvetica, Arial, sans-serif; font-size: 16px;"><u><br></u></span></div>
<div><span style="color: rgb(68, 68, 68); font-weight: 700; font-size: 16px;"><font face="Amazon Ember, Helvetica, Arial, sans-serif">1). <b>Running 1st</b>&nbsp;</font></span><span style="color: rgb(68, 68, 68); font-family: &quot;Amazon Ember&quot;, sans-serif; font-weight: 700;"><b>Doc (“AWSDocs-InstallALAMPServer-AL2”)</b>&nbsp;</span>
    <span style="color: rgb(68, 68, 68); font-family: &quot;Amazon Ember&quot;, sans-serif;">:</span>
</div>
<div><span style="color: rgb(68, 68, 68); font-family: &quot;Amazon Ember&quot;, sans-serif;"><br></span></div>
<div><pre style=""><font color="#444444" face="Amazon Ember, sans-serif"># aws ssm <b>start-automation-execution</b> --document-name <b>"AWSDocs-InstallALAMPServer-AL2" </b>--document-version "\$DEFAULT" <b>--region eu-west-1</b><br></font><font color="#444444" face="Amazon Ember, sans-serif">{<br></font><font color="#444444" face="Amazon Ember, sans-serif">&nbsp; &nbsp; "AutomationExecutionId": <b>"bd5xxxxxxxxxxxxxxxxxxxxxxx"</b><br></font><font color="#444444" face="Amazon Ember, sans-serif">}</font></pre><br></div>
<div><span style="color: rgb(68, 68, 68); font-weight: 700;">-&nbsp;</span><span style="color: rgb(68, 68, 68); font-weight: 700;"><b>Checking the Automation progress</b>&nbsp;</span><span style="color: rgb(68, 68, 68); font-weight: 700;"><b>/ Status:</b></span></div>
<div><span style="color: rgb(68, 68, 68); font-weight: 700;"><br></span></div>
<div><pre style=""><font color="#444444"># aws ssm <b>get-automation-execution</b> --automation-execution-id <b>"bd5xxxxxxxxxxxxxxxxxxx"</b> <b>--region eu-west-1</b> --output text --query "AutomationExecution.AutomationExecutionStatus"<br></font><font color="#444444"><b>InProgress</b></font></pre>
    <span style="font-weight: 700; color: rgb(68, 68, 68); font-family: &quot;Amazon Ember&quot;, Helvetica, Arial, sans-serif; font-size: 16px;"><u><br></u></span>
</div>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal">
    <o:p></o:p>
</p>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"><span style="font-weight: 700; color: rgb(68, 68, 68);"><b>- Lets wait for few mins to get this completed and Can check the Status again:</b></span></p><pre style="margin-bottom:7.5pt;line-height:normal"><font color="#444444"># aws ssm <b>get-automation-execution</b> --automation-execution-id <b>"bd56b3xxxxxxxxxxxxxxxxxxx"</b> <b>--region eu-west-1 -</b>-output text --query "AutomationExecution.AutomationExecutionStatus"<br></font><font color="#444444"><b>Success</b></font></pre>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"><span style="font-weight: 700; color: rgb(68, 68, 68);"><br></span></p>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"><span style="font-weight: 700; color: rgb(68, 68, 68);"><b>- You can also check the CloudFormation Stack details/Status :</b></span></p><pre style="margin-bottom:7.5pt;line-height:normal"><font color="#444444"><b># </b>aws cloudformation <b>describe-stacks </b>--stack-name <b>"LAMPStack-AL2" </b>--region eu-west-1</font></pre>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"><span style="font-weight: 700; color: rgb(68, 68, 68);"><br></span></p>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"><span style="font-weight: 700; color: rgb(68, 68, 68);">-&nbsp;</span><span style="color: rgb(68, 68, 68); font-weight: 700;"><b>To define CloudFormation stack resources :</b></span></p>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"></p><pre><font color="#444444"># aws cloudformation <b>describe-stack-resources&nbsp;</b> --stack-name <b>"LAMPStack-AL2"</b> --region eu-west-1</font></pre>
<font color="#444444" face="Amazon Ember"><b><br></b></font>
<p></p>
<p><span style="color: rgb(68, 68, 68);">We've confirmed the&nbsp;</span><span style="font-weight: 700; color: rgb(68, 68, 68);">Execution Status&nbsp;- "</span><span style="color: rgb(68, 68, 68);"><span style="font-weight: 700;"><b>Success</b>"&nbsp;</span>for
    first doc as well as CloudFormation stack status &amp; resources, Now, we can proceed further for our next step..</span>
</p>
<p><br></p>
<p>
    <font color="#444444" face="Amazon Ember, Helvetica, Arial, sans-serif"><span style="font-size: 16px;"><span style="font-weight: 700;">2).</span>&nbsp;<b>Running</b></span>
    </font><span style="font-weight: 700; color: rgb(68, 68, 68); font-family: &quot;Amazon Ember&quot;, sans-serif;">&nbsp;<b>2nd Doc ( “AWSDocs-HostingAWordPressBlog-AL2”) :</b></span></p><pre style="margin-bottom:7.5pt;line-height:normal"><font color="#444444" face="Amazon Ember"># aws ssm <b>start-automation-execution </b>--document-name <b>"AWSDocs-HostingAWordPressBlog-AL2"</b> --document-version "\$DEFAULT" <b>--region eu-west-1<br></b></font><font color="#444444" face="Amazon Ember">{<br></font><font color="#444444" face="Amazon Ember">&nbsp; &nbsp; "AutomationExecutionId": <b>"d61b49b7-xxxxxxxxxxxxxxxxx"<br></b></font><font color="#444444" face="Amazon Ember">}</font></pre>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"></p>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal">
    <font color="#444444" face="Amazon Ember"><br></font><span style="color: rgb(68, 68, 68); font-weight: 700;">- Lets wait for few mins to get this completed and Can check the Status :</span></p><pre style="margin-bottom:7.5pt;line-height:normal"># aws ssm <b>get-automation-execution</b> --automation-execution-id <b>"d61xxxxxxxxxxxxxxxxxxxxxx" </b>--region <b>eu-west-1</b> --output text --query "AutomationExecution.AutomationExecutionStatus"<br><b>Success</b></pre>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"><br><span style="font-size:
12.0pt;font-family:&quot;Times New Roman&quot;,serif;mso-fareast-font-family:&quot;Times New Roman&quot;;
mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:7.5pt;line-height:normal"><span style="font-family: &quot;Amazon Ember&quot;; color: rgb(68, 68, 68); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;"><o:p></o:p></span></p>
<p>
    <font color="#444444"><b>You can read more on AWS CLI references here :</b></font>
</p>
<p><b><font color="#444444">[+] SSM AWS CLI References :&nbsp;</font><a href="https://docs.aws.amazon.com/cli/latest/reference/ssm/index.html#cli-aws-ssm">https://docs.aws.amazon.com/cli/latest/reference/ssm/index.html#cli-aws-ssm</a><a href="https://docs.aws.amazon.com/cli/latest/reference/ssm/index.html#cli-aws-ssm"></a></b></p>
<p><b><font color="#444444" style="">[+] CloudFormation AWS CLI References :&nbsp;</font></b><a href="https://docs.aws.amazon.com/cli/latest/reference/cloudformation/index.html#cli-aws-cloudformation"><b>https://docs.aws.amazon.com/cli/latest/reference/cloudformation/index.html#cli-aws-cloudformation</b></a><b><a href="https://docs.aws.amazon.com/cli/latest/reference/cloudformation/index.html#cli-aws-cloudformation" style=""></a></b></p>
<p><br></p>