cdklabs / cdk-stacksets

Apache License 2.0
93 stars 16 forks source link

Cannot perform aws_kms.Key.fromLookup in stacksets #564

Open jtirrell-amazon opened 2 months ago

jtirrell-amazon commented 2 months ago
Error: Cannot retrieve value from context provider key-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.
    at Function.getValue (/Users/jtirrell/Documents/git-repos/gitlab/wwps-lcc-proserve/delivery-kits/secure-sight-continuous-compliance/arch/cdk_build/node_modules/aws-cdk-lib/core/lib/context-provider.js:2:562)
    at Function.fromLookup (/Users/jtirrell/Documents/git-repos/gitlab/wwps-lcc-proserve/delivery-kits/secure-sight-continuous-compliance/arch/cdk_build/node_modules/aws-cdk-lib/aws-kms/lib/key.js:1:6753)
   const secureSightKmsKey = cdk.aws_kms.Key.fromLookup(
      this,
      "secureSightKmsKey",{
      aliasName: "alias/secureSightKmsKey"
      }
    );

I would expect, because the stack-set is targeted to an account / region that the env variable should be set so that I can perform these look-ups.

McDoit commented 1 month ago

I assume that any stack created by stacksets needs to be region agnostic, and therefore you can't provide account/region One way would be to create your own lookup lambda (fromLookup is usually local to your code, not cloudformation)

CraigLager commented 1 month ago

I have the same issue when trying to import a VPC

Error: Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.

Any workaround so that I can import a VPC into a stacksetstack would be very welcome at this point.