-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (58 loc) · 2.05 KB
/
deploy-test.yml
File metadata and controls
69 lines (58 loc) · 2.05 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
57
58
59
60
61
62
63
64
65
66
67
68
69
name: "Deploy - Test"
run-name: "${{ github.event.inputs.git_ref }}"
on:
workflow_dispatch:
inputs:
git_ref:
description: "Branch, tag or SHA to deploy"
required: true
type: "string"
permissions:
pull-requests: write
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
terraform_plan_apply:
name: Terraform Plan/Apply (ndr-test)
runs-on: ubuntu-latest
environment: test
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.git_ref}}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
role-skip-session-tagging: true
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: true
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.14.5
terraform_wrapper: false
- name: Initialise Terraform
id: init
run: terraform init -backend-config=backend-test.conf
working-directory: ./infrastructure
shell: bash
- name: Select Terraform Workspace
id: workspace
run: terraform workspace select -or-create ${{ secrets.AWS_WORKSPACE }}
working-directory: ./infrastructure
shell: bash
- name: Check Terraform Formatting
run: terraform fmt -check
working-directory: ./infrastructure
- name: Run Terraform Plan
id: plan
run: |
terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
working-directory: ./infrastructure
shell: bash
- name: Run Terraform Apply
run: terraform apply -auto-approve -input=false tf.plan
working-directory: ./infrastructure