1.4.98 • Published 5 months ago

cdk-decorators v1.4.98

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months 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

5 months ago

1.4.97

5 months ago

1.4.96

5 months ago

1.4.95

5 months ago

1.4.80

8 months ago

1.4.82

8 months ago

1.4.81

8 months ago

1.4.84

8 months ago

1.4.83

8 months ago

1.4.86

7 months ago

1.4.85

7 months ago

1.4.88

6 months ago

1.4.87

7 months ago

1.4.89

6 months ago

1.4.91

6 months ago

1.4.90

6 months ago

1.4.93

6 months ago

1.4.92

6 months ago

1.4.94

5 months ago

1.4.64

10 months ago

1.4.63

10 months ago

1.4.66

10 months ago

1.4.65

10 months ago

1.4.68

9 months ago

1.4.67

10 months ago

1.4.69

9 months ago

1.4.71

9 months ago

1.4.70

9 months ago

1.4.73

9 months ago

1.4.72

9 months ago

1.4.75

9 months ago

1.4.74

9 months ago

1.4.77

9 months ago

1.4.76

9 months ago

1.4.79

8 months ago

1.4.78

9 months ago

1.4.60

10 months ago

1.4.62

10 months ago

1.4.61

10 months ago

1.4.59

10 months ago

1.4.57

11 months ago

1.4.58

11 months ago

1.4.55

11 months ago

1.4.54

11 months ago

1.4.56

11 months ago

1.4.48

11 months ago

1.4.47

11 months ago

1.4.49

11 months ago

1.4.51

11 months ago

1.4.50

11 months ago

1.4.53

11 months ago

1.4.52

11 months ago

1.4.28

12 months ago

1.4.29

12 months ago

1.4.31

12 months ago

1.4.30

12 months ago

1.4.33

12 months ago

1.4.32

12 months ago

1.4.35

12 months ago

1.4.34

12 months ago

1.4.37

12 months ago

1.4.36

12 months ago

1.4.39

12 months ago

1.4.38

12 months ago

1.4.40

12 months ago

1.4.42

11 months ago

1.4.41

11 months ago

1.4.44

11 months ago

1.4.43

11 months ago

1.4.46

11 months ago

1.4.45

11 months ago

1.4.20

1 year ago

1.4.22

1 year ago

1.4.21

1 year ago

1.4.24

1 year ago

1.4.23

1 year ago

1.4.26

1 year ago

1.4.25

1 year ago

1.4.27

1 year ago

1.4.9

1 year ago

1.4.11

1 year ago

1.4.8

1 year ago

1.4.10

1 year ago

1.4.13

1 year ago

1.4.12

1 year ago

1.4.15

1 year ago

1.4.14

1 year ago

1.4.17

1 year ago

1.4.16

1 year ago

1.4.19

1 year ago

1.4.18

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.7

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago