aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.59k stars 3.89k forks source link

aws-cdk-lib.pipelines: Codepipeline ECS CFN deploy step appear success without deployment finishing #23450

Closed proxy-hatch closed 1 year ago

proxy-hatch commented 1 year ago

Describe the bug

Using Docker image asset, CodePipeline is able to trigger ECS deployment via CloudFormation, but it seems like its just triggering ECS deployment and marking the step succeeded.

Expected Behavior

CodePipeline wait on ECS deployment step until deploy succeeds, then mark the step success. Otherwise, if ECS deployment fails, mark the step fail and block further pipeline execution for this release.

Current Behavior

CodePipeline does not seem to be aware of the ECS deployment status.

Reproduction Steps

CDK pipeline stack with ApplicationLoadBalancedFargateService stack. Below is ours, but any should work.

    const asset = new DockerImageAsset(this, 'ServiceImage', {
      directory: path.join(__dirname, '..', '..', '..', '..'),
      buildArgs: {
        SSH_PRIVATE_KEY: GITHUB_PRIVATE_KEY_BASE_64,
      },
    });

    const service = new ApplicationLoadBalancedFargateService(this, 'Service', {
      assignPublicIp: true,
      circuitBreaker: { rollback: false },
      cluster,
      cpu: cpuUnits,
      memoryLimitMiB: memoryMiB,
      deploymentController: {
        type: DeploymentControllerType.ECS,
      },
      desiredCount: 1,
      taskImageOptions: {
        containerName: SERVICE_NAME,
        image: ContainerImage.fromDockerImageAsset(asset),
        environment: {
          STAGE: stage,
          PORT: INTERNAL_HTTP_PORT.toString(),
          HEALTH_CHECK_PATH: HEALTH_CHECK_PATH,
        },
        enableLogging: true,
        logDriver: new AwsLogDriver({
          streamPrefix: 'service',
          logGroup: new LogGroup(this, `${ SERVICE_NAME }ApplicationLogGroup`),
        }),
        taskRole: serviceExecutionRole,
        containerPort: INTERNAL_HTTP_PORT,
      },
      loadBalancerName: `${ stage }-ALB`,
      maxHealthyPercent: 200,
      minHealthyPercent: stage === STAGE.ALPHA ? 0 : 100, // speed up deployment in dev testing
      openListener: true,
      publicLoadBalancer: true,
      serviceName: `${ stage }-${ SERVICE_NAME }`,
      targetProtocol: ApplicationProtocol.HTTP, // ALB to server
      protocol: props.enableHttps ? ApplicationProtocol.HTTPS : ApplicationProtocol.HTTP, // client to ALB
      listenerPort: props.enableHttps ? HTTPS_PORT : HTTP_PORT,
      certificate: props.enableHttps ? props.dns?.acmCertificate : undefined,
      domainName: props.enableHttps ? serviceHostedZone!.zoneName : undefined,
      domainZone: props.enableHttps ? serviceHostedZone! : undefined,
    });

    Array.from(this.props.ddb.tableEntries.values()).forEach(table => {
      DdbStack.grantTable(table, service.taskDefinition.taskRole);
    });

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

5.45.0 (build af1fb7c)

Framework Version

No response

Node.js Version

v16.17.0

OS

MacOS Monterey 12.5.1

Language

Typescript

Language Version

TypeScript (4.9.3)

Other information

No response

github-actions[bot] commented 1 year ago

⚠️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.

proxy-hatch commented 1 year ago

Pipeline was in an error state. Pushing latest commit fixed this.