Requires specific tags on all EC2 instances and RDS databases, ensuring proper resource categorization and cost allocation.
What this SCP does
This Service Control Policy (SCP) requires specific tags on all EC2 instances and RDS databases, ensuring proper resource categorization and cost allocation. For EC2 instances, it enforces the presence of the 'Environment' tag on the resource itself using resource-level tag conditions. For RDS databases, it enforces tagging at creation time using request-level tag conditions. This dual approach ensures effective tag enforcement while accommodating the different tagging capabilities of each service.
When users try to create EC2 instances without specifying the required 'Environment' tag in the resource tags, or RDS instances without the tag in the request, the operation will be denied. This enforces tagging discipline across all accounts in the organization while respecting service-specific tagging mechanisms.
How to test this SCP works
To validate this SCP, try to create instances with and without the required 'Environment' tag. Note that EC2 and RDS use different tagging mechanisms in the API calls.
We expect resource creation without the required tag to be denied with an AccessDenied error, while creation with the proper tag should succeed. For EC2, tags must be specified using the tag-specifications parameter, while for RDS they are specified directly in the request tags.