Skip to content

Latest commit

 

History

History
190 lines (123 loc) · 5.4 KB

File metadata and controls

190 lines (123 loc) · 5.4 KB

CDK Aspect Git Tagger

This is a CDK Aspect that will tag your CDK Stacks with the current git repo location for easier identification of deployed stacks.

How to install

npm install @defiance-digital/cdk-git-tagger

or

yarn add @defiance-digital/cdk-git-tagger

How to use

import { 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();

Example Output

{
  "Resources": {
    "MyTopic86869434": {
      "Type": "AWS::SNS::Topic",
      "Properties": {
        "Tags": [
          {
            "Key": "GitUrl",
            "Value": "https://github.com/defiance-digital/cdk-aspect-git-tagger-test.git"
          }
        ]
      }
    }
  }
}

API Reference

Structs

GitUrlTaggerProps

Initializer

import { GitUrlTaggerProps } from '@defiance-digital/cdk-git-tagger'

const gitUrlTaggerProps: GitUrlTaggerProps = { ... }

Properties

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.

normalizeUrlOptional
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.


tagNameOptional
public readonly tagName: string;
  • Type: string
  • Default: 'GitUrl'

The Tag key/name to use.


Classes

GitUrlTagger

  • Implements: aws-cdk-lib.IAspect

Initializers

import { GitUrlTagger } from '@defiance-digital/cdk-git-tagger'

new GitUrlTagger(props?: GitUrlTaggerProps)
Name Type Description
props GitUrlTaggerProps No description.

propsOptional

Methods

Name Description
findGitDirectory No description.
putGitUrlInFile No description.
retrieveGitUrl No description.
visit All aspects can visit an IConstruct.

findGitDirectory
public findGitDirectory(): string
putGitUrlInFile
public putGitUrlInFile(gitUrl: string): void
gitUrlRequired
  • Type: string

retrieveGitUrl
public retrieveGitUrl(): string
visit
public visit(construct: IConstruct): void

All aspects can visit an IConstruct.

constructRequired
  • Type: constructs.IConstruct