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-ecs: Cluster.fromClusterAttributes does not properly set autoScalingGroup #29241

Closed
cheruvian opened this issue Feb 23, 2024 · 3 comments · Fixed by #29244
Closed

aws-ecs: Cluster.fromClusterAttributes does not properly set autoScalingGroup #29241

cheruvian opened this issue Feb 23, 2024 · 3 comments · Fixed by #29244
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@cheruvian
Copy link
Contributor

cheruvian commented Feb 23, 2024

Describe the bug

Cluster.fromClusterAttributes does not properly set autoScalingGroup

Expected Behavior

autoScalingGroup to be set

Current Behavior

Is undefined which leads to NPEs.

Reproduction Steps

    const vpc   = new Vpc(this, 'Vpc', {});
    const cluster = Cluster.fromClusterAttributes(this, 'Cluster', {
      clusterName: 'my-cluster',
      vpc,
      securityGroups: [],
      autoscalingGroup: new AutoScalingGroup(this, 'Asg', {
        vpc,
        instanceType: InstanceType.of(InstanceClass.A1, InstanceSize.MICRO),
        machineImage: MachineImage.latestAmazonLinux2(),
      }),
    });
    cluster.autoscalingGroup!.addUserData('yum install -y aws-cli');

Possible Solution

All ClusterAttributes should get set on the ImportCluster.

Additional Information/Context

No response

CDK CLI Version

2.126.0

Framework Version

No response

Node.js Version

v20.10.0

OS

OSX

Language

TypeScript

Language Version

No response

Other information

No response

@cheruvian cheruvian added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 23, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Feb 23, 2024
@cheruvian
Copy link
Contributor Author

Workaround for anyone interested:

    (this.cluster as any).autoscalingGroup = this.autoScalingGroup;

@tim-finnigan
Copy link

Thanks for reporting this issue and noting the workaround! Looks like the PR linked above (#29244) was created to address this issue.

@tim-finnigan tim-finnigan added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 26, 2024
@tim-finnigan tim-finnigan removed their assignment Feb 26, 2024
@mergify mergify bot closed this as completed in #29244 Feb 28, 2024
mergify bot pushed a commit that referenced this issue Feb 28, 2024
…ster` (#29244)

This PR adds an `autoscalingGroup` attribute to `ImportedCluster`. This attribute is set using the `autoscalingGroup` property from `ClusterAttributes` in the constructor of `ImportedCluster`.

Closes #29241.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants