Background:
In general we follow the documentation to get started. Now, we have SSM Service which can do this in an automated fashion which is quicker and does all your job without any direct user interaction on OS level.
Which SSM Automation Documents you can use ?
You can use below Automated Documents to achieve this task :
For Amazon Linux:
- First Execute - Automation Document Name: AWSDocs-InstallALAMPServer-AL ----> Basically Automates - this documentation and once the Execution result is "Success"
- Then Execute - Automation Document Name: AWSDocs-HostingAWordPressBlog-AL ----> Basically Automates - this documentation
For Amazon Linux 2:
- First Execute - Automation Document Name: AWSDocs-InstallALAMPServer-AL2 ----> Basically Automates - this documentation and once the Execution result is "Success"
- Then Execute - Automation Document Name: AWSDocs-HostingAWordPressBlog-AL2 ----> Missing a reference as of now for documentation.
Some Important Tips Before you Start:
➜ Please note that these documents may not be available in one of the regions you've targeted. I've checked their presence in - (us-east-1,us-east-2,us-west-1,us-west-2,ca-central-1,eu-central-1,eu-west-1,eu-west-2,eu-west-3,sa-east-1,ap-northeast-1). Please choose your region and proceed.
➜ To know more on these documents and what they usually do, you can click on the Hyperlinks above.
➜ To run the following Automation documents, you must have permissions to run Automation workflows and create the resources mentioned there. The Automation workflow runs in the context of the current AWS Identity and Access Management (IAM) user. If you have admin privileges , it will be great !
➜ You should follow the sequence for executing it successfully as mentioned above and I am also explaining an example below
➜ To track any Progress or Failure, You can navigate to SSM Automation Execution or CloudFormation Stack details.
➜ To delete resources created you can go to CloudFormation Stack and delete, It will automatically deletes resources.
➜ You can preserve your resources (to avoid any accidental deletion) using CloudFormation Stack by choosing - "Stack Actions" -> "Edit Termination Protection" --> Choose - "Enabled" & Save
Now, we will see how to use AWS Systems Manager Automation Documents .. I will be taking an Example for "Amazon Linux 2"
- Use Case :- " I want to Install LAMP over Amazon Linux 2 based Instance and want to host a WordPress Blog on it "
You can do it either using Console (steps below) or using AWS CLI (check my post)
Steps Using Console:
As I've mentioned - I will follow the sequence for executing – 1st Doc (“AWSDocs-InstallALAMPServer-AL2”) and then check if “Success” , then will Execute 2nd Doc ( “AWSDocs-HostingAWordPressBlog-AL2”)
*Note:*
Please make sure you're in the right AWS region where you want to deploy your blog.
1). Click on below quick-link to Execute 1st Doc (“AWSDocs-InstallALAMPServer-AL2”) :
[+] https://console.aws.amazon.com/systems-manager/automation/execute/AWSDocs-InstallALAMPServer-AL2
Once you click on "Execute" Button the Automation will start and you can see this as follows:
You can see the the CloudFormation Console to see what resources are being created by Stack:
You can Monitor the overall Success in the Execution Status under SSM Automation Executions:
Now, We have an EC2 Instance ready with required configurations:
We've confirmed the Execution Status - "Success" for first doc, Now, we can proceed further for our next step..
2). Click on below quick-link to Execute 2nd Doc ( “AWSDocs-HostingAWordPressBlog-AL2”) :
[+] https://console.aws.amazon.com/systems-manager/automation/execute/AWSDocs-HostingAWordPressBlog-AL2
Once you click on "Execute" Button the Automation will start performing actions on your Instance you can see this as follows:
You can Monitor the overall Success in the Execution Status under SSM Automation Executions
Now, We've confirmed the Execution Status - "Success" for second doc as well, Now, we can proceed further for our next step for final touch on WordPress..
3). Attached an EIP (Elastic IP) to the Instance to make sure the IP doesn't change in future. To know more on EIP allocation and Assignment , please refer here.
4). Once the Automation has completed, you will be able to navigate to the WordPress blog dashboard by entering public DNS /EIP address (or the public IP address) of the launched instance in your browser :
For example: (in my use-case)
[+] http://ec2-54-194-131-54.eu-west-1.compute.amazonaws.com/ or [+] http://54.xxxxxxx/
Also, it will automatically route you to "WordPress wp-admin" page which looks like below :
Click Continue and Just fill in the information below and you’ll be on your way to using wordpress to manage your blog :
Please make a note of username and password to manage your WordPress blog. Click on "Install WordPress" b utton.
Click Login and use the Id and Password provided above :
Here is the WordPress Dashboard to manage you Blog:
Checking my New WordPress blog created :
[+] http://ec2-54-xxxxxxxxx4.eu-west-1.compute.amazonaws.com/ or [+] http://54.xxxxxxxxx/
To delete the Resources created
➜ To delete resources created you can go to CloudFormation Stack and Select your Stack and choose Delete, It will automatically deletes resources.
<>
➜ You can go to CloudFormation Stack and Select your Stack and choose - "Stack Actions" -> "Edit Termination Protection" --> Choose - "Enabled" & Save
This will basically will avoid your resources being deleted accidentally by CloudFormation action. To know more on this, please check Public Documentation.
**Want to see something more Interesting ?? **
Check out below post ---
How to Perform Above Steps Using AWS CLI, Please check --- Post:
[+] https://dev.to/dineshrathee12/using-aws-cli-automating-post-aws-ssm-to-setup-a-lamp-web-server-hosting-a-blog-on-it-quick-427f
**
References:
[+] Tutorials for Amazon EC2 Instances Running Linux: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-tutorials.html
[+] Tutorial: Install a LAMP Web Server with the Amazon Linux AMI: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
[+] AWSDocs-InstallALAMPServer-AL : https://eu-west-1.console.aws.amazon.com/systems-manager/automation/execute/AWSDocs-InstallALAMPServer-AL?region=eu-west-1
[+] Tutorial: Hosting a WordPress Blog with Amazon Linux : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html
[+] AWSDocs-HostingAWordPressBlog-AL : https://console.aws.amazon.com/systems-manager/automation/execute/AWSDocs-HostingAWordPressBlog-AL
[+] Tutorial: Install a LAMP Web Server on Amazon Linux 2: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html
[+] AWSDocs-InstallALAMPServer-AL2 : https://eu-west-1.console.aws.amazon.com/systems-manager/home?redirect=%2Fsystems-manager%2Fautomation%2Fexecute%2FAWSDocs-InstallALAMPServer-AL2®ion=eu-west-1
[+] AWSDocs-HostingAWordPressBlog-AL2 : https://console.aws.amazon.com/systems-manager/home?redirect=%2Fsystems-manager%2Fautomation%2Fexecute%2FAWSDocs-HostingAWordPressBlog-AL2
[+] Troubleshooting AWS CloudFormation : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html
[+] Troubleshooting Systems Manager Automation: https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-troubleshooting.html
[+] WordPress : https://wordpress.com/start/?ref=create-lp
Top comments (0)