-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(ecs): I get an error in BaseService.RegisterLoadBalancerTargets #17876
Comments
@aetos382 thanks for opening this issue, and providing repro steps. I was able to reproduce this issue, and I think it may be a regression. |
For what it's worth, here is an equivalent stack definition in Typescript: import * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as ecs from '@aws-cdk/aws-ecs';
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
export class Issue17876 extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'MyVpc');
const cluster = new ecs.Cluster(this, 'EcsCluster', { vpc });
const taskDefinition = new ecs.FargateTaskDefinition(this, 'FargateTaskDef', {
cpu: 256,
memoryLimitMiB: 512,
});
const container = taskDefinition.addContainer('container', {
image: ecs.ContainerImage.fromRegistry('nginx'),
portMappings: [{ containerPort: 80 }],
});
const service = new ecs.FargateService(this, 'FargateService', {
cluster,
taskDefinition,
});
const loadBalancer = new elbv2.ApplicationLoadBalancer(this, 'LoadBalancer', { vpc });
service.registerLoadBalancerTargets({
containerName: container.containerName,
containerPort: container.containerPort,
newTargetGroupId: 'targetGroup',
listener: ecs.ListenerConfig.applicationListener(new elbv2.ApplicationListener(this, 'AlbListener', {
loadBalancer,
protocol: elbv2.ApplicationProtocol.HTTP,
})),
});
}
} I can't reproduce the above error in Typescript using the above (with the appropriate CDK versions). That certainly points the finger to a quirk of Here's the code today: aws-cdk/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts Lines 358 to 361 in 59fe395
Here's the code prior to the change: aws-cdk/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts Lines 376 to 383 in 7dae114
|
The jsii kernel needs to attach metadata to instances that are sent across the process boundary. While these properties use symbol names to eliminate the risk for collisions with user-defined properties, they were inadvertently set as `enumerable`, causing those to show in outputs of `JSON.stringify` and to be copied over as part of spat expressions (e.g: `{...obj}`), which resulted in the new value sharing the same identity as the previous one when sent over the wire. Caused: aws/aws-cdk#17876
We identified the cause for this issue (see aws/jsii#3339 for more details). The jsii runtime bug has been there virtually forever, but CDK did not previously trigger that, so it went unnoticed. Once aws/jsii#3339 is released, ensuring the updated version of the jsii runtime library should be enough to get the problem fixed (no need to wait for a CDK release). |
The jsii kernel needs to attach metadata to instances that are sent across the process boundary. While these properties use symbol names to eliminate the risk for collisions with user-defined properties, they were inadvertently set as `enumerable`, causing those to show in outputs of `JSON.stringify` and to be copied over as part of spat expressions (e.g: `{...obj}`), which resulted in the new value sharing the same identity as the previous one when sent over the wire. Caused: aws/aws-cdk#17876 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
What is the problem?
I am using
FargateService.RegisterLoadBalancerTargets
in CDK for C#.This method was successfully synthesized in CDK v1.132, but fails in v1.133 and later (including v2.0).
Reproduction Steps
git clone https://github.com/aetos382/cdk-synth-error
cd cdk-synth-error
cd CdkV132
npm install
npx cdk synth
# It is synthesized successfully.cd ../CdkV133
# Also reproduced in CdkV134 and CdkV2npm install
npx cdk synth
# An error occurs.What did you expect to happen?
I can synthesize the stack successfully.
What actually happened?
I get an error with CDK v1.133 or later.
Missing required properties for @aws-cdk/aws-elasticloadbalancingv2.AddApplicationTargetGroupsProps: targetGroups
CDK CLI Version
1.133.0 (build 2dea31a)
Framework Version
.NET 6
Node.js Version
v16.13.0
OS
Windows 10
Language
.NET
Language Version
C# 10
Other information
The text was updated successfully, but these errors were encountered: