GR-03
TAG-01 tag keys on taggable resources (Component on environment-scoped ones, DQ-128), and hkb- names for named resources.
| Property | Value |
|---|---|
| Runs on | Every CloudFormation template, in CI on each change and in the pipeline's Validate stage |
| Source | guard/rules/gr-03-tags-and-names.guard |
| Exceptions | 1 in the exception register |
Rule text
# GR-03: TAG-01 tag keys on taggable resources (Component on environment-scoped ones, DQ-128), and hkb- names for named resources.
# Exempt roles mirror guard/exceptions.yaml (AWS-mandated Control Tower role names).
let exempt_roles = [
'AWSControlTowerAdmin', 'AWSControlTowerCloudTrailRole', 'AWSControlTowerStackSetRole',
'AWSControlTowerConfigAggregatorRoleForOrganizations'
]
let taggable = Resources.*[ Type in [
'AWS::IAM::Role', 'AWS::KMS::Key', 'AWS::SNS::Topic', 'AWS::S3::Bucket',
'AWS::Organizations::Policy', 'AWS::Organizations::ResourcePolicy',
'AWS::ServiceCatalog::CloudFormationProvisionedProduct'
] ]
# Organization-wide policies belong to no environment (TAG-01 has no value for them), so Environment is not required there.
let env_scoped = Resources.*[ Type in [
'AWS::IAM::Role', 'AWS::KMS::Key', 'AWS::SNS::Topic', 'AWS::S3::Bucket',
'AWS::ServiceCatalog::CloudFormationProvisionedProduct'
] ]
let named_roles = Resources.*[ Type == 'AWS::IAM::Role' Properties.RoleName exists ]
let named_topics = Resources.*[ Type == 'AWS::SNS::Topic' Properties.TopicName exists ]
let named_buckets = Resources.*[ Type == 'AWS::S3::Bucket' Properties.BucketName exists ]
rule GR_03_tags when %taggable !empty {
%taggable {
when Properties.RoleName not exists or Properties.RoleName !in %exempt_roles {
some Properties.Tags[*].Key == 'Project' <<GR-03: missing tag Project>>
some Properties.Tags[*].Key == 'ManagedBy' <<GR-03: missing tag ManagedBy>>
some Properties.Tags[*].Key == 'Owner' <<GR-03: missing tag Owner>>
}
}
}
rule GR_03_environment when %env_scoped !empty {
%env_scoped {
when Properties.RoleName not exists or Properties.RoleName !in %exempt_roles {
some Properties.Tags[*].Key == 'Environment' <<GR-03: missing tag Environment>>
}
}
}
# Component, so spend can be attributed (DQ-128). Not on Account Factory products: an account is not a component,
# and changing a provisioned product's tags runs a Control Tower account update.
let component_scoped = Resources.*[ Type in ['AWS::IAM::Role', 'AWS::KMS::Key', 'AWS::SNS::Topic', 'AWS::S3::Bucket'] ]
rule GR_03_component when %component_scoped !empty {
%component_scoped {
when Properties.RoleName not exists or Properties.RoleName !in %exempt_roles {
some Properties.Tags[*].Key == 'Component' <<GR-03: missing tag Component>>
}
}
}
rule GR_03_role_names when %named_roles !empty {
%named_roles {
when Properties.RoleName !in %exempt_roles {
Properties.RoleName == /^hkb-/ <<GR-03: role names start with the hkb- prefix>>
}
}
}
rule GR_03_topic_names when %named_topics !empty {
%named_topics { Properties.TopicName == /^hkb-/ <<GR-03: topic names start with the hkb- prefix>> }
}
rule GR_03_bucket_names when %named_buckets !empty {
%named_buckets {
Properties.BucketName == /^hkb-/ or
Properties.BucketName."Fn::Sub" == /^hkb-/
<<GR-03: bucket names start with the hkb- prefix, as a plain string or an Fn::Sub string>>
}
}
Page information
- Owner
- Security Engineering
- Status
- current Current: generated from the templates and records in the repository at this build.
- Generated from
guard/rules/gr-03-tags-and-names.guard- Linked from
- Controls, Template rules
- Plain markdown
- /wiki/guard/gr-03/index.md