forked from aws-ia/terraform-aws-eks-blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (68 loc) · 2.51 KB
/
e2e-test.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
71
72
73
74
75
76
77
78
79
80
81
name: e2e-test
on:
workflow_dispatch:
inputs:
TFDestroy:
description: 'Destroy TF Automatically (false/true) - Default: true'
required: true
default: 'true'
jobs:
deploy:
name: Run e2e test
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure AWS credentials from Test account
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.ROLE_TO_ASSUME }}
aws-region: us-west-2
role-duration-seconds: 3600
role-session-name: GithubActions-Session
- name: Terraform Job
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
- name: Terraform Fmt
id: fmt
run: terraform fmt -check -recursive -list -no-color
continue-on-error: false
- name: Terraform Init
id: init
run: terraform init -backend-config backend.conf -reconfigure
working-directory: deploy/e2e/eks
continue-on-error: false
- name: Terraform Validate
id: validate
working-directory: deploy/e2e/eks
run: terraform validate -no-color
continue-on-error: false
- name: Terraform Plan
id: plan
working-directory: deploy/e2e/eks
run: terraform plan -var-file base.tfvars -no-color
continue-on-error: false
- name: Terraform Apply
id: apply
working-directory: deploy/e2e/eks
run: terraform apply -var-file base.tfvars -no-color -auto-approve
continue-on-error: true
- name: Terraform Destroy
if: github.event.inputs.TFDestroy == 'true' && (steps.apply.outcome == 'success' || steps.apply.outcome == 'failure')
id: destroy
working-directory: deploy/e2e/eks
run: terraform destroy -var-file base.tfvars -no-color -auto-approve
continue-on-error: false
- name: Fail if TF apply failed
if: steps.apply.outcome == 'failure'
id: fail-if-tf-apply-failed
run: |
echo "Terraform Apply step failed...Please check the logs of the Terraform Apply step."
echo "Failing the job to avoid false positives."
exit 1
continue-on-error: false