This is a CDK Aspect that will tag your CDK Stacks with the current git repo location for easier identification of deployed stacks.
npm install @defiance-digital/cdk-git-taggeror
yarn add @defiance-digital/cdk-git-taggerimport { GitUrlTagger } from '@defiance-digital/cdk-git-tagger';
import { App, Aspects, Stack, StackProps } from 'aws-cdk-lib';
import { Topic } from 'aws-cdk-lib/aws-sns';
import { Construct } from 'constructs';
export class MyStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps = {}) {
super(scope, id, props);
// define resources here...
new Topic(this, 'MyTopic');
}
}
const app = new App();
new MyStack(app, 'cdk-aspect-git-tagger-tester-dev');
Aspects.of(app).add(new GitUrlTagger());
app.synth();{
"Resources": {
"MyTopic86869434": {
"Type": "AWS::SNS::Topic",
"Properties": {
"Tags": [
{
"Key": "GitUrl",
"Value": "https://github.com/defiance-digital/cdk-aspect-git-tagger-test.git"
}
]
}
}
}
}import { GitUrlTaggerProps } from '@defiance-digital/cdk-git-tagger'
const gitUrlTaggerProps: GitUrlTaggerProps = { ... }| Name | Type | Description |
|---|---|---|
normalizeUrl |
boolean |
A flag on whether to try to normalize the URL found in the git config If enabled, it will turn ssh urls into https urls. |
tagName |
string |
The Tag key/name to use. |
public readonly normalizeUrl: boolean;- Type: boolean
- Default: true
A flag on whether to try to normalize the URL found in the git config If enabled, it will turn ssh urls into https urls.
public readonly tagName: string;- Type: string
- Default: 'GitUrl'
The Tag key/name to use.
- Implements: aws-cdk-lib.IAspect
import { GitUrlTagger } from '@defiance-digital/cdk-git-tagger'
new GitUrlTagger(props?: GitUrlTaggerProps)| Name | Type | Description |
|---|---|---|
props |
GitUrlTaggerProps |
No description. |
- Type: GitUrlTaggerProps
| Name | Description |
|---|---|
findGitDirectory |
No description. |
putGitUrlInFile |
No description. |
retrieveGitUrl |
No description. |
visit |
All aspects can visit an IConstruct. |
public findGitDirectory(): stringpublic putGitUrlInFile(gitUrl: string): void- Type: string
public retrieveGitUrl(): stringpublic visit(construct: IConstruct): voidAll aspects can visit an IConstruct.
- Type: constructs.IConstruct