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.57k stars 3.88k forks source link

(codepipeline): Stack.crossRegionReferences fails with "aliasName: required but missing." #27137

Open closesimple-wl opened 1 year ago

closesimple-wl commented 1 year ago

Describe the bug

I understand crossRegionReferences is experimental, but I'd expect to actually get it deployed.

The problem seems related to the CrossRegionSupportStack. The most relevant part of the stack trace looks like:

aws-cdk-lib/aws-kms/lib/kms.generated.js:1:2998)
    at CfnAlias.renderProperties

Expected Behavior

No error when using cross-region CodePipeline action.

Current Behavior

Error: Resolution error: Supplied properties not correct for "CfnAliasProps"
  aliasName: required but missing.

Trace: Error: Resolution error: Supplied properties not correct for "CfnAliasProps"
  aliasName: required but missing.
    at ValidationResult.assertSuccess (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/runtime.js:1:2643)
    at convertCfnAliasPropsToCloudFormation (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/aws-kms/lib/kms.generated.js:1:2998)
    at CfnAlias.renderProperties (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/aws-kms/lib/kms.generated.js:1:1885)
    at PostResolveToken.Resources [as processor] (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/cfn-resource.js:1:7100)
    at PostResolveToken.postProcess (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/util.js:1:1565)
    at Object.postProcess (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:1018)
    at DefaultTokenResolver.resolveToken (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/resolvable.js:1:1320)
    at resolve (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:2510)
    at Object.resolve (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:892)
    at resolve (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:2787)
    at Object.resolve (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:892)
    at resolve (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:2787)
    at CrossRegionSupportStack.resolve (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/stack.js:1:6002)
    at node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/stack.js:1:18206
    at Array.map (<anonymous>)
    at CrossRegionSupportStack._toCloudFormation (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/stack.js:1:18194)
    at CrossRegionSupportStack._synthesizeTemplate (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/stack.js:1:12593)
    at DefaultStackSynthesizer.synthesizeTemplate (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/stack-synthesizers/stack-synthesizer.js:1:1699)
    at DefaultStackSynthesizer.synthesize (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.1.156/node_modules/aws-cdk-lib/core/lib/stack-synthesizers/default-synthesizer.js:1:6211)
    at node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.2.69/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:2:3407
    at visit (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.2.69/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:4:368)
    at visit (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.2.69/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:4:330)
    at synthesizeTree (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.2.69/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:2:3251)
    at synthesize (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.2.69/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:1:1083)
    at App.synth (node_modules/.pnpm/aws-cdk-lib@2.95.1_constructs@10.2.69/node_modules/aws-cdk-lib/core/lib/stage.js:1:2052)
    at Module.synth (node_modules/.pnpm/sst@2.25.1/node_modules/sst/stacks/synth.js:65:30)
    at async node_modules/.pnpm/sst@2.25.1/node_modules/sst/cli/commands/deploy.js:80:28
    at async Object.handler (node_modules/.pnpm/sst@2.25.1/node_modules/sst/cli/commands/deploy.js:71:26)
    at process.<anonymous> (node_modules/.pnpm/sst@2.25.1/node_modules/sst/cli/sst.js:62:21)
    at process.emit (node:events:525:35)
    at process.emit (node:domain:489:12)
    at process._fatalException (node:internal/process/execution:149:25)
    at processPromiseRejections (node:internal/process/promises:279:13)
    at processTicksAndRejections (node:internal/process/task_queues:97:32)

Reproduction Steps

CodePipeline construct with an existing Project.fromProjectArn() CodeBuild Project in a different region than the pipeline. Attempt to deploy.

https://github.com/closesimple-wl/codepipeline-repro

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.95.1 (build ae455d8)

Framework Version

No response

Node.js Version

16

OS

macOS 13.4

Language

Typescript

Language Version

No response

Other information

No response

peterwoodworth commented 1 year ago

Could you provide minimal reproduction code please? I'm not sure how you have this setup in CDK

closesimple-wl commented 1 year ago

Minimal-ish reproduction repo: https://github.com/closesimple-wl/codepipeline-repro

closesimple-wl commented 1 year ago

I realize the reproduction repo's code isn't the correct approach because I need a separate stack for the other region's resource(s). But even after stripping it down to direct cdk synthesize on a single App with two Stack, the error message is the same.

So regardless of the example code not being correct according to https://github.com/aws/aws-cdk/blob/af998c8581d2600fa4aa8d5fc5137da84d0f3418/packages/aws-cdk-lib/README.md?plain=1#L228, this still appears to be a real bug.

vibhavsinha commented 5 months ago

Is there any workaround for this problem?