Skip to content

migrate: stacks do not generate from from CloudWatch alarms due to tags property #241

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

Open
1 task
robertkatz4 opened this issue Mar 16, 2025 · 1 comment
Open
1 task
Labels

Comments

@robertkatz4
Copy link

Describe the bug

stacks do not generate from from CloudWatch alarms due to tags property

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I wanted to generate a stack from a generated CloudFormation template, including a CloudWatch::Alarm, with the cdk migrate command

Current Behavior

Stack could not be generated because Tags is not a valid property for resource CloudWatchAlarm

Reproduction Steps

Hard to reproduce exactly... going from ClickOps to IaC is the business purpose.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.171.0 (build 4957967)

Framework Version

No response

Node.js Version

v22.9.0

OS

MacOS 12.6.8 (really)

Language

TypeScript

Language Version

v22.9.0

Other information

cdk migrate --stack-name abc123-1 --from-path ./abc123-925472.yaml --language typescript
This command is an experimental feature.
 ❌  Migrate failed for `abc123-1`: Stack could not be generated because Tags is not a valid property for resource CloudWatchAlarm.... of type AWS::CloudWatch::Alarm

aws/aws-cdk#29759
perhaps "command is experimental" should be taken seriously.

@pahud
Copy link

pahud commented Mar 17, 2025

Root Cause:

  • The error seemsed to be generated by the cdk-from-cfn package

/**
* Generates a CDK stack file.
* @param template The template to translate into a CDK stack
* @param stackName The name to assign to the stack
* @param language The language to generate the stack in
* @returns A string representation of a CDK stack file
*/
export function generateStack(template: string, stackName: string, language: string) {
const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}Stack`;
try {
return cdk_from_cfn.transmute(template, language, formattedStackName);
} catch (e) {
throw new ToolkitError(`${formattedStackName} could not be generated because ${(e as Error).message}`);
}
}

  • The validation is failing because the package's schema for AWS::CloudWatch::Alarm doesn't recognize the Tags property
  • This is despite CloudFormation now supporting tags for CloudWatch Alarms

Fix Location: The fix needs to be made in the cdk-from-cfn package to update its CloudFormation resource schemas to recognize Tags as a valid property for AWS::CloudWatch::Alarm resources.

I am reaching out the core team to take a look. Meanwhile, can you update your AWS CLI to the latest version and let me know if this issue still exists?

@pahud pahud added p2 and removed needs-triage labels Mar 17, 2025
@pahud pahud changed the title aws-cdk-lib/aws-cloudformation: stacks do not generate from from CloudWatch alarms due to tags property migrate: stacks do not generate from from CloudWatch alarms due to tags property Mar 17, 2025
@pahud pahud transferred this issue from aws/aws-cdk Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants