Created
March 19, 2019 02:12
-
-
Save karl-cardenas-coding/92123b87520511101f136fd7a25bf157 to your computer and use it in GitHub Desktop.
Automation-ci-yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- terraform | |
- packer | |
before_script: | |
- mkdir ~/.aws/ | |
- echo -e "[default]" > ~/.aws/credentials | |
- echo -e "aws_access_key_id=$AWS_ACCESS_KEY">> ~/.aws/credentials | |
- echo -e "aws_secret_access_key=$AWS_SECRET_KEY">> ~/.aws/credentials | |
- echo -e "[default]" > ~/.aws/config | |
- echo -e "region = us-east-1" >> ~/.aws/config | |
- echo -e "output = json" >> ~/.aws/config | |
- echo -e "[profile home]" >> ~/.aws/config | |
- echo -e "role_arn=arn:aws:iam::$ACCOUNT_ID:role/$AWS_ROLE" >> ~/.aws/config | |
- echo -e "source_profile = default" >> ~/.aws/config | |
- echo -e "region = us-east-1" >> ~/.aws/config | |
- echo -e "output = json" >> ~/.aws/config | |
- export TF_IN_AUTOMATION=true | |
build_json: | |
stage: terraform | |
tags: [gitlab-org] | |
image: registry.gitlab.com/cardenas88karl/automate-ami-demo:latest | |
only: | |
refs: | |
- master | |
script: | |
- chmod 755 ./aws-cli.sh | |
- terraform init && terraform apply -auto-approve | |
- packer validate ami.json | |
artifacts: | |
paths: | |
- ami.json | |
allow_failure: false | |
execute_packer: | |
stage: packer | |
tags: [gitlab-org] | |
image: registry.gitlab.com/cardenas88karl/automate-ami-demo:latest | |
only: | |
refs: | |
- master | |
script: | |
- chmod 755 ./amazon.sh | |
- packer build ami.json | |
dependencies: | |
- build_json | |
allow_failure: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment