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] Healthcheck command always prepends CMD #2461

Closed
ChrisLahaye opened this issue May 2, 2019 · 0 comments · Fixed by #2462 · May be fixed by MechanicalRock/account-reaper#6
Closed

[ecs] Healthcheck command always prepends CMD #2461

ChrisLahaye opened this issue May 2, 2019 · 0 comments · Fixed by #2462 · May be fixed by MechanicalRock/account-reaper#6
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug.

Comments

@ChrisLahaye
Copy link

Describe the bug
Adding a healthcheck command to an ECS container definition results in an invalid command after synthesizing.

Input: ['CMD', 'command']
Output:
      HealthCheck:
        Command:
          - CMD
          - CMD
          - echo
          - z

Input: ['CMD-SHELL', 'command']
Output:
      HealthCheck:
        Command:
          - CMD
          - CMD-SHELL
          - echo
          - z

To Reproduce

#!/usr/bin/env node
import 'source-map-support/register';
import cdk = require('@aws-cdk/cdk');
import ecs = require('@aws-cdk/aws-ecs');
import ec2 = require('@aws-cdk/aws-ec2');

const app = new cdk.App();

export class Stack extends cdk.Stack {
  public constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const cluster = new ecs.Cluster(this, 'Cluster', {
      vpc: new ec2.VpcNetwork(this, 'VPC', { maxAZs: 2 }),
    });
    cluster.addCapacity('Capa', {
      instanceType: new ec2.InstanceType("t2.xlarge"),
      desiredCapacity: 3,
    });

    new ecs.LoadBalancedEc2Service(this, 'Service', {
      cluster,
      memoryLimitMiB: 512,
      image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
    });

    const ec2TaskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef');

    ec2TaskDefinition.addContainer("WebContainer", {
      image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
      memoryLimitMiB: 1024,
      healthCheck: {
        command: ['CMD-SHELL', 'echo', 'z']
      }
    });
  }
}

new Stack(app, 'Demo');

Expected behavior

Input: ['CMD', 'command']
Output:
      HealthCheck:
        Command:
          - CMD
          - echo
          - z

Input: ['CMD-SHELL', 'command']
Output:
      HealthCheck:
        Command:
          - CMD-SHELL
          - echo
          - z

Version:

  • Arch Linux
  • Typescript
  • 0.29
@ChrisLahaye ChrisLahaye added the bug This issue is a bug. label May 2, 2019
@SoManyHs SoManyHs added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label May 4, 2019
rix0rrr pushed a commit that referenced this issue May 6, 2019
Adding a healthcheck command to an ECS container definition
results in an invalid command after synthesizing.

Before:

    Input: ['CMD', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD
              - CMD
              - echo
              - z

    Input: ['CMD-SHELL', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD
              - CMD-SHELL
              - echo
              - z

After:

    Input: ['CMD', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD
              - echo
              - z

    Input: ['CMD-SHELL', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD-SHELL
              - echo
              - z

fixes #2461

Signed-off-by: Chris Lahaye <dev@chrislahaye.com>
SanderKnape pushed a commit to SanderKnape/aws-cdk that referenced this issue May 14, 2019
Adding a healthcheck command to an ECS container definition
results in an invalid command after synthesizing.

Before:

    Input: ['CMD', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD
              - CMD
              - echo
              - z

    Input: ['CMD-SHELL', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD
              - CMD-SHELL
              - echo
              - z

After:

    Input: ['CMD', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD
              - echo
              - z

    Input: ['CMD-SHELL', 'command']
    Output:
          HealthCheck:
            Command:
              - CMD-SHELL
              - echo
              - z

fixes aws#2461

Signed-off-by: Chris Lahaye <dev@chrislahaye.com>
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.
Projects
None yet
2 participants