Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KMS Keys are not getting the stacks default tags #33

Open
pplu opened this issue Mar 17, 2021 · 5 comments
Open

KMS Keys are not getting the stacks default tags #33

pplu opened this issue Mar 17, 2021 · 5 comments

Comments

@pplu
Copy link

pplu commented Mar 17, 2021

Hi,

KMS keys don't get tagged with cloudformation default tags:

aws:cloudformation:logical-id
aws:cloudformation:stack-name
aws:cloudformation:stack-id

This was reported here: aws-cloudformation/cloudformation-coverage-roadmap#193, but was closed, when it seems that it is not so.

@ammokhov
Copy link
Contributor

ammokhov commented Apr 2, 2021

@pplu I dont think this resource support CloudFormation stack-level tags with the prefix aws::.

@pplu
Copy link
Author

pplu commented Apr 3, 2021

@ammokhov : I'm opening this as an issue because I was expecting the KMS cloudformation provider to tag the KMS keys it creates with the aws:clouformation tags, that help identify what stack created which KMS key.

@iainelder
Copy link

iainelder commented Jul 7, 2021

For example, the stack tags are propagated to S3 buckets and EC2 instances.

I just discovered today that the same is not true of KMS keys.

I don't see the resource provider code for those resources in the Github organization.

Do any of the published resource providers have an example of how to implement this?

@ammokhov
Copy link
Contributor

Do any of the published resource providers have an example of how to implement this?

you mean aws prefixed tags or stack level tags? stack level tags are usually attached to stack and are provisioned to each individual resource that belongs to the stack (if supports tags) unless your execution role is missing correct permissions.

@rgoltz
Copy link

rgoltz commented Jun 26, 2024

I'm adding here (again) the details for this issue of #33:

Issue Description

To find the right CloudFormation Stack, where a AWS resource is defined/maintained, aws:cloudformation:* built-in tags are needed. This is an important function in day-to-day business.

Expected Behavior

Resources with type AWS::KMS::Key, which are managed as CloudFormations Stacks, should automatically receive the aws:cloudformation:* built-in tags / automatic default CFN AutoTags.

Once support CloudFormation Drift-Detection will be added via aws-cloudformation/cloudformation-coverage-roadmap#1671, please handled by those automatic tags correctly (hence, aws:cloudformation:* tags are not a drift)

Observed Behavior

When you have an AWS::KMS::Key resource in your stack, it does not get the built-in tags assigned:

  • aws:cloudformation:stack-name
  • aws:cloudformation:logical-id
  • aws:cloudformation:stack-id

Test Cases

Example Templates: Deploy this Stack in one Region:

Resources:
  EncryptionKey:
    Type: 'AWS::KMS::Key'
    Properties:
      Description: TestKeyForTags
      EnableKeyRotation: true
      MultiRegion: true
      Enabled: true
      Tags:
        - Key: "Stack Name Not Default Tag"
          Value: !Ref AWS::StackName
      KeyPolicy:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              AWS: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:root'
            Action:
              - 'kms:*'
            Resource: '*'

You will see on both Resources that aside from CloudFormation defined Tags, no other Tags are placed onto the Resources.
No tags aws:cloudformation:* are added to the resource (just the tags defined via Template-Resource-Level or via Stack-Level).

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants