Run CDK application. Diff, deploy, synth, destroy, ...
---
name: Deploy
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Deploy
uses: udondan/[email protected]
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
This will execute on the root directory of the repository:
npm inpm run buildcdk deploy --require-approval neverIf you want to run the action against a subdirectory of the repo, you can specify the directory:
- name: Deploy
uses: udondan/[email protected]
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SUBDIR: some/sub/directory
By default the action will run a deploy. In case you want to run any other process, you can specific the command via args:
- name: Destroy
uses: udondan/[email protected]
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
args: cdk destroy --force
# DEPLOY
docker run -it \
-v $(PWD):/workdir \
--workdir /workdir \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
udondan/cdk-nodejs:0.4.0
# DESTROY
docker run -it \
-v $(PWD):/workdir \
--workdir /workdir \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
udondan/cdk-nodejs:0.4.0 \
cdk destroy
The package code can be mounted to any location in the container. Just make sure you set the workdir to the same value. In the example above I use /workdir.
Parameters passed per env:
us-east-1true, debug mode is enabled. Might leak secrets in output.CDK needs to be able to interact with the cloudformation service and upload contents to a staging S3 bucket. Additionally you need to allow all actions you expect CloudFormation to do for you. Here is an example policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"cloudformation:*"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Condition": {
"ForAnyValue:StringEquals": {
"aws:CalledVia": [
"cloudformation.amazonaws.com"
]
}
},
"Action": "*",
"Resource": "*",
"Effect": "Allow"
},
{
"Action": "s3:*",
"Resource": "arn:aws:s3:::cdktoolkit-stagingbucket-*",
"Effect": "Allow"
}
]
}
The project is licensed under MIT.
Content type
Image
Digest
Size
176.4 MB
Last updated
almost 6 years ago
docker pull udondan/cdk-nodejs