-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (57 loc) · 2.01 KB
/
terraform-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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: terraform apply
on:
workflow_dispatch:
inputs:
environment:
description: "Target environment"
required: true
default: "test"
type: choice
options:
- test
jobs:
plan:
uses: ./.github/workflows/terraform-plan.yml
with:
environment: ${{ inputs.environment }}
store_plan: true
secrets: inherit
apply:
runs-on: ubuntu-24.04
# Related
# - https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
# - https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps
permissions:
id-token: write # Required for aws-actions/configure-aws-credentials
contents: read # Required for aws-actions/configure-aws-credentials
needs: [plan]
environment: "terraform-${{ inputs.environment }}"
steps:
- uses: actions/[email protected]
- name: Read .terraform-version
id: terraform_version
run: echo "value=$(cat .terraform-version)" >> $GITHUB_OUTPUT
working-directory: terraform
- uses: hashicorp/[email protected]
with:
terraform_version: "${{ steps.terraform_version.outputs.value }}"
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ vars.IAM_ROLE_ARN }}
aws-region: eu-central-1
- name: Retrieve tfplan artifact
uses: actions/[email protected]
with:
name: tfplan
path: terraform/
- name: terraform init
run: terraform init -backend-config=${{ inputs.environment }}.s3.tfbackend
working-directory: terraform
- name: terraform apply
run: terraform apply tfplan
working-directory: terraform
env:
TF_VAR_cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
TF_VAR_api_subdomain: ${{ vars.API_SUBDOMAIN }}
TF_VAR_email_function_parameters: ${{ secrets.EMAIL_FUNCTION_PARAMETERS }}