-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: show friendly display names for assets #33844
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
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #33844 +/- ##
==========================================
+ Coverage 82.35% 82.38% +0.03%
==========================================
Files 120 120
Lines 6941 6955 +14
Branches 1172 1173 +1
==========================================
+ Hits 5716 5730 +14
Misses 1120 1120
Partials 105 105
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
| buildSpecString: actualBuildSpec.toBuildSpec(), | ||
| })); | ||
|
|
||
| const actionName = options.actionName ?? this.stepId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This never did anything. The type of actionName is string (not string | undefined).
|
Build failures are due to |
Co-authored-by: Otavio Macedo <[email protected]>
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |


Assets created by the AWS Construct Library now use friendly display names.
MyStack Template.AssetorImageAssetconstructs now show the stack-relative construct path of the asset construct, likeMyConstruct/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 Templateor/MyBetaStack/MyFunction/Codewhen 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
displayNameproperty 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.Impact of this change
The new display name isn't used anywhere that impacts resource replacement. Your resources will deploy the same as they did before.
You will see this new name in CLI progress information, and in the action names of CDK Pipelines.
Any CDK Pipelines will self-mutate one additional time to show the new asset names, and will remain stable afterwards.
Implementation notes
Since in the cloud assembly
displayNameis part of neither asset source not asset destination, but an additional field, I've had to add a 3rd parameterAdd*AssetOptionsto most of theadd*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
displayNameto 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 (😶🌫️) andGraph.of()already takes an argument in that position, the type of that argument is now weird. The alternative would be to change the signature toGraph.of(id, data, <displayName?>, nodes?), insertingdisplayName, 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