Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets: Add property to retrieve content hash #1400

Closed
Assignees
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved.

Comments

@RomainMuller
Copy link
Contributor

As seen in cdklabs/aws-delivlib#20 - it is useful to be able to determine a content hash for an asset so as to allow detection of changes. This also would help support de-duplication of assets during the upload phase.

@aripalo
Copy link

aripalo commented Feb 28, 2019

One example use case for this would be having Lambda@Edge with CloudFront. These deploys take an awfully long.

At least in my case the Edge Lambda code doesn't change so much… so if I could just get the hash of the asset and compare it to the hash of the deployed version I could determine if I need to make a change at all. And when I would not need to make a change to the Edge Lambda, then the whole deployment would be much faster.

@eladb eladb assigned eladb and unassigned sam-goodwin Mar 4, 2019
@fulghum fulghum added effort/medium Medium work item – several days of effort and removed effort/small Small work item – less than a day of effort labels Mar 11, 2019
@eladb
Copy link
Contributor

eladb commented Apr 16, 2019

Please notice that we already have a fingerprint of the asset source available during synthesis, which is used to stage the artifact in the staging directory.

This issue is about the hash of the artifact, which we can know calculate after the asset is bundled (e.g. the .zip is created, the docker image is produced, etc). Since this information cannot be "sent back in time" to synthesis, we can pass it through as a CloudFormation parameter (together with S3 coordinates/docker image location) and make it available as a token during synthesis.

@RomainMuller RomainMuller assigned RomainMuller and unassigned eladb Apr 16, 2019
RomainMuller added a commit that referenced this issue Apr 19, 2019
Introduces an `IAsset` interface that centralizes common aspects about
assets, such as the `sourceHash` and `bundleHash` properties.

The `sourceHash` fingerprints the objects that are used as the source
for the asset bundling logic, and is available at synthesis time (it can
for example be injected in construct IDs when it one wants to ensure a
new logical ID is issued for every new version of the asset).

The `bundleHash` fingerprints the result of the bundling logic, and is
more accurate than `sourceHash` (in that, if the same source can produce
different artifacts at different points in time, the `sourceHash` will
remain un-changed, but the `bundleHash` will change. The `bundleHash` is
however a deploy-time value and thus cannot be used in construct IDs.

Fixes #1400
RomainMuller added a commit that referenced this issue Apr 19, 2019
Introduces an `IAsset` interface that centralizes common aspects about
assets, such as the `sourceHash` and `bundleHash` properties.

The `sourceHash` fingerprints the objects that are used as the source
for the asset bundling logic, and is available at synthesis time (it can
for example be injected in construct IDs when it one wants to ensure a
new logical ID is issued for every new version of the asset).

The `bundleHash` fingerprints the result of the bundling logic, and is
more accurate than `sourceHash` (in that, if the same source can produce
different artifacts at different points in time, the `sourceHash` will
remain un-changed, but the `bundleHash` will change. The `bundleHash` is
however a deploy-time value and thus cannot be used in construct IDs.

Fixes #1400
RomainMuller added a commit that referenced this issue May 23, 2019
Introduces an `IAsset` interface that centralizes common aspects about
assets, such as the `sourceHash` and `bundleHash` properties.

The `sourceHash` fingerprints the objects that are used as the source
for the asset bundling logic, and is available at synthesis time (it can
for example be injected in construct IDs when it one wants to ensure a
new logical ID is issued for every new version of the asset).

The `bundleHash` fingerprints the result of the bundling logic, and is
more accurate than `sourceHash` (in that, if the same source can produce
different artifacts at different points in time, the `sourceHash` will
remain un-changed, but the `bundleHash` will change. The `bundleHash` is
however a deploy-time value and thus cannot be used in construct IDs.

Fixes #1400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment