-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
aws-cdk: Ability to add metadata to assets and retain original source path of assets #27415
Comments
@sagar794 Could you please provide more details about what you mean by "validate the origin of the assets"? Are you looking to ensure that assets originate from a specific directory? Is this related to verifying artifact provenance? Perhaps it would be more sensible to generate a Software Bill of Materials (SBOM) for the CDK cloud assembly rather than relying on CDK metadata for this purpose? |
@evgenyka Sure thing! Thank you for taking the time to read through the issue.
What I meant by "validate the origin of the assets" is that I would like to know whether the asset that was staged came from a trusted source or if it came from somewhere else. In order to do that, I would need to know what was the original file that was referenced. CDK will save the original path of the file if For example, during the CI stage of my CI/CD pipeline if I wanted to ensure assets that were staged were sourced from local files only, I would not be able to do that since external files could be downloaded within the CDK application and those files could then be added as assets. Since CDK does not store the referenced files when creating an asset there is no way to audit that later without managing a custom solution.
Not a specific directory at the moment, but possibly could be. For now I am looking to verify that assets originate either from local files or from a trusted external source. When sourcing from the trusted external source I also need to retain the URL that was used to fetch the external asset (through a custom function). So downloading a file from the trusted external source in a way that bypasses the storage of the URL and using that as an asset would not be okay. This is where having the ability to associate additional metadata about assets would be nice to have.
Apologies if I misunderstood you here, but I don't think this would help resolve my problem statement since the original asset paths would not be known today when staging assets. |
Another similar request here #27402, but your request seems to be more general for all assets rather than for one, and it would make sense to me to add metadata in the assets file regarding where assets came from, rather than just the template which may not cover all assets |
Describe the feature
cdk synth
Use Case
I want my CI system to validate the origin of the assets that were added to the
cdk.out
directory during thecdk synth
execution. Today, when Assets are staged, they are copied over tocdk.out
as part ofcdk synth
. Within the<stackId>.asset.json
we can see the path to the staged asset, but not the original source path.For example, when viewing this
<stackId>.asset.json
file I know the staged asset is namedasset.97c324c84f5d023be4edee540cb2cb401a49f115d01ed403b288f6cb412771df.zip
, but not which file on the local was used to create this asset.The motivation for this feature is to be able to determine the origin of the asset using the
<stackId>.assets.json file
.We also have created a function that allows us to download assets from a trusted external source, but would like to be able to audit the external source used to create the asset later.
Proposed Solution
If possible to safely add new keys to the
<stackId>.asset.json
files, then I would propose adding a newmetadata
key where metadata by CDK and custom metadata added by users could reside postcdk synth
.As for the original source path, I would expect that data to be added by CDK.
For
lambda.fromAsset('path/to/file')
I would expect"@aws-cdk/originalSourcePath": "path/to/file"
to be in themetadata
section. For constructs likeNodejsFunction
it would be a bit tricker sinceentry
is not a required field in the props, but would like to know what value CDK resolved to for that. The same logic would follow for all other ways assets can get added with CDK.Users should be able to add their own metadata to assets as well. This could possibly be done by adding a new
metadata
parameter toAssetProps
for the Asset construct. All functions which create assets could then pass the metadata as an input. For my use case, this would be used to add the trusted external source URL that was used as metadata which could get audited later.Alternatively, the original source path could be it's own key similar to
path
andpackaging
outside of themetadata
section (i.e.originalSourcePath
).Other Information
This issue is similar, but not what I am looking for here since this is adding metadata to the CloudFormation template.
Acknowledgements
CDK version used
2.93.0
Environment details (OS name and version, etc.)
macOS Ventura (13.6)
The text was updated successfully, but these errors were encountered: