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 and confirm your configuration.
- Tag an AMI and EC2 Instance
- On the EC2 instances page, select any of the instances and create an AMI image from it.
- For the Image name, enter Base.
- Navigate to the AMI page, and once the Base image has a status of available (this may take a few minutes), launch it.
- Select t3.micro and keep the default settings until you reach the Add Tags page.
- On the Add Tags page, add the following tag:
- Key: Name
- Value: Test Web Server
- Advance to the Configure Security Group page and select the pre-existing group named SecurityGroupWeb (listed as the first option).
- Launch the instance without a key pair.
- Tag Applications with the Tag Editor
Module 1 Tagging
- Navigate to Tag Editor under Resource Groups & Tag Editor.
- Find the following types of resources:
- Regions: us-east-1
- Resource types:
- AWS::EC2::Instance
- AWS::S3::Bucket
- Find and select both resources of Mod. 1
- Find and select the resources of moduleone
- Add tags to the resources:
- Tag key: Module
- Tag value: Starship Monitor
- Apply the changes to the selected resources.
Module 2 Tagging
- Navigate to Tag Editor under Resource Groups & Tag Editor.
- Find the following types of resources:
- Regions: us-east-1
- Resource types:
- AWS::EC2::Instance
- AWS::S3::Bucket
- Find and select both resources of Mod. 2
- Find and select the resources of moduletwo
- Add tags to the resources:
- Tag key: Module
- Tag value: Warp Drive
- Apply the changes to the selected resources.
- Create Resource Groups and Use AWS Config Rules for Compliance
Create the
Starship-Monitor
Resource GroupNote: The resource groups in this lab task have been given hyphenated names (e.g., Starship-Monitor), while the the tag values have been written in an unhyphenated format. To successfully complete the challenge lab, the tag values must appear in the same format as provided below (e.g., Starship Monitor). Because resource group names cannot contain spaces, group names have intentionally been hyphenated.
- Add these tag-based resources to a new resource group.
- In the Grouping criteria section, select the following:
- Tag key: Module
- Tag value: Starship Monitor
- Preview the group resources and enter the Group name of Starship-Monitor.
Create the
Warp-Drive
Resource Group- Add these tag-based resources to a new resource group.
- In the Grouping criteria section, select the following:
- Tag key: Module
- Tag value: Warp Drive
- Preview the group resources and enter the Group name of Warp-Drive.
View the Saved Resource Groups
In Saved Resource Groups, check the Starship-Monitor and Warp-Drive resource groups. We should see all the resources applied correctly to each group.
Use AWS Config Rules for Compliance
- Copy the AMI ID of the AMI we created and add a rule to it in the AWS Config console.
- 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 Parameters section, paste the AMI ID we copied earlier into the Value field and save the rule.
- Let the rule run for a few minutes until complete.
- Reboot all your EC2 instances.
- 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 non-compliant resources to see more information.