aws-cdk
aws-cdk copied to clipboard
aws-ecs: `Cluster.fromClusterAttributes` does not properly set `autoScalingGroup`
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 ClusterAttribute
s 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
Workaround for anyone interested:
(this.cluster as any).autoscalingGroup = this.autoScalingGroup;
Thanks for reporting this issue and noting the workaround! Looks like the PR linked above (https://github.com/aws/aws-cdk/pull/29244) was created to address this issue.
⚠️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.