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.52k stars 3.86k forks source link

(@aws-cdk/pipelines): CdkPipeline assets & DynamoDB with replicationRegions #12802

Closed adamskicool closed 3 years ago

adamskicool commented 3 years ago

When using the construct CdkPipeline to deploy a stack that creates a global dynamo table using replicationRegions, not all assets seem to be included in the assets stage of the pipeline. When synthesizing the pipeline, four assets seem to be connected to the stack (see below, copy pasted from cdk-out/assembly-{the-stack-name}). When I look at the pipelines assets (after having deployed the CdkPipeline) and go into their details I can see that there are only three of four assets included in the assets step, that is the last asset that looks like it contains a template is excluded (c58ee6d7fc2dd16161745b02f0d7220f4da730b163cdb57e3818cf4333515500)

Reproduction Steps

Create a CdkPipeline with one stage containing one stack that creates a global DynamoDB table

Stage:

import {
  Stage,
  Construct,
  StageProps,
} from "@aws-cdk/core";
import { StorageStack } from "../storage";

export class StorageStage extends Stage {
  constructor(
    scope: Construct,
    id: string,
    props?: StageProps
  ) {
    super(scope, id, props);

    new StorageStack(
      this,
      "storage-stack"
    );
  }
}

The stack the stage creates:

import {
  Construct,
  Stack,
  StackProps,
} from "@aws-cdk/core";
import {
  AttributeType,
  Table,
} from "@aws-cdk/aws-dynamodb";

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

    const replicationRegions: string[] = [
      "us-west-2",
    ];

    new Table(this, "Table", {
      partitionKey: {
        name: "id",
        type: AttributeType.STRING,
      },
      replicationRegions,
    });
  }
}

What did you expect to happen?

I expected the CodePipeline asset step to include all assets that the stack it is deploying contains.

What actually happened?

Includes all but one asset.

Environment

Other

assets in cdk.out directory for the stack with the global dynamo table in it:

{
  "version": "9.0.0",
  "files": {
    "10f8cd166dc2442813a83b2f11d3a8f68cd322ef11c5505728cff42ad157b8f7": {
      "source": {
        "path": "../asset.10f8cd166dc2442813a83b2f11d3a8f68cd322ef11c5505728cff42ad157b8f7",
        "packaging": "zip"
      },
      "destinations": {
        "current_account-current_region": {
          "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
          "objectKey": "10f8cd166dc2442813a83b2f11d3a8f68cd322ef11c5505728cff42ad157b8f7.zip",
          "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
        }
      }
    },
    "c691172cdeefa2c91b5a2907f9d81118e47597634943344795f1a844192dd49c": {
      "source": {
        "path": "../asset.c691172cdeefa2c91b5a2907f9d81118e47597634943344795f1a844192dd49c",
        "packaging": "zip"
      },
      "destinations": {
        "current_account-current_region": {
          "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
          "objectKey": "c691172cdeefa2c91b5a2907f9d81118e47597634943344795f1a844192dd49c.zip",
          "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
        }
      }
    },
    "48abd7e4370c6ed35ff7e97e4dc7ad83178b168242009155d7a1c32ee38734f6": {
      "source": {
        "path": "gastoragestackstoragegastoragestackawscdkawsdynamodbReplicaProvider98993AC5.nested.template.json",
        "packaging": "file"
      },
      "destinations": {
        "current_account-current_region": {
          "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
          "objectKey": "48abd7e4370c6ed35ff7e97e4dc7ad83178b168242009155d7a1c32ee38734f6",
          "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
        }
      }
    },
    "c58ee6d7fc2dd16161745b02f0d7220f4da730b163cdb57e3818cf4333515500": {
      "source": {
        "path": "gastoragestackstoragegastoragestackB41D5EEB.template.json",
        "packaging": "file"
      },
      "destinations": {
        "current_account-current_region": {
          "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
          "objectKey": "c58ee6d7fc2dd16161745b02f0d7220f4da730b163cdb57e3818cf4333515500",
          "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
        }
      }
    }
  },
  "dockerImages": {}
}

What the CodePipeline looks like in aws console:

Skärmavbild 2021-02-01 kl  13 51 23

This is :bug: Bug Report

otaviomacedo commented 3 years ago

@adamskicool This is the intended behavior. The pipeline deploys all assets, but excludes the stack template itself, which is the artifact that you noticed is missing.

github-actions[bot] commented 3 years 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.