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-cdk-lib/core: cfn-parse cannot parse CfnInclude template #32454

Closed
1 task done
mikevoets opened this issue Dec 10, 2024 · 3 comments · Fixed by #32461
Closed
1 task done

aws-cdk-lib/core: cfn-parse cannot parse CfnInclude template #32454

mikevoets opened this issue Dec 10, 2024 · 3 comments · Fixed by #32461
Labels
@aws-cdk/cloudformation-include Issues related to the "CFN include v.20" package bug This issue is a bug. p0 potential-regression Marking this issue as a potential regression to be checked by team member

Comments

@mikevoets
Copy link

mikevoets commented Dec 10, 2024

Describe the bug

We have a cloudformation template for autoscaling that we import into our CDK stack with CfnInclude.

I believe that #32321 that was released in [email protected] last week broke the parsing of this template, because we now get an error when we synthesize this stack. In [email protected], the synthesization works without any errors thrown.

Regression Issue

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

Last Known Working CDK Version

2.171.0

Expected Behavior

The stack synthesization is successful and runs without errors.

Current Behavior

The stack synthesization fails with:

TypeError: Cannot read properties of undefined (reading 'getArray')
    at getStringArray (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:3237)
    at ObjectParser.parse (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:18595)
    at ObjectParser.parseCase (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:18475)
    at parseAutoScalingRollingUpdate (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:8738)
    at ObjectParser.parse (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:18595)
    at ObjectParser.parseCase (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:18475)
    at CfnParser.parseUpdatePolicy (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:7642)
    at CfnParser.handleAttributes (/Users/path/to/repo/node_modules/aws-cdk-lib/core/lib/helpers-internal/cfn-parse.js:1:4944)
    at Function._fromCloudFormation (/Users/path/to/repo/node_modules/aws-cdk-lib/aws-autoscaling/lib/autoscaling.generated.js:1:1188)
    at CfnInclude.getOrCreateResource (/Users/path/to/repo/node_modules/aws-cdk-lib/cloudformation-include/lib/cfn-include.js:1:14510)
Subprocess exited with error 1

Reproduction Steps

Given the following code:

template.yaml

---
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  AutoScalingGroup:
    Type: 'AWS::AutoScaling::AutoScalingGroup'
    Properties:
      DesiredCapacity: 1
      MaxSize: 1
      MinSize: 1
    CreationPolicy:
      ResourceSignal:
        Count: 1
        Timeout: PT10M
    UpdatePolicy:
      AutoScalingRollingUpdate:
        PauseTime: PT10M
        SuspendProcesses:
          - HealthCheck
          - ReplaceUnhealthy
          - AZRebalance
          - AlarmNotification
          - ScheduledActions
        WaitOnResourceSignals: true

app.ts

import * as cdk from 'aws-cdk-lib';
import { CfnInclude } from 'aws-cdk-lib/cloudformation-include';
import { Construct } from 'constructs';

class TestStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new CfnInclude(this, 'Template', {
      templateFile: './template.yaml',
    });
  }
}

const app = new cdk.App();

new TestStack(app, 'TestStack', {
  env: {
    region: process.env.AWS_REGION,
    account: process.env.AWS_ACCOUNT,
  },
});

Run:

npm run cdk -- -a "npx ts-node --prefer-ts-exts app.ts" synth TestStack

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.172.0 (build 0f666c5)

Framework Version

No response

Node.js Version

v22.10.0

OS

macOS 15.1.1 (24B91)

Language

TypeScript

Language Version

TypeScript (5.7.2)

Other information

No response

@mikevoets mikevoets added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 10, 2024
@github-actions github-actions bot added @aws-cdk/cloudformation-include Issues related to the "CFN include v.20" package potential-regression Marking this issue as a potential regression to be checked by team member labels Dec 10, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 10, 2024
@khushail khushail self-assigned this Dec 10, 2024
@khushail khushail added the p1 label Dec 10, 2024
@khushail
Copy link
Contributor

@mikevoets , thanks for reporting this and sharing the repro code. I am able to reproduce the issue and can see that with CDK Version 2.172.0 , this error is being shown-

Screenshot 2024-12-10 at 11 19 40 AM

while it works fine in earlier CDK Version 2.171.0.

Reaching out to Core team and marking as appropriate.

@khushail khushail added p0 and removed p1 labels Dec 10, 2024
@khushail khushail removed their assignment Dec 10, 2024
@khushail khushail removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Dec 10, 2024
@mergify mergify bot closed this as completed in #32461 Dec 11, 2024
@mergify mergify bot closed this as completed in 0c2f98b Dec 11, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/cloudformation-include Issues related to the "CFN include v.20" package bug This issue is a bug. p0 potential-regression Marking this issue as a potential regression to be checked by team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants