Skip to content

Commit 4e958d4

Browse files
authored
feat: show friendly display names for assets (#33844)
Assets created by the AWS Construct Library now use friendly display names. - Assets like stack templates now show a display name like `MyStack Template`. - Assets from `Asset` or `ImageAsset` constructs now show the stack-relative construct path of the asset construct, like `MyConstruct/MyFunction/Code`. These defaults explicitly don't use entire construct paths on purpose, because those will be confusing in combination with the deduplication behavior of assets; if the same asset is added in multiple places in the construct tree, it will be deduplicated (based on the asset hash) and only processed once. The defaults have therefore been chosen to give useful contextual information, without implying a context that will alarm users. For example, it would be confusing for users to see references to `/MyBetaStage/MyStack Template` or `/MyBetaStack/MyFunction/Code` when they were deploying a "prod" environment; but if we used full context paths and the Beta resources were defined first, that would be the default behavior. A `displayName` property is available to override the default if the defaults are undesirable. This property is available for Asset/AssetImage constructs and their helper functions, not for template assets. ## Implementation notes Since in the cloud assembly `displayName` is part of neither asset *source* not asset *destination*, but an additional field, I've had to add a 3rd parameter `Add*AssetOptions` to most of the `add*Asset()` methods and it needs to be forwarded in a number of places. The CDK Pipelines implementation also needed to add the concept of a `displayName` to pipeline graph nodes, since reflecting it in the node IDs had far-reaching consequences (the node ID also affects the construct IDs of constructs that get created, and we don't want to have to recreate these just for a different display name). Uniquification of action names happens at the very last moment, when we put the Pipeline together. `GraphNode.of()` accepts positional parameters so I added a positional optional argument for display name there, but since in TypeScript subclasses have to be structurally compatible with superclasses (😶‍🌫️) and `Graph.of()` already takes an argument in that position, the type of that argument is now weird. The alternative would be to change the signature to `Graph.of(id, data, <displayName?>, nodes?)`, inserting `displayName`, but even though this is not part of the super public jsii interface this method is still accessible on the semi-public "extend me via TypeScript only" interface and we don't want to unnecessarily break consumers. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 56586f4 commit 4e958d4

File tree

95 files changed

+2209
-6774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2209
-6774
lines changed

packages/@aws-cdk-testing/framework-integ/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"license": "Apache-2.0",
3131
"devDependencies": {
3232
"@aws-cdk/cdk-build-tools": "0.0.0",
33-
"@aws-cdk/integ-runner": "2.186.0",
33+
"@aws-cdk/integ-runner": "^2.186.0",
3434
"@aws-cdk/pkglint": "0.0.0",
3535
"@aws-sdk/client-acm": "3.632.0",
3636
"@aws-sdk/client-rds": "3.632.0",

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/PipelinesFileSystemLocations.assets.json

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/PipelinesFileSystemLocations.template.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@
883883
"Name": "Synth_Output"
884884
}
885885
],
886-
"Name": "FileAsset1",
886+
"Name": "Asset",
887887
"RoleArn": {
888888
"Fn::GetAtt": [
889889
"PipelineCodeBuildActionRole226DB0CB",
@@ -1732,7 +1732,7 @@
17321732
"Cache": {
17331733
"Type": "NO_CACHE"
17341734
},
1735-
"Description": "Pipeline step PipelinesFileSystemLocations/Pipeline/Assets/FileAsset1",
1735+
"Description": "Pipeline step PipelinesFileSystemLocations/Pipeline/Assets/Asset",
17361736
"EncryptionKey": "alias/aws/s3",
17371737
"Environment": {
17381738
"ComputeType": "BUILD_GENERAL1_SMALL",

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/assembly-PipelinesFileSystemLocations-Beta/PipelinesFileSystemLocationsBetaStack18199ECAE.assets.json

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/assembly-PipelinesFileSystemLocations-Beta/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/assembly-PipelinesFileSystemLocations-Beta/manifest.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/cdkintegcodepipelinewithfilesystemlocationsDefaultTestDeployAssert3E26E748.assets.json

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/pipelines/test/integ.newpipeline-with-file-system-locations.js.snapshot/manifest.json

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)