aws / aws/aws-cdk

aws-s3-deployment: BucketDeployment cannot be used as dependency for L1 resources

Open
#30,635 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-s3-deployment feature-request p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

We should be able to call `addDepenedency(bucketDeployment)` on L1 resources that depend on a bucket deployment, but it does not currently work.

### Use Case

Right now, e.g. cases where an L1 resource depends on an S3 objects (such as Greengrassv2 ComponentVersions) are unsupported, as the BucketDeployment is some kind of special resource that does not implement the interfaces of the `CfnResource`, including also on it's `node.defaultChild` property. This makes it impossible to use the BucketDeployment with such resources, as they require the S3 object to already exist before they can be created.

### Proposed Solution

I think `node.defaultChild` property of the BucketDeployment should implement CfnResource interface because its just a custom resource and those can be used as dependencies in Cloudformation, right?

### Other Information

I was able to use this hack as a workaround:

```typescript
const recipie = this.generateGGv2Recipie();

const depl = new BucketDeployment(this, "GGv2RunScript", {
sources: [
Source.asset(path.join(__dirname, "..", "..", "..", "src"), {
ignoreMode: cdk.IgnoreMode.GIT,
exclude: ["*", "!ggv2-run.sh"],
assetHash: recipie,
})
],
destinationBucket: Bucket.fromBucketName(this, "ComponentsBucket", cfg.componentsBucketName),
// its required to make sure the path to file is predictable because greengrass needs full path to the file in the recipie and the file to exist at the given location before the componentversion can be created
destinationKeyPrefix: "/my/prefix/",
extract: true
});

const componentVersion = new ggv2.CfnComponentVersion(this, "MyComponent", {
inlineRecipe: recipie,
});
Dependable.implement(depl, {dependencyRoots: [depl]})
componentVersion.node.addDependency(depl)
```

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.147.0

### Environment details (OS name and version, etc.)

Ubuntu 22.04, AMD64

Contributor guide

Open the contributing guide

Research direction

Start with BucketDeployment and its node.defaultChild, then reproduce the dependency path with an L1 resource such as ggv2.CfnComponentVersion. Check how addDependency and Dependable roots handle the deployment. Done means an L1 resource can depend on BucketDeployment without the shown workaround and the dependency is honored.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.