DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Using AWS CLI - Automating my post on - AWS SSM to Setup a LAMP Web Server & Hosting a Blog on it - Quick check ;)
Dinesh Rathee
Dinesh Rathee

Posted on • Updated on

Using AWS CLI - Automating my post on - AWS SSM to Setup a LAMP Web Server & Hosting a Blog on it - Quick check ;)

How To Execute Post 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

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:



1). Running 1stΒ Doc (β€œAWSDocs-InstallALAMPServer-AL2”)Β  :
# aws ssm start-automation-execution --document-name "AWSDocs-InstallALAMPServer-AL2" --document-version "\$DEFAULT" --region eu-west-1
{
Β  Β  "AutomationExecutionId": "bd5xxxxxxxxxxxxxxxxxxxxxxx"
}

-Β Checking the Automation progressΒ / Status:
# aws ssm get-automation-execution --automation-execution-id "bd5xxxxxxxxxxxxxxxxxxx" --region eu-west-1 --output text --query "AutomationExecution.AutomationExecutionStatus"
InProgress

- Lets wait for few mins to get this completed and Can check the Status again:

# aws ssm get-automation-execution --automation-execution-id "bd56b3xxxxxxxxxxxxxxxxxxx" --region eu-west-1 --output text --query "AutomationExecution.AutomationExecutionStatus"
Success


- You can also check the CloudFormation Stack details/Status :

# aws cloudformation describe-stacks --stack-name "LAMPStack-AL2" --region eu-west-1


-Β To define CloudFormation stack resources :

# aws cloudformation describe-stack-resourcesΒ  --stack-name "LAMPStack-AL2" --region eu-west-1

We've confirmed theΒ Execution StatusΒ - "Success"Β for first doc as well as CloudFormation stack status & resources, Now, we can proceed further for our next step..

2).Β Running Β 2nd Doc ( β€œAWSDocs-HostingAWordPressBlog-AL2”) :

# aws ssm start-automation-execution --document-name "AWSDocs-HostingAWordPressBlog-AL2" --document-version "\$DEFAULT" --region eu-west-1
{
Β  Β  "AutomationExecutionId": "d61b49b7-xxxxxxxxxxxxxxxxx"
}


- Lets wait for few mins to get this completed and Can check the Status :

# aws ssm get-automation-execution --automation-execution-id "d61xxxxxxxxxxxxxxxxxxxxxx" --region eu-west-1 --output text --query "AutomationExecution.AutomationExecutionStatus"
Success


You can read more on AWS CLI references here :

[+] SSM AWS CLI References :Β https://docs.aws.amazon.com/cli/latest/reference/ssm/index.html#cli-aws-ssm

[+] CloudFormation AWS CLI References :Β https://docs.aws.amazon.com/cli/latest/reference/cloudformation/index.html#cli-aws-cloudformation

Top comments (0)

Join us at DEV
Yes, this is technically an β€œad”, but really we just want to ask if you want to join DEV. We have 900k+ developers reading, posting, and enjoying community, and would love to have you. Β  Create an account and continue your coding journey.