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

ECS task definition does not allow you to set linuxParameters, it is read only #2380

Closed
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container

Comments

@nathanpeck
Copy link
Member

nathanpeck commented Apr 25, 2019

There is no way to set the linuxParameters on an ECS task definition. It is present on the underlying CfnTaskDefinition.ContainerDefinitionProperty but is a readonly property on the actual CDK construct, with no way to set it

See the official ECS docs here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_linuxparameters

And the corresponding CFN docs here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-taskdefinition-linuxparameters.html

@nathanpeck nathanpeck added the gap label Apr 25, 2019
@nathanpeck
Copy link
Member Author

nathanpeck commented Apr 26, 2019

I found a workaround for now if anyone else encounters this:

    // Define the worker application.
    this.workerDefinition = new ecs.Ec2TaskDefinition(this, 'worker-definition', {
      cpu: '2048',
      memoryMiB: '4096'
    });

    this.container = this.workerDefinition.addContainer('worker', {
      image: ecs.ContainerImage.fromAsset(this, 'worker-image', {
        directory: './worker'
      }),
      memoryLimitMiB: 4096,
      privileged: true,
      cpu: 2048
    });

    this.container.linuxParameters = new ecs.LinuxParameters();

    // Headless chrome requires more shared memory for rendering large pages
    this.container.linuxParameters.sharedMemorySize = 2048;

    // Headless chrome uses sandboxing which requires system admin capability
    this.container.linuxParameters.addCapabilities('SYS_ADMIN');

Although the constructor doesn't accept linuxParameters, if you are using JavaScript instead of TypeScript you can ignore the readonly status of the property and just overwrite the properties into the task defition that you need.

@eladb eladb added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Apr 28, 2019
@SoManyHs SoManyHs self-assigned this Apr 29, 2019
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue Apr 30, 2019
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue Apr 30, 2019
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue Apr 30, 2019
SanderKnape pushed a commit to SanderKnape/aws-cdk that referenced this issue May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment