To simplify the management of AWS resources such as EC2 instances, you can assign metadata using tags. Resource groups can then use these tags to automate tasks on large numbers of resources at one time. They serve as a unique identifier for custom automation, to break out cost reporting by department and much more. In this hands-on lab, we will explore tag restrictions and best practices for tagging strategies. We will also get experience with the Tag Editor, AWS resource group basics, and leveraging automation through the use of tags.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Set Up AWS Config
- Navigate to Config.
- Click 1-click setup.
- Leave the settings as their defaults.
- Click Confirm.
- Tag an AMI and EC2 Instance
- Navigate to EC2 > Instances.
- Select any of the instances listed and select Image and templates > Create image.
- For the Image name, enter "Base".
- Click Create image.
- Click AMIs in the left-hand menu.
- Once the AMI you just created has a status of available, select it.
- Click Launch.
- Leave t2.micro selected, and click Next: Configure Instance Details.
- Leave the defaults on the Configure Instance Details page.
- Click Next: Add Storage, and then click Next: Add Tags.
- On the Add Tags page, add the following tag:
- Key: Name
- Value: Test Web Server
- Click Next: Configure Security Group.
- Click to Select an existing security group.
- Select the one with SecurityGroupWeb in the name (not the default security group).
- Launch the instance without a key pair.
- Tag Applications with the Tag Editor
Module 1 Tagging
- Search in the AWS console for Resource Groups and select Resource Groups & Tag Editor.
- Click Tag Editor.
- In the Find resources to tag section, set the following values:
- Regions: us-east-1
- Resource types:
- AWS::EC2::Instance
- AWS::S3::Bucket
- Click Search resources.
- In the Resource search results section, set the following values:
- Enter "Mod. 1" in the Filter resources search window, and then select both instances.
- Clear the filter.
- Enter "moduleone" in the Filter resources search window, and then select the listed S3 bucket.
- Clear the filter.
- Click Manage tags of selected resources.
- In the Edit tags of all selected resources section, click Add tag and set the following values:
- Tag key: Module
- Tag value: Starship Monitor
- Click Review and apply tag changes > Apply changes to all selected.
Module 2 Tagging
- Still on the Tag Editor page, in the Find resources to tag section, set the following values:
- Regions: us-east-1
- Resource types:
- AWS::EC2::Instance
- AWS::S3::Bucket
- Click Search resources.
- In the Resource search results section:
- Enter "Mod. 2" in the Filter resources search window, and select both instances.
- Clear the filter.
- Enter "moduletwo" in the Filter resources search window, and select the S3 bucket.
- Clear the filter.
- Click Manage tags of selected resources.
- In the Edit tags of all selected resources section, click Add tag and set the following values:
- Tag key: Module
- Tag value: Warp Drive
- Click Review and apply tag changes > Apply changes to all selected.
- Create Resource Groups and Use AWS Config Rules for Compliance
Create
Starship Monitor
Resource Group- In the left-hand menu, select Create Resource Group.
- Select Tag based.
- In the Grouping criteria section, add the following:
- Tag key: Module
- Optional tag value: Starship Monitor
- Click Add.
- Click View group resources.
- Enter a Group name of "Starship-Monitor".
- Click Create group.
Create
Warp Drive
Resource Group- Click Create Resource Group in the left-hand menu.
- Select Tag based.
- In the Grouping criteria section, add the following:
- Tag key: Module
- Optional tag value: Warp Drive
- Click Add.
- Click Preview group resources.
- Enter a Group name of "Warp-Drive".
- Click Create group.
View Saved Resource Groups
- Click Saved Resource Groups in the left-hand menu.
- Click Starship-Monitor. Here, we should see all the resources in our Starship-Monitor group.
Use AWS Config Rules for Compliance
- Navigate to EC2 > AMIs.
- Select the AMI we created earlier.
- Copy its AMI ID.
- Navigate to Config > Rules.
- Click Add rule.
- Search for approved-amis-by-id in the search box, and select that rule.
- In the Trigger section, set the following values:
- Scope of changes: Tags
- Resources by tag:
- Tag key: Module
- Tag value: Starship Monitor
- In the Rule parameters section, paste the AMI ID we copied earlier into the Value field.
- Click Save.
- Let the rule run for a few minutes, and then click the refresh icon to make sure it’s done.
- Navigate to the EC2 instance console, select all instances, and reboot them.
- Give the rule more time to run, and then revisit the AWS Config console.
- Click the approved-amis-by-id link.
- Click the link for one of the noncompliant resources to see more information.