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

(aws-resourcegroups) ResourceGroup doesn't properly inherit Tags, causes deploy failure #12986

Closed
EhrhardtDa opened this issue Feb 11, 2021 · 4 comments · Fixed by #16211
Closed
Labels
@aws-cdk/aws-resourcegroups Related to AWS Resource Groups bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@EhrhardtDa
Copy link

The Question

I get the folllowing error, when I try to deploy a stack including global tags and a ResourceGroup.

Environment

  • CDK CLI Version: 1.89.0
  • Module Version: 1.89.0
  • Node.js Version: v14.15.4
  • OS: Windows 10
  • Language: TypeScript

Other information

cdk.Tags.of(this).add('myTagA', tagValueA);
cdk.Tags.of(this).add('myTagB', tagValueB);

...

let resourceGroupName = `BaKo-TIS-${props.environmentName}`;
const ressourceGroup = new resourcegroups.CfnGroup(this, 'ResourceGroup',{
  name: resourceGroupName,
});
const application = new applicationinsights.CfnApplication(this, 'Application', {
  resourceGroupName,
});
[ 1/4 | 15:42:57 | CREATE_FAILED        | AWS::ResourceGroups::Group                | ResourceGroup Model validation failed (#/Tags: expected type: JSONArray, found: JSONObject)
        new TisAgentAppStack (D:\Git\tis-agent\lib\tis-agent-stack.ts:189:28)
        \_ Object.<anonymous> (D:\Git\tis-agent\bin\tis-agent.ts:21:1)
        \_ Module._compile (internal/modules/cjs/loader.js:1063:30)
        \_ Module.m._compile (D:\Git\tis-agent\node_modules\ts-node\src\index.ts:1056:23)
        \_ Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
        \_ Object.require.extensions.<computed> [as .ts] (D:\Git\tis-agent\node_modules\ts-node\src\index.ts:1059:12)
        \_ Module.load (internal/modules/cjs/loader.js:928:32)
        \_ Function.Module._load (internal/modules/cjs/loader.js:769:14)
        \_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
        \_ main (D:\Git\tis-agent\node_modules\ts-node\src\bin.ts:198:14)
        \_ Object.<anonymous> (D:\Git\tis-agent\node_modules\ts-node\src\bin.ts:288:3)
        \_ Module._compile (internal/modules/cjs/loader.js:1063:30)
        \_ Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
        \_ Module.load (internal/modules/cjs/loader.js:928:32)
        \_ Function.Module._load (internal/modules/cjs/loader.js:769:14)
        \_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
        \_ internal/main/run_main_module.js:17:47
]
@EhrhardtDa EhrhardtDa changed the title ResourceGroup Model validation failed (#/Tags: expected type: JSONArray, found: JSONObject) (aws-resourcegroups) ResourceGroup Model validation failed (#/Tags: expected type: JSONArray, found: JSONObject) Feb 12, 2021
@github-actions github-actions bot added the @aws-cdk/aws-resourcegroups Related to AWS Resource Groups label Feb 12, 2021
@MrArnoldPalmer MrArnoldPalmer removed their assignment Jun 21, 2021
@NGL321 NGL321 added the guidance Question that needs advice or information. label Jul 24, 2021
@peterwoodworth peterwoodworth added the needs-triage This issue or PR still needs to be triaged. label Jul 27, 2021
@peterwoodworth peterwoodworth changed the title (aws-resourcegroups) ResourceGroup Model validation failed (#/Tags: expected type: JSONArray, found: JSONObject) (aws-resourcegroups) ResourceGroup doesn't properly inherit Tags, causes deploy failure Aug 4, 2021
@peterwoodworth peterwoodworth added bug This issue is a bug. p2 and removed guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Aug 4, 2021
@peterwoodworth peterwoodworth added the effort/small Small work item – less than a day of effort label Aug 4, 2021
@peterwoodworth
Copy link
Contributor

I can confirm that this is a bug and still occurring in 1.116.0.

relevant synth output for ResourceGroup:

"Tags": {
  "myTagA": "myValueA",
  "myTagB": "myValueB"
}

I tested to see if the same configuration happens with other Cfn resources (such as Bucket), the issue seems to be isolated to CfnGroup but there could potentially be other cases of this happening.

@alexmcmanus
Copy link

The underlying problem is that it configures a TagManager with the wrong type. It's probably a simple fix, and I'd be happy to submit a PR - except that it's in generated code, and I can't see where I'd need to make the change. The following workaround is possible in the meantime:

    const resourceGroup = new CfnGroup(this, 'ResourceGroup', {
      // ...etc.
    })
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    ;(resourceGroup as any).tags = new TagManager(TagType.STANDARD, 'AWS::ResourceGroups::Group', undefined, {
      tagPropertyName: 'tags'
    })

@madeline-k
Copy link
Contributor

For some reason there is a patch to the cfn spec for ResoureGroups which is causing the tag type to be MAP instead of STANDARD: https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/cfnspec/spec-source/530_ResourceGroups_Tags_patch.json

If we remove this patch, then the tag type will be STANDARD.

The PR where it was added: #6995 (comment)

I will consult with the team to see if it can be removed.

@madeline-k madeline-k removed their assignment Aug 23, 2021
@mergify mergify bot closed this as completed in #16211 Aug 24, 2021
mergify bot pushed a commit that referenced this issue Aug 24, 2021
… deploy failure (#16211)

This PR removes a patch to the cloudformation spec that is no longer necessary. Without the patch, the correct tag type of STANDARD is generated for CfnResourceGroup.

PR where the patch was introduced: #6995

Closes #12986 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
… deploy failure (aws#16211)

This PR removes a patch to the cloudformation spec that is no longer necessary. Without the patch, the correct tag type of STANDARD is generated for CfnResourceGroup.

PR where the patch was introduced: aws#6995

Closes aws#12986 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Sep 6, 2021
… deploy failure (aws#16211)

This PR removes a patch to the cloudformation spec that is no longer necessary. Without the patch, the correct tag type of STANDARD is generated for CfnResourceGroup.

PR where the patch was introduced: aws#6995

Closes aws#12986 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
david-doyle-as24 pushed a commit to david-doyle-as24/aws-cdk that referenced this issue Sep 7, 2021
… deploy failure (aws#16211)

This PR removes a patch to the cloudformation spec that is no longer necessary. Without the patch, the correct tag type of STANDARD is generated for CfnResourceGroup.

PR where the patch was introduced: aws#6995

Closes aws#12986 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-resourcegroups Related to AWS Resource Groups bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
6 participants