PART-B AWS AMI Automation using (SSM) Systems Manager Automation service Automating the Creation and Management of Amazon Machine Images (AMIs)

PART-A LINK

Steps to be performed by this automation:

Step 1. Create an Amazon Machine Image (AMI) from the provided instance ID

Step 2. Update the existing launch template version using the AMI created in Step 1

Step 3. Start refreshing instances in the Auto Scaling group using the launch template

Prerequisite

Before you begin
Complete the following tasks before you begin this example.

Configure IAM roles for Automation, a capability of AWS Systems Manager. The Systems Manager requires an instance profile role and a service role ARN to process automation. For more information, see Setting up Automation.

Search for Systems Manager service > Click on Documents

Now click on Owned by me

Create a document then click on the automation

Enter the name Choose the Editor tab, and choose Edit.

Click on Editor then Edit

Choose OK when prompted, and delete the content in the Document editor field.

In the Document editor field, paste the following YAML below is the runbook content.

Choose to Create automation button.

  1. In the navigation pane, choose Automation, and then choose Execute automation.
  2. In the Choose document page, choose the Owned by me tab.
  3. Search for the PatchAMIAndUpdateASG runbook, and select the button in the PatchAMIAndUpdateASG card.
  4. Choose Next.
  5. Choose Simple execution.

Click on Execute

To see your running executions go to executions pannel

Below you can see the executions

Click on the Execution ID

All steps have run successfully.

Reference links

Resources:

[1] Create a new image -
https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-action-create.html

[2] StartInstanceRefresh โ€” https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_StartInstanceRefresh.html

[3] create_launch_template โ€” https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.create_launch_template

[4] Updating AMIs for Auto Scaling โ€” groupshttps://docs.aws.amazon.com/systems-manager/latest/userguide/automation-tutorial-update-patch-windows-ami-autoscaling.html

[5] Modify_launch_template โ€”https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/modify_launch_template.html

--

--

๐’๐š๐ค๐ž๐ญ ๐‰๐š๐ข๐ง

๐ƒ๐ž๐ฏ๐Ž๐ฉ๐ฌ/๐’๐‘๐„/๐‚๐ฅ๐จ๐ฎ๐ /๐ˆ๐ง๐Ÿ๐ซ๐š๐ฌ๐ญ๐ซ๐ฎ๐œ๐ญ๐ฎ๐ซ๐ž /๐’๐ฒ๐ฌ๐ญ๐ž๐ฆ ๐„๐ง๐ ๐ข๐ง๐ž๐ž๐ซ