From 9eff7cf865ede5b21fffae48249bbee7080fbbdf Mon Sep 17 00:00:00 2001 From: Matheus Genteluci Date: Thu, 22 Aug 2019 22:15:39 -0300 Subject: [PATCH] Turning variables into optional Make template file optional adding default value Make capabilites configurable --- README.md | 17 ++++++++++++++++- entrypoint.sh | 16 +++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39d3c58..3ee9f72 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: mgenteluci/cloudformation-deploy-action@v1 + - uses: mgenteluci/cloudformation-deploy-action@v1.1.0 env: TEMPLATE: 'template.yml' + CAPABILITIES: 'CAPABILITY_IAM' AWS_STACK_NAME: 'my-stack' AWS_REGION: 'us-east-1' AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} AWS_DEPLOY_BUCKET: ${{secrets.AWS_DEPLOY_BUCKET}} ``` + +### Environment Variables + +* `TEMPLATE` - [Optional]. YML file containing CloudFormation Stack. Default to `template.yml`. +* `CAPABILITIES` - [Optional]. AWS Stack Capabilites. Default to `CAPABILITY_IAM`. +* `AWS_STACK_NAME` - [**Required**]. The Stack name that is going to be published. +* `AWS_REGION` - [**Required**]. AWS Region where to deploy the CloudFormation Stack. +* `AWS_ACCESS_KEY_ID` - [**Required**]. AWS Access Key Id. +* `AWS_SECRET_ACCESS_KEY` - [**Required**]. AWS Secret Access Key. +* `AWS_DEPLOY_BUCKET` - [**Required**]. AWS S3 Bucket where the Stack package is going to be stored. + +### License + +The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). diff --git a/entrypoint.sh b/entrypoint.sh index 697e693..db5bd01 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,8 +3,14 @@ set -e if [[ -z "$TEMPLATE" ]]; then - echo Empty template specified - exit 1 + echo Empty template specified. Searching template.yml... + + if [[ ! -f "template.yml" ]]; then + echo default template.yml not found + exit 1 + fi + + TEMPLATE="template.yml" fi if [[ -z "$AWS_STACK_NAME" ]]; then @@ -32,6 +38,10 @@ if [[ -z "$AWS_DEPLOY_BUCKET" ]]; then exit 1 fi +if [[ -z "$CAPABILITIES" ]]; then + CAPABILITIES=CAPABILITY_IAM +fi + mkdir ~/.aws touch ~/.aws/credentials touch ~/.aws/config @@ -46,4 +56,4 @@ output = text region = $AWS_REGION" > ~/.aws/config aws cloudformation package --template-file $TEMPLATE --output-template-file serverless-output.yaml --s3-bucket $AWS_DEPLOY_BUCKET -aws cloudformation deploy --template-file serverless-output.yaml --stack-name $AWS_STACK_NAME --capabilities CAPABILITY_IAM +aws cloudformation deploy --template-file serverless-output.yaml --stack-name $AWS_STACK_NAME --capabilities $CAPABILITIES