Open
Description
Describe the bug
I'm trying to use S3Deployment
with a Source.jsonData
source to deploy a json configuration file with values resolved at deploy time (eg cognito userpool id). These values, properties of a construct from another nested stack passed as StackProp to the S3Deployment nested stack, doesn't get resolved properly.
Expected Behavior
When I use values from another stack construct in a Source.jsonData
source with S3Deployment
, they are properly resolved at deploy time.
Current Behavior
A 'unresolved resource dependencies' error is thrown.
1:20:17 PM | CREATE_FAILED | AWS::CloudFormation::Stack | DeploymentNestedSt...ckResource3980C4F4
Template format error: Unresolved resource dependencies [UserPool6BA7E5F2] in the Resources block of the template
new NestedStack (nested-stack.ts:133:21)
\_ new DeploymentNestedStack (nested-stack-ref-bug-repro-lowing resource(s) failed to create: [ResourceNestedStackNestedStackResourceNestedStackNestedStackResourceCDDDB2BF, DeploymentNestedStackNestedStackDeploymentNestedStackNested
stack-bug-repro/app.ts:19:5)
\_ new MainStack nest-stack-ref-bug-repro/app.ts:33:5)
\_ Object.<anonymous> (nested-stack-b
ug-repro/app.ts:38:1)
\_ Module._compile (internal/modules/cjs/loader.js:1072:14)
\_ Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
\_ Module.load (internal/modules/cjs/loader.js:937:32)
\_ Function.Module._load (internal/modules/cjs/loader.js:778:12)
\_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
\_ internal/main/run_main_module.js:17:47
Reproduction Steps
import { App, Construct, Stack, NestedStack, StackProps, NestedStackProps } from '@aws-cdk/core'
import { UserPool, IUserPool } from '@aws-cdk/aws-cognito'
import { BucketDeployment, Source } from '@aws-cdk/aws-s3-deployment'
import { Bucket } from '@aws-cdk/aws-s3'
class ResourceNestedStack extends NestedStack {
userPool: UserPool
constructor (scope: Construct, id: string, props: NestedStackProps = {}){
super(scope, id, props)
this.userPool = new UserPool(this, 'UserPool')
}
}
interface DeploymentNestedStackProps extends NestedStackProps {
userPool: IUserPool
}
class DeploymentNestedStack extends NestedStack {
constructor (scope: Construct, id: string, props: DeploymentNestedStackProps){
super(scope, id, props)
const bucket = new Bucket(this, 'Bucket')
new BucketDeployment(this, 'Deployment', {
destinationBucket: bucket,
sources : [
Source.jsonData('appconfig.json', { userPoolId: props.userPool.userPoolId })
]
})
}
}
class MainStack extends Stack {
constructor (scope: Construct, id: string, props: StackProps = {}){
super(scope, id, props)
const resourceNestedStack = new ResourceNestedStack(this, 'ResourceNestedStack')
new DeploymentNestedStack(this, 'DeploymentNestedStack', { userPool: resourceNestedStack.userPool })
}
}
const app = new App()
new MainStack(app, 'MainStack', {
env: { account, region }
})
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
1.180.0
Framework Version
No response
Node.js Version
14.19.0
OS
Debian GNU/Linux 10 (buster)
Language
Typescript
Language Version
4.4.2
Other information
No response