-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
task_definition.add_volume: Error occuring during cdk synth with the module in cdk python #29517
Comments
This works for me in TS: export class DummyStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
const task = new ecs.FargateTaskDefinition(this, 'Task', { cpu: 512, memoryLimitMiB: 1024 });
const sampleContainer = task.addContainer('container', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
portMappings: [
{ containerPort: 80 },
],
});
const vol = new ecs.ServiceManagedVolume(this, 'Vol', {
name: 'dummy',
});
vol.mountIn(sampleContainer, {
containerPath: '/opt',
readOnly: false,
});
task.addVolume(vol);
}
} But this fails in Py class PythoncdkStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
task_definition = ecs.FargateTaskDefinition(self, "TaskDef")
container = task_definition.add_container("web",
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
port_mappings=[ecs.PortMapping(
container_port=80,
)]
)
volume = ecs.ServiceManagedVolume(self, "EBSVolume",
name="ebs1",
)
volume.mount_in(container,
container_path="/opt",
read_only=False
)
task_definition.add_volume(volume)
Subprocess exited with error 1 Both in 2.133.0. Looks like a JSII issue but I am not sure. Will bring this up for review. |
try
|
This is a problem in .Net also... works when
|
This is not a JSII issue. Look at the error message:
As suggested by @clarkm5, the correct way to call this function is:
Why does it work in TypeScript?The example is actually incorrect. The argument to It just so happens that aws-cdk/packages/aws-cdk-lib/aws-ecs/README.md Line 1829 in 2a00ddd
The example should be rewritten, probably to look something like this (warning, untested and no domain knowledge!): taskDefinition.addVolume({
name: 'vol0',
// Unsure how a ServiceManagedVolume needs to be attached to a TaskDefinition
// Refer to the service documentation for this.
dockerVolumeConfiguration: {
}
// Perhaps there needs to be a 'serviceManagedVolumeConfiguration' property here
}); |
Describe the bug
When trying to use task_definition.add_volume method in cdk python, it fails with the error below.
Code used by me:
Expected Behavior
Expected behaviour of this method is to add the volume and synthesize template without any issue. This is possible using typescript, only errors out in python.
Current Behavior
Error occurs during synth:
Reproduction Steps
Use the code below to reproduce the same:
Possible Solution
NA
Additional Information/Context
NA
CDK CLI Version
2.133.0 (build dcc1e75)
Framework Version
aws-cdk-lib==2.133.0 constructs>=10.0.0,<11.0.0
Node.js Version
v20.0.0
OS
MacOs
Language
Python
Language Version
Python 3.11.7
Other information
NA
The text was updated successfully, but these errors were encountered: