Skip to content

Commit

Permalink
Turning variables into optional
Browse files Browse the repository at this point in the history
Make template file optional adding default value
Make capabilites configurable
  • Loading branch information
MGenteluci committed Aug 23, 2019
1 parent 4f27619 commit 9eff7cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
16 changes: 13 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 9eff7cf

Please sign in to comment.