-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (53 loc) · 1.83 KB
/
terraform-root-apply.yaml
File metadata and controls
56 lines (53 loc) · 1.83 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: 'Terraform Apply'
on:
workflow_call:
inputs:
runs-on:
description: 'Agent selection string.'
required: false
default: 'ubuntu-latest'
type: string
secrets:
aws-assume-role-arn:
description: 'The AWS Role ARN to assume for Terraform operations.'
required: true
aws-assume-role-region:
description: 'The AWS region to assume IAM in for Terraform operations.'
required: true
terraform-registry-token:
description: 'Terraform registry token to authorize Terraform operations.'
required: false
terraform-env-vars:
description: 'Environment variables to inject into Terraform operations.'
required: false
permissions:
id-token: write
contents: read
jobs:
terraform-apply:
name: 'Terraform Apply'
runs-on: ${{ inputs.runs-on }}
env:
TF_IN_AUTOMATION: true
steps:
- name: Sanity check
if: github.ref != 'refs/heads/main'
run: echo 'Not running against 'main' branch, exiting.' && exit 1
- name: Checkout
uses: actions/checkout@v3
- name: Read Terraform Version
run: echo "TF_VERSION=$(cat .terraform-version)" >> $GITHUB_ENV
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.aws-assume-role-arn }}
aws-region: ${{ secrets.aws-assume-role-region }}
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: ${{ env.TF_VERSION }}
cli_config_credentials_token: ${{ secrets.terraform-registry-token }}
- name: Initialize Terraform
run: terraform init
- name: Terraform Apply
run: ${{ secrets.terraform-env-vars }} terraform apply -auto-approve -input=false