Open gratinierer opened 5 days ago
@gratinierer Good morning. Thanks for reporting the issue. Using the below CDK code (in TypeScript):
import * as cdk from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';
import path = require('path');
import * as s3Deployment from 'aws-cdk-lib/aws-s3-deployment';
export class CdktestStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const s3TestDeployment = new s3Deployment.BucketDeployment(this, 'TestBucketDeployment', {
sources:[s3Deployment.Source.asset(path.join(__dirname, 'source-files'))],
destinationBucket: s3.Bucket.fromBucketName(this, 'MyBucket', 'testbucket-issue32253')
});
console.log("s3TestDeployment.node.defaultChild instanceof cdk.Resource: " + (s3TestDeployment.node.defaultChild instanceof cdk.Resource));
console.log("s3TestDeployment.node.defaultChild === undefined: " + (s3TestDeployment.node.defaultChild === undefined));
const newBucket = new s3.Bucket(this, 'NewBucket');
console.log("newBucket.node.defaultChild instanceof cdk.Resource: "+ (newBucket.node.defaultChild instanceof cdk.Resource));
console.log("newBucket.node.defaultChild === undefined: "+ (newBucket.node.defaultChild === undefined));
}
}
And running cdk synth
produces the below output:
s3TestDeployment.node.defaultChild instanceof cdk.Resource: false
s3TestDeployment.node.defaultChild === undefined: true
newBucket.node.defaultChild instanceof cdk.Resource: false
newBucket.node.defaultChild === undefined: false
...
<<CFN Template YAML>>
If you check the code documentation for node.defaultChild
, it @returns — a construct or undefined if there is no default child
.
Also in above output, the defaultChild
for a BucketDeployment
is not defined, hence it cannot be used as a dependency (in Python CDK, undefined
is represented as NoneType
).
The most likely reason for defaultChild
not defined is that BucketDeployment
doesn't represents a resource where per code, BucketDeployment
extends Construct
(compare it to Bucket class, which extends BucketBase which further extends Resource
). And this makes sense since BucketDeployment
construct represents a deployment operation. And per CloudFormation DependsOn attribute documentation, it specifies that the creation of a specific resource follows another resource.
Thanks, Ashish
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
Describe the bug
Using a
aws_s3_deployment.BucketDeployment
and trying do add this deployment as dependency does not work.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
i would expect, that I can add a BucketDeployment as dependency to another L1-Constructs, as can do e.g. with aws_s3.Bucket
Current Behavior
is thrown
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.148.0 (build e5740c0)
Framework Version
No response
Node.js Version
20.15
OS
Win10
Language
Python
Language Version
No response
Other information
No response