aws / aws/aws-cdk

(s3-deployment): BucketDeployment expose asset hash

Open
#29,336 0 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-s3-deployment effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the feature

I would like to be able to access some kind of hash for the assets in a BucketDeployment.

### Use Case

I have an s3 bucket with some sql schema migrations, and I want to run a Custom Resource Provider when the lambda or the migration files change.

### Proposed Solution

Add hashes to the [array](https://github.com/aws/aws-cdk/blob/a7de7feb6a14658ec25f4cfda434d5e1d69157d2/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts#L279C29-L279C41) of [`SourceConfigs`](https://github.com/aws/aws-cdk/blob/0d6ef63e04ed0301e40684594266e83b50dce186/packages/aws-cdk-lib/aws-s3-deployment/lib/source.ts#L13) in a `BucketDeployment`, and add a getter to hash all of them.

### Other Information

This *can* be done if there is only one source with
```
const migrationFilesHash: string = (migrationFilesDeployment.node.findChild("Asset1")).assetHash;
```
but I don't like relying on the magic string `Asset` because that isn't part of any api agreement.

### Acknowledgements

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

### CDK version used

2.130.0

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

debian stable

Contributor guide

Open the contributing guide

Research direction

Start with packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts at the SourceConfigs array and packages/aws-cdk-lib/aws-s3-deployment/lib/source.ts at the SourceConfigs definition. Trace how deployment assets are represented, then expose their hashes through the BucketDeployment API and provide a combined hash getter as described; done means consumers no longer need the magic Asset1 child name.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.