├── .eslintrc.json ├── .gitattributes ├── .github ├── pull_request_template.md └── workflows │ ├── auto-approve.yml │ ├── build.yml │ ├── pull-request-lint.yml │ ├── release.yml │ ├── stale.yml │ └── upgrade-main.yml ├── .gitignore ├── .mergify.yml ├── .npmignore ├── .projen ├── deps.json ├── files.json └── tasks.json ├── .projenrc.js ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── lambda ├── .gitignore └── index.js ├── package.json ├── src ├── index.ts └── triggers.ts ├── test ├── __snapshots__ │ └── trigger.test.ts.snap └── trigger.test.ts ├── tsconfig.dev.json ├── version.json └── yarn.lock /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true, 4 | "node": true 5 | }, 6 | "root": true, 7 | "plugins": [ 8 | "@typescript-eslint", 9 | "import" 10 | ], 11 | "parser": "@typescript-eslint/parser", 12 | "parserOptions": { 13 | "ecmaVersion": 2018, 14 | "sourceType": "module", 15 | "project": "./tsconfig.dev.json" 16 | }, 17 | "extends": [ 18 | "plugin:import/typescript" 19 | ], 20 | "settings": { 21 | "import/parsers": { 22 | "@typescript-eslint/parser": [ 23 | ".ts", 24 | ".tsx" 25 | ] 26 | }, 27 | "import/resolver": { 28 | "node": {}, 29 | "typescript": { 30 | "project": "./tsconfig.dev.json", 31 | "alwaysTryTypes": true 32 | } 33 | } 34 | }, 35 | "ignorePatterns": [ 36 | "*.js", 37 | "!.projenrc.js", 38 | "*.d.ts", 39 | "node_modules/", 40 | "*.generated.ts", 41 | "coverage" 42 | ], 43 | "rules": { 44 | "indent": [ 45 | "off" 46 | ], 47 | "@typescript-eslint/indent": [ 48 | "error", 49 | 2 50 | ], 51 | "quotes": [ 52 | "error", 53 | "single", 54 | { 55 | "avoidEscape": true 56 | } 57 | ], 58 | "comma-dangle": [ 59 | "error", 60 | "always-multiline" 61 | ], 62 | "comma-spacing": [ 63 | "error", 64 | { 65 | "before": false, 66 | "after": true 67 | } 68 | ], 69 | "no-multi-spaces": [ 70 | "error", 71 | { 72 | "ignoreEOLComments": false 73 | } 74 | ], 75 | "array-bracket-spacing": [ 76 | "error", 77 | "never" 78 | ], 79 | "array-bracket-newline": [ 80 | "error", 81 | "consistent" 82 | ], 83 | "object-curly-spacing": [ 84 | "error", 85 | "always" 86 | ], 87 | "object-curly-newline": [ 88 | "error", 89 | { 90 | "multiline": true, 91 | "consistent": true 92 | } 93 | ], 94 | "object-property-newline": [ 95 | "error", 96 | { 97 | "allowAllPropertiesOnSameLine": true 98 | } 99 | ], 100 | "keyword-spacing": [ 101 | "error" 102 | ], 103 | "brace-style": [ 104 | "error", 105 | "1tbs", 106 | { 107 | "allowSingleLine": true 108 | } 109 | ], 110 | "space-before-blocks": [ 111 | "error" 112 | ], 113 | "curly": [ 114 | "error", 115 | "multi-line", 116 | "consistent" 117 | ], 118 | "@typescript-eslint/member-delimiter-style": [ 119 | "error" 120 | ], 121 | "semi": [ 122 | "error", 123 | "always" 124 | ], 125 | "max-len": [ 126 | "error", 127 | { 128 | "code": 150, 129 | "ignoreUrls": true, 130 | "ignoreStrings": true, 131 | "ignoreTemplateLiterals": true, 132 | "ignoreComments": true, 133 | "ignoreRegExpLiterals": true 134 | } 135 | ], 136 | "quote-props": [ 137 | "error", 138 | "consistent-as-needed" 139 | ], 140 | "@typescript-eslint/no-require-imports": [ 141 | "error" 142 | ], 143 | "import/no-extraneous-dependencies": [ 144 | "error", 145 | { 146 | "devDependencies": [ 147 | "**/test/**", 148 | "**/build-tools/**" 149 | ], 150 | "optionalDependencies": false, 151 | "peerDependencies": true 152 | } 153 | ], 154 | "import/no-unresolved": [ 155 | "error" 156 | ], 157 | "import/order": [ 158 | "warn", 159 | { 160 | "groups": [ 161 | "builtin", 162 | "external" 163 | ], 164 | "alphabetize": { 165 | "order": "asc", 166 | "caseInsensitive": true 167 | } 168 | } 169 | ], 170 | "no-duplicate-imports": [ 171 | "error" 172 | ], 173 | "no-shadow": [ 174 | "off" 175 | ], 176 | "@typescript-eslint/no-shadow": [ 177 | "error" 178 | ], 179 | "key-spacing": [ 180 | "error" 181 | ], 182 | "no-multiple-empty-lines": [ 183 | "error" 184 | ], 185 | "@typescript-eslint/no-floating-promises": [ 186 | "error" 187 | ], 188 | "no-return-await": [ 189 | "off" 190 | ], 191 | "@typescript-eslint/return-await": [ 192 | "error" 193 | ], 194 | "no-trailing-spaces": [ 195 | "error" 196 | ], 197 | "dot-notation": [ 198 | "error" 199 | ], 200 | "no-bitwise": [ 201 | "error" 202 | ], 203 | "@typescript-eslint/member-ordering": [ 204 | "error", 205 | { 206 | "default": [ 207 | "public-static-field", 208 | "public-static-method", 209 | "protected-static-field", 210 | "protected-static-method", 211 | "private-static-field", 212 | "private-static-method", 213 | "field", 214 | "constructor", 215 | "method" 216 | ] 217 | } 218 | ] 219 | }, 220 | "overrides": [ 221 | { 222 | "files": [ 223 | ".projenrc.js" 224 | ], 225 | "rules": { 226 | "@typescript-eslint/no-require-imports": "off", 227 | "import/no-extraneous-dependencies": "off" 228 | } 229 | } 230 | ] 231 | } 232 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | *.snap linguist-generated 4 | /.eslintrc.json linguist-generated 5 | /.gitattributes linguist-generated 6 | /.github/pull_request_template.md linguist-generated 7 | /.github/workflows/auto-approve.yml linguist-generated 8 | /.github/workflows/build.yml linguist-generated 9 | /.github/workflows/pull-request-lint.yml linguist-generated 10 | /.github/workflows/release.yml linguist-generated 11 | /.github/workflows/stale.yml linguist-generated 12 | /.github/workflows/upgrade-main.yml linguist-generated 13 | /.gitignore linguist-generated 14 | /.mergify.yml linguist-generated 15 | /.npmignore linguist-generated 16 | /.projen/** linguist-generated 17 | /.projen/deps.json linguist-generated 18 | /.projen/files.json linguist-generated 19 | /.projen/tasks.json linguist-generated 20 | /LICENSE linguist-generated 21 | /package.json linguist-generated 22 | /tsconfig.dev.json linguist-generated 23 | /yarn.lock linguist-generated -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Fixes # -------------------------------------------------------------------------------- /.github/workflows/auto-approve.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | name: auto-approve 4 | on: 5 | pull_request_target: 6 | types: 7 | - labeled 8 | - opened 9 | - synchronize 10 | - reopened 11 | - ready_for_review 12 | jobs: 13 | approve: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | pull-requests: write 17 | if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && (github.event.pull_request.user.login == 'cdklabs-automation') 18 | steps: 19 | - uses: hmarr/auto-approve-action@v2.1.0 20 | with: 21 | github-token: ${{ secrets.GITHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | name: build 4 | on: 5 | pull_request: {} 6 | workflow_dispatch: {} 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: write 12 | outputs: 13 | self_mutation_happened: ${{ steps.self_mutation.outputs.self_mutation_happened }} 14 | env: 15 | CI: "true" 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v2 19 | with: 20 | ref: ${{ github.event.pull_request.head.ref }} 21 | repository: ${{ github.event.pull_request.head.repo.full_name }} 22 | - name: Install dependencies 23 | run: yarn install --check-files 24 | - name: build 25 | run: npx projen build 26 | - id: self_mutation 27 | name: Find mutations 28 | run: |- 29 | git add . 30 | git diff --staged --patch --exit-code > .repo.patch || echo "::set-output name=self_mutation_happened::true" 31 | - if: steps.self_mutation.outputs.self_mutation_happened 32 | name: Upload patch 33 | uses: actions/upload-artifact@v2 34 | with: 35 | name: .repo.patch 36 | path: .repo.patch 37 | - name: Fail build on mutation 38 | if: steps.self_mutation.outputs.self_mutation_happened 39 | run: |- 40 | echo "::error::Files were changed during build (see build log). If this was triggered from a fork, you will need to update your branch." 41 | cat .repo.patch 42 | exit 1 43 | - name: Upload artifact 44 | uses: actions/upload-artifact@v2.1.1 45 | with: 46 | name: build-artifact 47 | path: dist 48 | container: 49 | image: jsii/superchain:1-buster-slim-node14 50 | self-mutation: 51 | needs: build 52 | runs-on: ubuntu-latest 53 | permissions: 54 | contents: write 55 | if: always() && needs.build.outputs.self_mutation_happened && !(github.event.pull_request.head.repo.full_name != github.repository) 56 | steps: 57 | - name: Checkout 58 | uses: actions/checkout@v2 59 | with: 60 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 61 | ref: ${{ github.event.pull_request.head.ref }} 62 | repository: ${{ github.event.pull_request.head.repo.full_name }} 63 | - name: Download patch 64 | uses: actions/download-artifact@v2 65 | with: 66 | name: .repo.patch 67 | path: ${{ runner.temp }} 68 | - name: Apply patch 69 | run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp }}/.repo.patch || echo "Empty patch. Skipping."' 70 | - name: Set git identity 71 | run: |- 72 | git config user.name "github-actions" 73 | git config user.email "github-actions@github.com" 74 | - name: Push changes 75 | run: |2- 76 | git add . 77 | git commit -s -m "chore: self mutation" 78 | git push origin HEAD:${{ github.event.pull_request.head.ref }} 79 | package-js: 80 | needs: build 81 | runs-on: ubuntu-latest 82 | permissions: {} 83 | if: "! needs.build.outputs.self_mutation_happened" 84 | steps: 85 | - uses: actions/setup-node@v2 86 | with: 87 | node-version: 14.x 88 | - name: Download build artifacts 89 | uses: actions/download-artifact@v2 90 | with: 91 | name: build-artifact 92 | path: dist 93 | - name: Prepare Repository 94 | run: mv dist .repo 95 | - name: Install Dependencies 96 | run: cd .repo && yarn install --check-files --frozen-lockfile 97 | - name: Create js artifact 98 | run: cd .repo && npx projen package:js 99 | - name: Collect js Artifact 100 | run: mv .repo/dist dist 101 | package-java: 102 | needs: build 103 | runs-on: ubuntu-latest 104 | permissions: {} 105 | if: "! needs.build.outputs.self_mutation_happened" 106 | steps: 107 | - uses: actions/setup-java@v2 108 | with: 109 | distribution: temurin 110 | java-version: 11.x 111 | - uses: actions/setup-node@v2 112 | with: 113 | node-version: 14.x 114 | - name: Download build artifacts 115 | uses: actions/download-artifact@v2 116 | with: 117 | name: build-artifact 118 | path: dist 119 | - name: Prepare Repository 120 | run: mv dist .repo 121 | - name: Install Dependencies 122 | run: cd .repo && yarn install --check-files --frozen-lockfile 123 | - name: Create java artifact 124 | run: cd .repo && npx projen package:java 125 | - name: Collect java Artifact 126 | run: mv .repo/dist dist 127 | package-python: 128 | needs: build 129 | runs-on: ubuntu-latest 130 | permissions: {} 131 | if: "! needs.build.outputs.self_mutation_happened" 132 | steps: 133 | - uses: actions/setup-node@v2 134 | with: 135 | node-version: 14.x 136 | - uses: actions/setup-python@v2 137 | with: 138 | python-version: 3.x 139 | - name: Download build artifacts 140 | uses: actions/download-artifact@v2 141 | with: 142 | name: build-artifact 143 | path: dist 144 | - name: Prepare Repository 145 | run: mv dist .repo 146 | - name: Install Dependencies 147 | run: cd .repo && yarn install --check-files --frozen-lockfile 148 | - name: Create python artifact 149 | run: cd .repo && npx projen package:python 150 | - name: Collect python Artifact 151 | run: mv .repo/dist dist 152 | package-dotnet: 153 | needs: build 154 | runs-on: ubuntu-latest 155 | permissions: {} 156 | if: "! needs.build.outputs.self_mutation_happened" 157 | steps: 158 | - uses: actions/setup-node@v2 159 | with: 160 | node-version: 14.x 161 | - uses: actions/setup-dotnet@v1 162 | with: 163 | dotnet-version: 3.x 164 | - name: Download build artifacts 165 | uses: actions/download-artifact@v2 166 | with: 167 | name: build-artifact 168 | path: dist 169 | - name: Prepare Repository 170 | run: mv dist .repo 171 | - name: Install Dependencies 172 | run: cd .repo && yarn install --check-files --frozen-lockfile 173 | - name: Create dotnet artifact 174 | run: cd .repo && npx projen package:dotnet 175 | - name: Collect dotnet Artifact 176 | run: mv .repo/dist dist 177 | -------------------------------------------------------------------------------- /.github/workflows/pull-request-lint.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | name: pull-request-lint 4 | on: 5 | pull_request_target: 6 | types: 7 | - labeled 8 | - opened 9 | - synchronize 10 | - reopened 11 | - ready_for_review 12 | - edited 13 | jobs: 14 | validate: 15 | name: Validate PR title 16 | runs-on: ubuntu-latest 17 | permissions: 18 | pull-requests: write 19 | steps: 20 | - uses: amannn/action-semantic-pull-request@v3.4.6 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | with: 24 | types: |- 25 | feat 26 | fix 27 | chore 28 | requireScope: false 29 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | name: release 4 | on: 5 | push: 6 | branches: 7 | - main 8 | workflow_dispatch: {} 9 | jobs: 10 | release: 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write 14 | outputs: 15 | latest_commit: ${{ steps.git_remote.outputs.latest_commit }} 16 | env: 17 | CI: "true" 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v2 21 | with: 22 | fetch-depth: 0 23 | - name: Set git identity 24 | run: |- 25 | git config user.name "github-actions" 26 | git config user.email "github-actions@github.com" 27 | - name: Install dependencies 28 | run: yarn install --check-files --frozen-lockfile 29 | - name: release 30 | run: npx projen release 31 | - name: Check for new commits 32 | id: git_remote 33 | run: echo ::set-output name=latest_commit::"$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" 34 | - name: Upload artifact 35 | if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} 36 | uses: actions/upload-artifact@v2.1.1 37 | with: 38 | name: build-artifact 39 | path: dist 40 | container: 41 | image: jsii/superchain:1-buster-slim-node14 42 | release_github: 43 | name: Publish to GitHub Releases 44 | needs: release 45 | runs-on: ubuntu-latest 46 | permissions: 47 | contents: write 48 | if: needs.release.outputs.latest_commit == github.sha 49 | steps: 50 | - uses: actions/setup-node@v2 51 | with: 52 | node-version: 14.x 53 | - name: Download build artifacts 54 | uses: actions/download-artifact@v2 55 | with: 56 | name: build-artifact 57 | path: dist 58 | - name: Prepare Repository 59 | run: mv dist .repo 60 | - name: Collect GitHub Metadata 61 | run: mv .repo/dist dist 62 | - name: Release 63 | run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) --target $GITHUB_REF 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then cat $errout; exit $exitcode; fi 64 | env: 65 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 66 | GITHUB_REPOSITORY: ${{ github.repository }} 67 | GITHUB_REF: ${{ github.ref }} 68 | release_npm: 69 | name: Publish to npm 70 | needs: release 71 | runs-on: ubuntu-latest 72 | permissions: 73 | contents: read 74 | if: needs.release.outputs.latest_commit == github.sha 75 | steps: 76 | - uses: actions/setup-node@v2 77 | with: 78 | node-version: 14.x 79 | - name: Download build artifacts 80 | uses: actions/download-artifact@v2 81 | with: 82 | name: build-artifact 83 | path: dist 84 | - name: Prepare Repository 85 | run: mv dist .repo 86 | - name: Install Dependencies 87 | run: cd .repo && yarn install --check-files --frozen-lockfile 88 | - name: Create js artifact 89 | run: cd .repo && npx projen package:js 90 | - name: Collect js Artifact 91 | run: mv .repo/dist dist 92 | - name: Release 93 | run: npx -p publib@latest publib-npm 94 | env: 95 | NPM_DIST_TAG: latest 96 | NPM_REGISTRY: registry.npmjs.org 97 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 98 | release_maven: 99 | name: Publish to Maven Central 100 | needs: release 101 | runs-on: ubuntu-latest 102 | permissions: 103 | contents: read 104 | if: needs.release.outputs.latest_commit == github.sha 105 | steps: 106 | - uses: actions/setup-java@v2 107 | with: 108 | distribution: temurin 109 | java-version: 11.x 110 | - uses: actions/setup-node@v2 111 | with: 112 | node-version: 14.x 113 | - name: Download build artifacts 114 | uses: actions/download-artifact@v2 115 | with: 116 | name: build-artifact 117 | path: dist 118 | - name: Prepare Repository 119 | run: mv dist .repo 120 | - name: Install Dependencies 121 | run: cd .repo && yarn install --check-files --frozen-lockfile 122 | - name: Create java artifact 123 | run: cd .repo && npx projen package:java 124 | - name: Collect java Artifact 125 | run: mv .repo/dist dist 126 | - name: Release 127 | run: npx -p publib@latest publib-maven 128 | env: 129 | MAVEN_ENDPOINT: https://s01.oss.sonatype.org 130 | MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 131 | MAVEN_GPG_PRIVATE_KEY_PASSPHRASE: ${{ secrets.MAVEN_GPG_PRIVATE_KEY_PASSPHRASE }} 132 | MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} 133 | MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} 134 | MAVEN_STAGING_PROFILE_ID: ${{ secrets.MAVEN_STAGING_PROFILE_ID }} 135 | release_pypi: 136 | name: Publish to PyPI 137 | needs: release 138 | runs-on: ubuntu-latest 139 | permissions: 140 | contents: read 141 | if: needs.release.outputs.latest_commit == github.sha 142 | steps: 143 | - uses: actions/setup-node@v2 144 | with: 145 | node-version: 14.x 146 | - uses: actions/setup-python@v2 147 | with: 148 | python-version: 3.x 149 | - name: Download build artifacts 150 | uses: actions/download-artifact@v2 151 | with: 152 | name: build-artifact 153 | path: dist 154 | - name: Prepare Repository 155 | run: mv dist .repo 156 | - name: Install Dependencies 157 | run: cd .repo && yarn install --check-files --frozen-lockfile 158 | - name: Create python artifact 159 | run: cd .repo && npx projen package:python 160 | - name: Collect python Artifact 161 | run: mv .repo/dist dist 162 | - name: Release 163 | run: npx -p publib@latest publib-pypi 164 | env: 165 | TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} 166 | TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} 167 | release_nuget: 168 | name: Publish to NuGet Gallery 169 | needs: release 170 | runs-on: ubuntu-latest 171 | permissions: 172 | contents: read 173 | if: needs.release.outputs.latest_commit == github.sha 174 | steps: 175 | - uses: actions/setup-node@v2 176 | with: 177 | node-version: 14.x 178 | - uses: actions/setup-dotnet@v1 179 | with: 180 | dotnet-version: 3.x 181 | - name: Download build artifacts 182 | uses: actions/download-artifact@v2 183 | with: 184 | name: build-artifact 185 | path: dist 186 | - name: Prepare Repository 187 | run: mv dist .repo 188 | - name: Install Dependencies 189 | run: cd .repo && yarn install --check-files --frozen-lockfile 190 | - name: Create dotnet artifact 191 | run: cd .repo && npx projen package:dotnet 192 | - name: Collect dotnet Artifact 193 | run: mv .repo/dist dist 194 | - name: Release 195 | run: npx -p publib@latest publib-nuget 196 | env: 197 | NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} 198 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | name: stale 4 | on: 5 | schedule: 6 | - cron: 0 1 * * * 7 | workflow_dispatch: {} 8 | jobs: 9 | stale: 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | steps: 15 | - uses: actions/stale@v4 16 | with: 17 | days-before-stale: -1 18 | days-before-close: -1 19 | days-before-pr-stale: 14 20 | days-before-pr-close: 2 21 | stale-pr-message: This pull request is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label. 22 | close-pr-message: Closing this pull request as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label. 23 | stale-pr-label: stale 24 | exempt-pr-labels: backlog 25 | days-before-issue-stale: 60 26 | days-before-issue-close: 7 27 | stale-issue-message: This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label. 28 | close-issue-message: Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label. 29 | stale-issue-label: stale 30 | exempt-issue-labels: backlog 31 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-main.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | name: upgrade-main 4 | on: 5 | workflow_dispatch: {} 6 | schedule: 7 | - cron: 0 0 * * * 8 | jobs: 9 | upgrade: 10 | name: Upgrade 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: read 14 | outputs: 15 | patch_created: ${{ steps.create_patch.outputs.patch_created }} 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v2 19 | with: 20 | ref: main 21 | - name: Install dependencies 22 | run: yarn install --check-files --frozen-lockfile 23 | - name: Upgrade dependencies 24 | run: npx projen upgrade 25 | - id: create_patch 26 | name: Find mutations 27 | run: |- 28 | git add . 29 | git diff --staged --patch --exit-code > .repo.patch || echo "::set-output name=patch_created::true" 30 | - if: steps.create_patch.outputs.patch_created 31 | name: Upload patch 32 | uses: actions/upload-artifact@v2 33 | with: 34 | name: .repo.patch 35 | path: .repo.patch 36 | container: 37 | image: jsii/superchain:1-buster-slim-node14 38 | pr: 39 | name: Create Pull Request 40 | needs: upgrade 41 | runs-on: ubuntu-latest 42 | permissions: 43 | contents: write 44 | pull-requests: write 45 | if: ${{ needs.upgrade.outputs.patch_created }} 46 | steps: 47 | - name: Checkout 48 | uses: actions/checkout@v2 49 | with: 50 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 51 | ref: main 52 | - name: Download patch 53 | uses: actions/download-artifact@v2 54 | with: 55 | name: .repo.patch 56 | path: ${{ runner.temp }} 57 | - name: Apply patch 58 | run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp }}/.repo.patch || echo "Empty patch. Skipping."' 59 | - name: Set git identity 60 | run: |- 61 | git config user.name "github-actions" 62 | git config user.email "github-actions@github.com" 63 | - name: Create Pull Request 64 | id: create-pr 65 | uses: peter-evans/create-pull-request@v3 66 | with: 67 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 68 | commit-message: |- 69 | chore(deps): upgrade dependencies 70 | 71 | Upgrades project dependencies. See details in [workflow run]. 72 | 73 | [Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 74 | 75 | ------ 76 | 77 | *Automatically created by projen via the "upgrade-main" workflow* 78 | branch: github-actions/upgrade-main 79 | title: "chore(deps): upgrade dependencies" 80 | labels: auto-approve 81 | body: |- 82 | Upgrades project dependencies. See details in [workflow run]. 83 | 84 | [Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 85 | 86 | ------ 87 | 88 | *Automatically created by projen via the "upgrade-main" workflow* 89 | author: github-actions 90 | committer: github-actions 91 | signoff: true 92 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | !/.gitattributes 3 | !/.projen/tasks.json 4 | !/.projen/deps.json 5 | !/.projen/files.json 6 | !/.github/workflows/pull-request-lint.yml 7 | !/.github/workflows/auto-approve.yml 8 | !/.github/workflows/stale.yml 9 | !/package.json 10 | !/LICENSE 11 | !/.npmignore 12 | logs 13 | *.log 14 | npm-debug.log* 15 | yarn-debug.log* 16 | yarn-error.log* 17 | lerna-debug.log* 18 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | lib-cov 24 | coverage 25 | *.lcov 26 | .nyc_output 27 | build/Release 28 | node_modules/ 29 | jspm_packages/ 30 | *.tsbuildinfo 31 | .eslintcache 32 | *.tgz 33 | .yarn-integrity 34 | .cache 35 | !/.projenrc.js 36 | /test-reports/ 37 | junit.xml 38 | /coverage/ 39 | !/.github/workflows/build.yml 40 | /dist/changelog.md 41 | /dist/version.txt 42 | !/.github/workflows/release.yml 43 | !/.mergify.yml 44 | !/.github/pull_request_template.md 45 | !/test/ 46 | !/tsconfig.dev.json 47 | !/src/ 48 | /lib 49 | /dist/ 50 | !/.eslintrc.json 51 | .jsii 52 | tsconfig.json 53 | !/.github/workflows/upgrade-main.yml 54 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | 3 | queue_rules: 4 | - name: default 5 | conditions: 6 | - "#approved-reviews-by>=1" 7 | - -label~=(do-not-merge) 8 | - status-success=build 9 | - status-success=package-js 10 | - status-success=package-java 11 | - status-success=package-python 12 | - status-success=package-dotnet 13 | pull_request_rules: 14 | - name: Automatic merge on approval and successful build 15 | actions: 16 | delete_head_branch: {} 17 | queue: 18 | method: squash 19 | name: default 20 | commit_message_template: |- 21 | {{ title }} (#{{ number }}) 22 | 23 | {{ body }} 24 | conditions: 25 | - "#approved-reviews-by>=1" 26 | - -label~=(do-not-merge) 27 | - status-success=build 28 | - status-success=package-js 29 | - status-success=package-java 30 | - status-success=package-python 31 | - status-success=package-dotnet 32 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". 2 | /.projen/ 3 | /test-reports/ 4 | junit.xml 5 | /coverage/ 6 | /dist/changelog.md 7 | /dist/version.txt 8 | /.mergify.yml 9 | /test/ 10 | /tsconfig.dev.json 11 | /src/ 12 | !/lib/ 13 | !/lib/**/*.js 14 | !/lib/**/*.d.ts 15 | dist 16 | /tsconfig.json 17 | /.github/ 18 | /.vscode/ 19 | /.idea/ 20 | /.projenrc.js 21 | tsconfig.tsbuildinfo 22 | /.eslintrc.json 23 | !.jsii 24 | -------------------------------------------------------------------------------- /.projen/deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | { 4 | "name": "@types/aws-lambda", 5 | "type": "build" 6 | }, 7 | { 8 | "name": "@types/jest", 9 | "type": "build" 10 | }, 11 | { 12 | "name": "@types/node", 13 | "version": "^12", 14 | "type": "build" 15 | }, 16 | { 17 | "name": "@typescript-eslint/eslint-plugin", 18 | "version": "^5", 19 | "type": "build" 20 | }, 21 | { 22 | "name": "@typescript-eslint/parser", 23 | "version": "^5", 24 | "type": "build" 25 | }, 26 | { 27 | "name": "aws-cdk-lib", 28 | "version": "2.0.0", 29 | "type": "build" 30 | }, 31 | { 32 | "name": "aws-sdk", 33 | "type": "build" 34 | }, 35 | { 36 | "name": "constructs", 37 | "version": "10.0.5", 38 | "type": "build" 39 | }, 40 | { 41 | "name": "eslint-import-resolver-node", 42 | "type": "build" 43 | }, 44 | { 45 | "name": "eslint-import-resolver-typescript", 46 | "type": "build" 47 | }, 48 | { 49 | "name": "eslint-plugin-import", 50 | "type": "build" 51 | }, 52 | { 53 | "name": "eslint", 54 | "version": "^8", 55 | "type": "build" 56 | }, 57 | { 58 | "name": "jest", 59 | "type": "build" 60 | }, 61 | { 62 | "name": "jest-junit", 63 | "version": "^13", 64 | "type": "build" 65 | }, 66 | { 67 | "name": "jsii", 68 | "type": "build" 69 | }, 70 | { 71 | "name": "jsii-diff", 72 | "type": "build" 73 | }, 74 | { 75 | "name": "json-schema", 76 | "type": "build" 77 | }, 78 | { 79 | "name": "npm-check-updates", 80 | "version": "^12", 81 | "type": "build" 82 | }, 83 | { 84 | "name": "projen", 85 | "type": "build" 86 | }, 87 | { 88 | "name": "standard-version", 89 | "version": "^9", 90 | "type": "build" 91 | }, 92 | { 93 | "name": "ts-jest", 94 | "version": "^26", 95 | "type": "build" 96 | }, 97 | { 98 | "name": "typescript", 99 | "type": "build" 100 | }, 101 | { 102 | "name": "aws-cdk-lib", 103 | "version": "^2.0.0", 104 | "type": "peer" 105 | }, 106 | { 107 | "name": "constructs", 108 | "version": "^10.0.5", 109 | "type": "peer" 110 | } 111 | ], 112 | "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." 113 | } 114 | -------------------------------------------------------------------------------- /.projen/files.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | ".eslintrc.json", 4 | ".gitattributes", 5 | ".github/pull_request_template.md", 6 | ".github/workflows/auto-approve.yml", 7 | ".github/workflows/build.yml", 8 | ".github/workflows/pull-request-lint.yml", 9 | ".github/workflows/release.yml", 10 | ".github/workflows/stale.yml", 11 | ".github/workflows/upgrade-main.yml", 12 | ".gitignore", 13 | ".mergify.yml", 14 | ".projen/deps.json", 15 | ".projen/files.json", 16 | ".projen/tasks.json", 17 | "LICENSE", 18 | "tsconfig.dev.json" 19 | ], 20 | "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." 21 | } 22 | -------------------------------------------------------------------------------- /.projen/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": { 3 | "build": { 4 | "name": "build", 5 | "description": "Full release build", 6 | "steps": [ 7 | { 8 | "spawn": "default" 9 | }, 10 | { 11 | "spawn": "pre-compile" 12 | }, 13 | { 14 | "spawn": "compile" 15 | }, 16 | { 17 | "spawn": "post-compile" 18 | }, 19 | { 20 | "spawn": "test" 21 | }, 22 | { 23 | "spawn": "package" 24 | } 25 | ] 26 | }, 27 | "bump": { 28 | "name": "bump", 29 | "description": "Bumps version based on latest git tag and generates a changelog entry", 30 | "env": { 31 | "OUTFILE": "package.json", 32 | "CHANGELOG": "dist/changelog.md", 33 | "BUMPFILE": "dist/version.txt", 34 | "RELEASETAG": "dist/releasetag.txt" 35 | }, 36 | "steps": [ 37 | { 38 | "builtin": "release/bump-version" 39 | } 40 | ], 41 | "condition": "! git log --oneline -1 | grep -q \"chore(release):\"" 42 | }, 43 | "clobber": { 44 | "name": "clobber", 45 | "description": "hard resets to HEAD of origin and cleans the local repo", 46 | "env": { 47 | "BRANCH": "$(git branch --show-current)" 48 | }, 49 | "steps": [ 50 | { 51 | "exec": "git checkout -b scratch", 52 | "name": "save current HEAD in \"scratch\" branch" 53 | }, 54 | { 55 | "exec": "git checkout $BRANCH" 56 | }, 57 | { 58 | "exec": "git fetch origin", 59 | "name": "fetch latest changes from origin" 60 | }, 61 | { 62 | "exec": "git reset --hard origin/$BRANCH", 63 | "name": "hard reset to origin commit" 64 | }, 65 | { 66 | "exec": "git clean -fdx", 67 | "name": "clean all untracked files" 68 | }, 69 | { 70 | "say": "ready to rock! (unpushed commits are under the \"scratch\" branch)" 71 | } 72 | ], 73 | "condition": "git diff --exit-code > /dev/null" 74 | }, 75 | "compat": { 76 | "name": "compat", 77 | "description": "Perform API compatibility check against latest version", 78 | "steps": [ 79 | { 80 | "exec": "jsii-diff npm:$(node -p \"require('./package.json').name\") -k --ignore-file .compatignore || (echo \"\nUNEXPECTED BREAKING CHANGES: add keys such as 'removed:constructs.Node.of' to .compatignore to skip.\n\" && exit 1)" 81 | } 82 | ] 83 | }, 84 | "compile": { 85 | "name": "compile", 86 | "description": "Only compile", 87 | "steps": [ 88 | { 89 | "exec": "jsii --silence-warnings=reserved-word --no-fix-peer-dependencies" 90 | } 91 | ] 92 | }, 93 | "default": { 94 | "name": "default", 95 | "description": "Synthesize project files", 96 | "steps": [ 97 | { 98 | "exec": "node .projenrc.js" 99 | } 100 | ] 101 | }, 102 | "eject": { 103 | "name": "eject", 104 | "description": "Remove projen from the project", 105 | "env": { 106 | "PROJEN_EJECTING": "true" 107 | }, 108 | "steps": [ 109 | { 110 | "spawn": "default" 111 | } 112 | ] 113 | }, 114 | "eslint": { 115 | "name": "eslint", 116 | "description": "Runs eslint against the codebase", 117 | "steps": [ 118 | { 119 | "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern src test build-tools .projenrc.js" 120 | } 121 | ] 122 | }, 123 | "package": { 124 | "name": "package", 125 | "description": "Creates the distribution package", 126 | "steps": [ 127 | { 128 | "exec": "if [ ! -z ${CI} ]; then mkdir -p dist && rsync -a . dist --exclude .git --exclude node_modules; else npx projen package-all; fi" 129 | } 130 | ] 131 | }, 132 | "package-all": { 133 | "name": "package-all", 134 | "description": "Packages artifacts for all target languages", 135 | "steps": [ 136 | { 137 | "spawn": "package:js" 138 | }, 139 | { 140 | "spawn": "package:java" 141 | }, 142 | { 143 | "spawn": "package:python" 144 | }, 145 | { 146 | "spawn": "package:dotnet" 147 | } 148 | ] 149 | }, 150 | "package:dotnet": { 151 | "name": "package:dotnet", 152 | "description": "Create dotnet language bindings", 153 | "steps": [ 154 | { 155 | "exec": "jsii_version=$(node -p \"JSON.parse(fs.readFileSync('.jsii')).jsiiVersion.split(' ')[0]\")" 156 | }, 157 | { 158 | "exec": "npx jsii-pacmak@$jsii_version -v --target dotnet" 159 | } 160 | ] 161 | }, 162 | "package:java": { 163 | "name": "package:java", 164 | "description": "Create java language bindings", 165 | "steps": [ 166 | { 167 | "exec": "jsii_version=$(node -p \"JSON.parse(fs.readFileSync('.jsii')).jsiiVersion.split(' ')[0]\")" 168 | }, 169 | { 170 | "exec": "npx jsii-pacmak@$jsii_version -v --target java" 171 | } 172 | ] 173 | }, 174 | "package:js": { 175 | "name": "package:js", 176 | "description": "Create js language bindings", 177 | "steps": [ 178 | { 179 | "exec": "jsii_version=$(node -p \"JSON.parse(fs.readFileSync('.jsii')).jsiiVersion.split(' ')[0]\")" 180 | }, 181 | { 182 | "exec": "npx jsii-pacmak@$jsii_version -v --target js" 183 | } 184 | ] 185 | }, 186 | "package:python": { 187 | "name": "package:python", 188 | "description": "Create python language bindings", 189 | "steps": [ 190 | { 191 | "exec": "jsii_version=$(node -p \"JSON.parse(fs.readFileSync('.jsii')).jsiiVersion.split(' ')[0]\")" 192 | }, 193 | { 194 | "exec": "npx jsii-pacmak@$jsii_version -v --target python" 195 | } 196 | ] 197 | }, 198 | "post-compile": { 199 | "name": "post-compile", 200 | "description": "Runs after successful compilation" 201 | }, 202 | "post-upgrade": { 203 | "name": "post-upgrade", 204 | "description": "Runs after upgrading dependencies" 205 | }, 206 | "pre-compile": { 207 | "name": "pre-compile", 208 | "description": "Prepare the project for compilation" 209 | }, 210 | "release": { 211 | "name": "release", 212 | "description": "Prepare a release from \"main\" branch", 213 | "env": { 214 | "RELEASE": "true" 215 | }, 216 | "steps": [ 217 | { 218 | "exec": "rm -fr dist" 219 | }, 220 | { 221 | "spawn": "bump" 222 | }, 223 | { 224 | "spawn": "build" 225 | }, 226 | { 227 | "spawn": "unbump" 228 | }, 229 | { 230 | "exec": "git diff --ignore-space-at-eol --exit-code" 231 | } 232 | ] 233 | }, 234 | "test": { 235 | "name": "test", 236 | "description": "Run tests", 237 | "steps": [ 238 | { 239 | "exec": "jest --passWithNoTests --all --updateSnapshot" 240 | }, 241 | { 242 | "spawn": "eslint" 243 | } 244 | ] 245 | }, 246 | "test:update": { 247 | "name": "test:update", 248 | "description": "Update jest snapshots", 249 | "steps": [ 250 | { 251 | "exec": "jest --updateSnapshot" 252 | } 253 | ] 254 | }, 255 | "test:watch": { 256 | "name": "test:watch", 257 | "description": "Run jest in watch mode", 258 | "steps": [ 259 | { 260 | "exec": "jest --watch" 261 | } 262 | ] 263 | }, 264 | "unbump": { 265 | "name": "unbump", 266 | "description": "Restores version to 0.0.0", 267 | "env": { 268 | "OUTFILE": "package.json", 269 | "CHANGELOG": "dist/changelog.md", 270 | "BUMPFILE": "dist/version.txt", 271 | "RELEASETAG": "dist/releasetag.txt" 272 | }, 273 | "steps": [ 274 | { 275 | "builtin": "release/reset-version" 276 | } 277 | ] 278 | }, 279 | "upgrade": { 280 | "name": "upgrade", 281 | "description": "upgrade dependencies", 282 | "env": { 283 | "CI": "0" 284 | }, 285 | "steps": [ 286 | { 287 | "exec": "npm-check-updates --dep dev --upgrade --target=minor" 288 | }, 289 | { 290 | "exec": "npm-check-updates --dep optional --upgrade --target=minor" 291 | }, 292 | { 293 | "exec": "npm-check-updates --dep peer --upgrade --target=minor" 294 | }, 295 | { 296 | "exec": "npm-check-updates --dep prod --upgrade --target=minor" 297 | }, 298 | { 299 | "exec": "npm-check-updates --dep bundle --upgrade --target=minor" 300 | }, 301 | { 302 | "exec": "yarn install --check-files" 303 | }, 304 | { 305 | "exec": "yarn upgrade" 306 | }, 307 | { 308 | "exec": "npx projen" 309 | }, 310 | { 311 | "spawn": "post-upgrade" 312 | } 313 | ] 314 | }, 315 | "watch": { 316 | "name": "watch", 317 | "description": "Watch & compile in the background", 318 | "steps": [ 319 | { 320 | "exec": "jsii -w --silence-warnings=reserved-word --no-fix-peer-dependencies" 321 | } 322 | ] 323 | } 324 | }, 325 | "env": { 326 | "PATH": "$(npx -c \"node -e \\\"console.log(process.env.PATH)\\\"\")" 327 | }, 328 | "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." 329 | } 330 | -------------------------------------------------------------------------------- /.projenrc.js: -------------------------------------------------------------------------------- 1 | const { awscdk, DependencyType } = require('projen'); 2 | 3 | const project = new awscdk.AwsCdkConstructLibrary({ 4 | author: 'Amazon Web Services', 5 | authorAddress: 'aws-cdk-team@amazon.com', 6 | description: 'Execute AWS Lambda handlers during deployments of AWS CDK stacks', 7 | cdkVersion: '2.0.0', 8 | defaultReleaseBranch: 'main', 9 | name: 'cdk-triggers', 10 | projenUpgradeSecret: 'PROJEN_GITHUB_TOKEN', 11 | repositoryUrl: 'https://github.com/awslabs/cdk-triggers.git', 12 | stability: 'deprecated', 13 | docgen: false, // jsii-docgen fails if a package is deprecated 14 | 15 | devDeps: [ 16 | 'aws-sdk', 17 | '@types/aws-lambda', 18 | ], 19 | 20 | publishToPypi: { 21 | distName: 'cdk-triggers', 22 | module: 'cdk_triggers', 23 | }, 24 | 25 | publishToNuget: { 26 | packageId: 'Cdklabs.CdkTriggers', 27 | dotNetNamespace: 'Cdklabs.CdkTriggers', 28 | }, 29 | 30 | publishToMaven: { 31 | mavenGroupId: 'io.github.cdklabs', 32 | javaPackage: 'io.github.cdklabs.cdktriggers', 33 | mavenArtifactId: 'cdktriggers', 34 | mavenEndpoint: 'https://s01.oss.sonatype.org', 35 | }, 36 | 37 | autoApproveOptions: { 38 | allowedUsernames: ['cdklabs-automation'], 39 | secret: 'GITHUB_TOKEN', 40 | }, 41 | 42 | autoApproveUpgrades: true, 43 | }); 44 | 45 | project.deps.addDependency('ts-jest@^26', DependencyType.BUILD); 46 | 47 | 48 | project.synth(); 49 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CDK Triggers 2 | 3 | ## This project has graduated from incubation and is now part of the AWS CDK. It is no longer maintained in this repository 4 | 5 | Please refer to the official AWS CDK documentation: 6 | 7 | - [Documentation](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.triggers-readme.html) 8 | - [Source Code](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/triggers) 9 | 10 | ## Usage 11 | 12 | ```ts 13 | import * as lambda from 'aws-cdk-lib/aws-lambda'; 14 | import * as triggers from 'aws-cdk-lib/triggers'; 15 | import { Stack } from 'aws-cdk-lib'; 16 | import { Construct } from 'constructs'; 17 | 18 | declare const stack: Stack; 19 | declare const resource1: Construct; 20 | declare const resource2: Construct; 21 | 22 | new triggers.TriggerFunction(stack, 'MyTrigger', { 23 | runtime: lambda.Runtime.NODEJS_12_X, 24 | handler: 'index.handler', 25 | code: lambda.Code.fromAsset(__dirname + '/my-trigger'), 26 | executeAfter: [resource1, resource2], 27 | }); 28 | ``` 29 | 30 | ## Security 31 | 32 | See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. 33 | 34 | ## License 35 | 36 | This project is licensed under the Apache-2.0 License. 37 | -------------------------------------------------------------------------------- /lambda/.gitignore: -------------------------------------------------------------------------------- 1 | __entrypoint__.js 2 | -------------------------------------------------------------------------------- /lambda/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | 3 | exports.handler = async function(event) { 4 | console.log({ event }); 5 | 6 | if (event.RequestType === 'Delete') { 7 | console.log('not calling trigger on DELETE'); 8 | return; 9 | } 10 | 11 | const handlerArn = event.ResourceProperties.HandlerArn; 12 | if (!handlerArn) { 13 | throw new Error('The "HandlerArn" property is required'); 14 | } 15 | 16 | const lambda = new AWS.Lambda(); 17 | const invokeRequest = { FunctionName: handlerArn }; 18 | console.log({ invokeRequest }); 19 | const invokeResponse = await lambda.invoke(invokeRequest).promise(); 20 | console.log({ invokeResponse }); 21 | 22 | if (invokeResponse.StatusCode !== 200) { 23 | throw new Error(`Invoke failed with status code ${invokeResponse.StatusCode}`); 24 | } 25 | 26 | // if the lambda function throws an error, parse the error message and fail 27 | if (invokeResponse.FunctionError) { 28 | throw new Error(parseError(invokeResponse.Payload?.toString())); 29 | } 30 | } 31 | 32 | /** 33 | * Parse the error message from the lambda function. 34 | */ 35 | function parseError(payload) { 36 | if (!payload) { return 'unknown handler error'; } 37 | try { 38 | const error = JSON.parse(payload); 39 | const concat = [error.errorMessage, error.trace].filter(x => x).join('\n'); 40 | return concat.length > 0 ? concat : payload; 41 | } catch (e) { 42 | // fall back to just returning the payload 43 | return payload; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk-triggers", 3 | "description": "Execute AWS Lambda handlers during deployments of AWS CDK stacks", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/awslabs/cdk-triggers.git" 7 | }, 8 | "scripts": { 9 | "build": "npx projen build", 10 | "bump": "npx projen bump", 11 | "clobber": "npx projen clobber", 12 | "compat": "npx projen compat", 13 | "compile": "npx projen compile", 14 | "default": "npx projen default", 15 | "eject": "npx projen eject", 16 | "eslint": "npx projen eslint", 17 | "package": "npx projen package", 18 | "package-all": "npx projen package-all", 19 | "package:dotnet": "npx projen package:dotnet", 20 | "package:java": "npx projen package:java", 21 | "package:js": "npx projen package:js", 22 | "package:python": "npx projen package:python", 23 | "post-compile": "npx projen post-compile", 24 | "post-upgrade": "npx projen post-upgrade", 25 | "pre-compile": "npx projen pre-compile", 26 | "release": "npx projen release", 27 | "test": "npx projen test", 28 | "test:update": "npx projen test:update", 29 | "test:watch": "npx projen test:watch", 30 | "unbump": "npx projen unbump", 31 | "upgrade": "npx projen upgrade", 32 | "watch": "npx projen watch", 33 | "projen": "npx projen" 34 | }, 35 | "author": { 36 | "name": "Amazon Web Services", 37 | "email": "aws-cdk-team@amazon.com", 38 | "organization": false 39 | }, 40 | "devDependencies": { 41 | "@types/aws-lambda": "^8.10.92", 42 | "@types/jest": "^26.0.24", 43 | "@types/node": "^12", 44 | "@typescript-eslint/eslint-plugin": "^5", 45 | "@typescript-eslint/parser": "^5", 46 | "aws-cdk-lib": "2.0.0", 47 | "aws-sdk": "^2.1079.0", 48 | "constructs": "10.0.5", 49 | "eslint": "^8", 50 | "eslint-import-resolver-node": "^0.3.6", 51 | "eslint-import-resolver-typescript": "^2.5.0", 52 | "eslint-plugin-import": "^2.25.4", 53 | "jest": "^26.6.3", 54 | "jest-junit": "^13", 55 | "jsii": "^1.54.0", 56 | "jsii-diff": "^1.54.0", 57 | "json-schema": "^0.4.0", 58 | "npm-check-updates": "^12", 59 | "projen": "^0.52.43", 60 | "standard-version": "^9", 61 | "ts-jest": "^26", 62 | "typescript": "^4.5.5" 63 | }, 64 | "peerDependencies": { 65 | "aws-cdk-lib": "^2.0.0", 66 | "constructs": "^10.0.5" 67 | }, 68 | "keywords": [ 69 | "cdk" 70 | ], 71 | "main": "lib/index.js", 72 | "license": "Apache-2.0", 73 | "version": "0.0.0", 74 | "jest": { 75 | "testMatch": [ 76 | "/src/**/__tests__/**/*.ts?(x)", 77 | "/(test|src)/**/?(*.)+(spec|test).ts?(x)" 78 | ], 79 | "clearMocks": true, 80 | "collectCoverage": true, 81 | "coverageReporters": [ 82 | "json", 83 | "lcov", 84 | "clover", 85 | "cobertura", 86 | "text" 87 | ], 88 | "coverageDirectory": "coverage", 89 | "coveragePathIgnorePatterns": [ 90 | "/node_modules/" 91 | ], 92 | "testPathIgnorePatterns": [ 93 | "/node_modules/" 94 | ], 95 | "watchPathIgnorePatterns": [ 96 | "/node_modules/" 97 | ], 98 | "reporters": [ 99 | "default", 100 | [ 101 | "jest-junit", 102 | { 103 | "outputDirectory": "test-reports" 104 | } 105 | ] 106 | ], 107 | "preset": "ts-jest", 108 | "globals": { 109 | "ts-jest": { 110 | "tsconfig": "tsconfig.dev.json" 111 | } 112 | } 113 | }, 114 | "types": "lib/index.d.ts", 115 | "stability": "deprecated", 116 | "deprecated": true, 117 | "jsii": { 118 | "outdir": "dist", 119 | "targets": { 120 | "java": { 121 | "package": "io.github.cdklabs.cdktriggers", 122 | "maven": { 123 | "groupId": "io.github.cdklabs", 124 | "artifactId": "cdktriggers" 125 | } 126 | }, 127 | "python": { 128 | "distName": "cdk-triggers", 129 | "module": "cdk_triggers" 130 | }, 131 | "dotnet": { 132 | "namespace": "Cdklabs.CdkTriggers", 133 | "packageId": "Cdklabs.CdkTriggers" 134 | } 135 | }, 136 | "tsc": { 137 | "outDir": "lib", 138 | "rootDir": "src" 139 | } 140 | }, 141 | "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." 142 | } -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './triggers'; -------------------------------------------------------------------------------- /src/triggers.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path'; 2 | import { CustomResource, CustomResourceProvider, CustomResourceProviderRuntime } from 'aws-cdk-lib'; 3 | import * as lambda from 'aws-cdk-lib/aws-lambda'; 4 | import { Construct } from 'constructs'; 5 | 6 | export interface AfterCreateProps { 7 | /** 8 | * Resources to trigger on. Resources can come from any stack in the app. 9 | * 10 | * @default [] Run the trigger at any time during stack deployment. 11 | */ 12 | readonly resources?: Construct[]; 13 | 14 | /** 15 | * The handler to execute once after all the resources are created. 16 | * 17 | * The trigger will be executed every time the handler changes (code or 18 | * configuration). 19 | */ 20 | readonly handler: lambda.Function; 21 | } 22 | 23 | export class AfterCreate extends Construct { 24 | constructor(scope: Construct, id: string, props: AfterCreateProps) { 25 | super(scope, id); 26 | 27 | const provider = CustomResourceProvider.getOrCreateProvider(this, 'AWSCDK.TriggerCustomResourceProvider', { 28 | runtime: CustomResourceProviderRuntime.NODEJS_14_X, 29 | codeDirectory: join(__dirname, '..', 'lambda'), 30 | policyStatements: [ 31 | { 32 | Effect: 'Allow', 33 | Action: ['lambda:InvokeFunction'], 34 | Resource: ['*'], // TODO? 35 | }, 36 | ], 37 | }); 38 | 39 | const resource = new CustomResource(this, 'Resource', { 40 | resourceType: 'Custom::Trigger', 41 | serviceToken: provider.serviceToken, 42 | properties: { 43 | // we use 'currentVersion' because a new version is created every time the 44 | // handler changes (either code or configuration). this will have the effect 45 | // that the trigger will be executed every time the handler is changed. 46 | HandlerArn: props.handler.currentVersion.functionArn, 47 | }, 48 | }); 49 | 50 | // add a dependency between our resource and the resources we want to invoke 51 | // after. 52 | resource.node.addDependency(...props.resources ?? []); 53 | } 54 | } -------------------------------------------------------------------------------- /test/__snapshots__/trigger.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`minimal usage 1`] = ` 4 | Object { 5 | "Parameters": Object { 6 | "BootstrapVersion": Object { 7 | "Default": "/cdk-bootstrap/hnb659fds/version", 8 | "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", 9 | "Type": "AWS::SSM::Parameter::Value", 10 | }, 11 | }, 12 | "Resources": Object { 13 | "AWSCDKTriggerCustomResourceProviderCustomResourceProviderHandler97BECD91": Object { 14 | "DependsOn": Array [ 15 | "AWSCDKTriggerCustomResourceProviderCustomResourceProviderRoleE18FAF0A", 16 | ], 17 | "Properties": Object { 18 | "Code": Object { 19 | "S3Bucket": Object { 20 | "Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}", 21 | }, 22 | "S3Key": "37c94ea3bc7bb6623c24299284372b368af0b6f986835e1b6ebc1fac865dfc7a.zip", 23 | }, 24 | "Handler": "__entrypoint__.handler", 25 | "MemorySize": 128, 26 | "Role": Object { 27 | "Fn::GetAtt": Array [ 28 | "AWSCDKTriggerCustomResourceProviderCustomResourceProviderRoleE18FAF0A", 29 | "Arn", 30 | ], 31 | }, 32 | "Runtime": "nodejs14.x", 33 | "Timeout": 900, 34 | }, 35 | "Type": "AWS::Lambda::Function", 36 | }, 37 | "AWSCDKTriggerCustomResourceProviderCustomResourceProviderRoleE18FAF0A": Object { 38 | "Properties": Object { 39 | "AssumeRolePolicyDocument": Object { 40 | "Statement": Array [ 41 | Object { 42 | "Action": "sts:AssumeRole", 43 | "Effect": "Allow", 44 | "Principal": Object { 45 | "Service": "lambda.amazonaws.com", 46 | }, 47 | }, 48 | ], 49 | "Version": "2012-10-17", 50 | }, 51 | "ManagedPolicyArns": Array [ 52 | Object { 53 | "Fn::Sub": "arn:\${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", 54 | }, 55 | ], 56 | "Policies": Array [ 57 | Object { 58 | "PolicyDocument": Object { 59 | "Statement": Array [ 60 | Object { 61 | "Action": Array [ 62 | "lambda:InvokeFunction", 63 | ], 64 | "Effect": "Allow", 65 | "Resource": Array [ 66 | "*", 67 | ], 68 | }, 69 | ], 70 | "Version": "2012-10-17", 71 | }, 72 | "PolicyName": "Inline", 73 | }, 74 | ], 75 | }, 76 | "Type": "AWS::IAM::Role", 77 | }, 78 | "MyTopic86869434": Object { 79 | "Type": "AWS::SNS::Topic", 80 | }, 81 | "MyTriggerB6CCCACE": Object { 82 | "DeletionPolicy": "Delete", 83 | "DependsOn": Array [ 84 | "MyTopic86869434", 85 | ], 86 | "Properties": Object { 87 | "HandlerArn": Object { 88 | "Ref": "MyTriggerHandlerCurrentVersionC0B6BBD40f3abd954eb77fda7e548d681c7fa667", 89 | }, 90 | "ServiceToken": Object { 91 | "Fn::GetAtt": Array [ 92 | "AWSCDKTriggerCustomResourceProviderCustomResourceProviderHandler97BECD91", 93 | "Arn", 94 | ], 95 | }, 96 | }, 97 | "Type": "Custom::Trigger", 98 | "UpdateReplacePolicy": "Delete", 99 | }, 100 | "MyTriggerHandlerCurrentVersionC0B6BBD40f3abd954eb77fda7e548d681c7fa667": Object { 101 | "Properties": Object { 102 | "FunctionName": Object { 103 | "Ref": "MyTriggerHandlerD6B1FF23", 104 | }, 105 | }, 106 | "Type": "AWS::Lambda::Version", 107 | }, 108 | "MyTriggerHandlerD6B1FF23": Object { 109 | "DependsOn": Array [ 110 | "MyTriggerHandlerServiceRoleFC0CFFAB", 111 | ], 112 | "Properties": Object { 113 | "Code": Object { 114 | "ZipFile": "zoo", 115 | }, 116 | "Handler": "index.handler", 117 | "Role": Object { 118 | "Fn::GetAtt": Array [ 119 | "MyTriggerHandlerServiceRoleFC0CFFAB", 120 | "Arn", 121 | ], 122 | }, 123 | "Runtime": "nodejs12.x", 124 | }, 125 | "Type": "AWS::Lambda::Function", 126 | }, 127 | "MyTriggerHandlerServiceRoleFC0CFFAB": Object { 128 | "Properties": Object { 129 | "AssumeRolePolicyDocument": Object { 130 | "Statement": Array [ 131 | Object { 132 | "Action": "sts:AssumeRole", 133 | "Effect": "Allow", 134 | "Principal": Object { 135 | "Service": "lambda.amazonaws.com", 136 | }, 137 | }, 138 | ], 139 | "Version": "2012-10-17", 140 | }, 141 | "ManagedPolicyArns": Array [ 142 | Object { 143 | "Fn::Join": Array [ 144 | "", 145 | Array [ 146 | "arn:", 147 | Object { 148 | "Ref": "AWS::Partition", 149 | }, 150 | ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", 151 | ], 152 | ], 153 | }, 154 | ], 155 | }, 156 | "Type": "AWS::IAM::Role", 157 | }, 158 | }, 159 | "Rules": Object { 160 | "CheckBootstrapVersion": Object { 161 | "Assertions": Array [ 162 | Object { 163 | "Assert": Object { 164 | "Fn::Not": Array [ 165 | Object { 166 | "Fn::Contains": Array [ 167 | Array [ 168 | "1", 169 | "2", 170 | "3", 171 | "4", 172 | "5", 173 | ], 174 | Object { 175 | "Ref": "BootstrapVersion", 176 | }, 177 | ], 178 | }, 179 | ], 180 | }, 181 | "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", 182 | }, 183 | ], 184 | }, 185 | }, 186 | } 187 | `; 188 | -------------------------------------------------------------------------------- /test/trigger.test.ts: -------------------------------------------------------------------------------- 1 | import { Stack } from 'aws-cdk-lib'; 2 | import { Match, Template } from 'aws-cdk-lib/assertions'; 3 | import * as lambda from 'aws-cdk-lib/aws-lambda'; 4 | import * as sns from 'aws-cdk-lib/aws-sns'; 5 | import * as triggers from '../src'; 6 | 7 | test('minimal usage', () => { 8 | // GIVEN 9 | const stack = new Stack(); 10 | const triggeringResource = new sns.Topic(stack, 'MyTopic'); 11 | const trigger = new lambda.Function(stack, 'MyTriggerHandler', { 12 | runtime: lambda.Runtime.NODEJS_12_X, 13 | code: lambda.Code.fromInline('zoo'), 14 | handler: 'index.handler', 15 | }); 16 | 17 | // WHEN 18 | new triggers.AfterCreate(stack, 'MyTrigger', { 19 | handler: trigger, 20 | resources: [triggeringResource], 21 | }); 22 | 23 | // THEN 24 | const template = Template.fromStack(stack); 25 | expect(template).toMatchSnapshot(); 26 | 27 | expect(template.hasResourceProperties('Custom::Trigger', 28 | Match.objectLike({ 29 | HandlerArn: { 30 | Ref: 'MyTriggerHandlerCurrentVersionC0B6BBD40f3abd954eb77fda7e548d681c7fa667', 31 | }, 32 | }))); 33 | 34 | expect(template.hasResource('Custom::Trigger', 35 | Match.objectLike({ 36 | DependsOn: ['MyTopic86869434'], 37 | }))); 38 | }); 39 | -------------------------------------------------------------------------------- /tsconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "alwaysStrict": true, 4 | "declaration": true, 5 | "esModuleInterop": true, 6 | "experimentalDecorators": true, 7 | "inlineSourceMap": true, 8 | "inlineSources": true, 9 | "lib": [ 10 | "es2019" 11 | ], 12 | "module": "CommonJS", 13 | "noEmitOnError": false, 14 | "noFallthroughCasesInSwitch": true, 15 | "noImplicitAny": true, 16 | "noImplicitReturns": true, 17 | "noImplicitThis": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "resolveJsonModule": true, 21 | "strict": true, 22 | "strictNullChecks": true, 23 | "strictPropertyInitialization": true, 24 | "stripInternal": true, 25 | "target": "ES2019" 26 | }, 27 | "include": [ 28 | ".projenrc.js", 29 | "src/**/*.ts", 30 | "test/**/*.ts" 31 | ], 32 | "exclude": [ 33 | "node_modules" 34 | ], 35 | "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." 36 | } 37 | -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.5" 3 | } 4 | --------------------------------------------------------------------------------