1.4.98 • Published 2 years ago

cdk-decorators v1.4.98

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

📎TypeScript Decorators for AWS CDK

docs

This is a collection of TypeScript decorators for AWS Cloud Development Kit (CDK) that aims to make the code more aesthetically pleasing.

Note: This is not an official project from AWS.

Installation

This library is available on npm/yarn. To install it, run the following command:

npm install cdk-decorators

Usage

The library provides a set of decorators that can be used to annotate your CDK classes. Here's an example:

@TagWith('my-tag', 'my-value')
class TestStack extends Stack {
  constructor(scope: any, id: string) {
    super(scope, id);
    new Bucket(this, 'MyBucket', {});
  }
}

In this example, we're using the @TagWith decorator to annotate the class. The @TagWith decorator takes two arguments:

  • @TagWith(key?: string, value?: string): Adds a tag to all the resources in the stack with the specified key and value.

Decorators

TagWith

Adds a tag to all the resources in the stack with the specified key and value.

@TagWith('my-tag', 'my-value')
class TestStack extends Stack {
  constructor(scope: any, id: string) {
    super(scope, id);
    new Bucket(this, 'MyBucket', {});
  }
}

Aspect

Adds aspects to the stack.

@Aspect((node: IConstruct) => {
  if (node instanceof CfnBucket) {
    node.bucketName = 'my-bucket';
  }
})
class TestStack extends Stack {
  constructor(scope: any, id: string) {
    super(scope, id);
    new Bucket(this, 'MyBucket', {});
  }
}

Skip

Skips stack synthesis for the annotated class.

@Skip
class TestStack extends Stack {
  constructor(scope: any, id: string) {
    super(scope, id);
    new Bucket(this, 'MyBucket', {});
  }
}

TriggerAfter

Triggers a lambda function after the stack has been deployed.

@TriggerAfter({
  code: Code.fromInline(`
      exports.handler = async (event) => {
        console.log('event: ', event)
      };
    `),
  handler: 'index.handler',
  runtime: Runtime.NODEJS_14_X,
})
class TestStack extends Stack {
  constructor(scope: any, id: string) {
    super(scope, id);
  }
}

PrefixWith

Prefixes all the resources in the stack with the specified string.

@PrefixWith('MyPrefix')
class TestStack extends Stack {
  constructor(scope: any, id: string) {
    super(scope, id);
    new Bucket(this, 'Bucket', {});
  }
}

Contributing

Contributions are welcome! If you find a bug or have an idea for a new feature, feel free to open an issue or submit a pull request.

Before submitting a pull request, please make sure to run the tests:

yarn test

License

This library is licensed under the MIT License. See the LICENSE file for more information.

1.4.98

2 years ago

1.4.97

2 years ago

1.4.96

2 years ago

1.4.95

2 years ago

1.4.80

2 years ago

1.4.82

2 years ago

1.4.81

2 years ago

1.4.84

2 years ago

1.4.83

2 years ago

1.4.86

2 years ago

1.4.85

2 years ago

1.4.88

2 years ago

1.4.87

2 years ago

1.4.89

2 years ago

1.4.91

2 years ago

1.4.90

2 years ago

1.4.93

2 years ago

1.4.92

2 years ago

1.4.94

2 years ago

1.4.64

2 years ago

1.4.63

2 years ago

1.4.66

2 years ago

1.4.65

2 years ago

1.4.68

2 years ago

1.4.67

2 years ago

1.4.69

2 years ago

1.4.71

2 years ago

1.4.70

2 years ago

1.4.73

2 years ago

1.4.72

2 years ago

1.4.75

2 years ago

1.4.74

2 years ago

1.4.77

2 years ago

1.4.76

2 years ago

1.4.79

2 years ago

1.4.78

2 years ago

1.4.60

2 years ago

1.4.62

2 years ago

1.4.61

2 years ago

1.4.59

2 years ago

1.4.57

2 years ago

1.4.58

2 years ago

1.4.55

2 years ago

1.4.54

2 years ago

1.4.56

2 years ago

1.4.48

2 years ago

1.4.47

2 years ago

1.4.49

2 years ago

1.4.51

2 years ago

1.4.50

2 years ago

1.4.53

2 years ago

1.4.52

2 years ago

1.4.28

2 years ago

1.4.29

2 years ago

1.4.31

2 years ago

1.4.30

2 years ago

1.4.33

2 years ago

1.4.32

2 years ago

1.4.35

2 years ago

1.4.34

2 years ago

1.4.37

2 years ago

1.4.36

2 years ago

1.4.39

2 years ago

1.4.38

2 years ago

1.4.40

2 years ago

1.4.42

2 years ago

1.4.41

2 years ago

1.4.44

2 years ago

1.4.43

2 years ago

1.4.46

2 years ago

1.4.45

2 years ago

1.4.20

2 years ago

1.4.22

2 years ago

1.4.21

2 years ago

1.4.24

2 years ago

1.4.23

2 years ago

1.4.26

2 years ago

1.4.25

2 years ago

1.4.27

2 years ago

1.4.9

2 years ago

1.4.11

2 years ago

1.4.8

2 years ago

1.4.10

2 years ago

1.4.13

2 years ago

1.4.12

2 years ago

1.4.15

2 years ago

1.4.14

2 years ago

1.4.17

2 years ago

1.4.16

2 years ago

1.4.19

2 years ago

1.4.18

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.7

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago