feat(core): add git source metadata to CloudFormation templates#37368
feat(core): add git source metadata to CloudFormation templates#37368otaviomacedo wants to merge 10 commits intomainfrom
Conversation
Synthesized CloudFormation templates now include an `AWS::CloudFormation::Source`
entry in the top-level `Metadata` section containing the git remote repository
URL and the latest commit hash. This helps trace deployed stacks back to their
source code.
Example output:
Metadata:
AWS::CloudFormation::Source:
Repository: git@github.com:org/app.git
Commit: 19e3e594a5512b75074526af89bf3b67a3164cc1
The metadata is generated by default. It can be suppressed by:
- Setting the `CDK_DISABLE_GIT_SOURCE` environment variable
- Setting the `@aws-cdk/core:disableGitSource` context key to `true`
If the current directory is not a git repository or git is not available,
the metadata entry is silently omitted.
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Features must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
|
Is there a way to get that information on a stack or app? https://github.com/open-constructs/cdk-devops (Sorry no docs yet) |
This reverts commit 93c0aba.
Add it to the cloud assembly metadata
| // add the permissions boundary aspect | ||
| this.addPermissionsBoundaryAspect(); | ||
|
|
||
| const gitSource = getGitSource(); |
There was a problem hiding this comment.
We should probably be able to make this configurable at the App level.
There was a problem hiding this comment.
Yes, but if it's enabled by default, we would have to disable it in every integ test, for example. I had this in some iteration, but decided against it when the PR had 1000+ changes, and GitHub would truncate it and not even get to the important bits :/
There was a problem hiding this comment.
We probably should have a mechanism to make config changes to every integ test. Might need a separate PR.
| @@ -0,0 +1,3 @@ | |||
| // Disable git source metadata in CloudFormation templates during tests | |||
| // to avoid breaking existing snapshot/assertion tests. | |||
| process.env.CDK_DISABLE_GIT_SOURCE = '1'; | |||
There was a problem hiding this comment.
To avoid negative parameters, something like:
| process.env.CDK_DISABLE_GIT_SOURCE = '1'; | |
| process.env.CDK_GIT_SOURCE = '0'; |
?
Synthesized CloudFormation templates now include an
AWS::CloudFormation::Sourceentry in the top-level
Metadatasection containing the git remote repository URL andthe latest commit hash. This helps trace deployed stacks back to their source code.
Example output:
The metadata is also added to the cloud assembly.
The metadata is generated by default. It can be suppressed by setting the
CDK_DISABLE_GIT_SOURCEenvironment variable.If the current directory is not a git repository or git is not available, the metadata entry
is silently omitted.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license