forked from WahlNetwork/github-action-terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (34 loc) · 1.49 KB
/
tf-apply.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: "Terraform Apply"
# Trigger when commits are pushed to the master branch
on:
push:
branches:
- master
jobs:
terraform-plan:
name: "Terraform Apply"
runs-on: ubuntu-latest
steps:
# Checkout the code
# Marketplace: https://github.com/marketplace/actions/checkout
- name: "Setup - Checkout"
uses: actions/[email protected]
# Provides AWS credentials to Terraform
# By default, Terraform checks the home directory for a .aws folder with a credential file
# Documentation: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/create-shared-credentials-file.html
- name: "Setup - Build AWS Credentials"
run: |
mkdir -p ~/.aws
echo "[default]" > ~/.aws/credentials
echo "aws_access_key_id = ${{ secrets.AWS_ACCESS_KEY_ID }}" >> ~/.aws/credentials
echo "aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials
# Downloads a specific version of Terraform CLI and adds it to PATH
# Marketplace: https://github.com/marketplace/actions/hashicorp-setup-terraform
- name: "Setup - Terraform CLI"
uses: hashicorp/[email protected]
# Init pulls credentials from the .aws/credentials file by default
- name: "Run - Terraform Init"
run: terraform init -input=false
# Auto-approve prevents the requirement of human interaction
- name: "Run - Terraform Apply"
run: terraform apply -input=false -auto-approve