Skip to content

Commit c4004f7

Browse files
committed
Add GCP auth at apply and simplify check-secure-estimate workflow
* Add Google auth file if the corresponding secret is set * Remove terraform plan from estimation job in check-secure-estimate workflow * Remove AWS-related auth env vars in check-secure-estimate workflow
1 parent a3051da commit c4004f7

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

.github/workflows/tf-check-secure-estimate.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ permissions:
1010
pull-requests: write
1111

1212
env:
13-
AWS_ACCESS_KEY_ID : "${{ secrets.AWS_ACCESS_KEY_ID }}"
14-
AWS_SECRET_ACCESS_KEY : "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
1513
TF_ROOT : "."
1614

1715
jobs:
@@ -32,7 +30,7 @@ jobs:
3230

3331
# Initialize a new or existing Terraform working directory
3432
- name: Terraform Init
35-
run: terraform init
33+
run: terraform init -backend=false
3634

3735
# Validate terraform files
3836
- name: Terraform Validate
@@ -98,14 +96,9 @@ jobs:
9896
with:
9997
terraform_wrapper: false
10098

101-
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
10299
- name: Terraform Init
103-
run: terraform init
100+
run: terraform init -backend=false
104101

105-
# Plan change
106-
- name: Terraform Plan
107-
run: terraform plan
108-
109102
- name: Setup Infracost
110103
uses: infracost/actions/setup@v2
111104
with:

.github/workflows/tf-plan-apply.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ permissions:
1414
env:
1515
AWS_ACCESS_KEY_ID : "${{ secrets.AWS_ACCESS_KEY_ID }}"
1616
AWS_SECRET_ACCESS_KEY : "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
17+
GOOGLE_APPLICATION_CREDENTIALS : /tmp/gcp.creds
1718
TF_ROOT : "."
1819

1920
jobs:
@@ -27,6 +28,13 @@ jobs:
2728
tfplanExitCode: ${{ steps.tf-plan.outputs.exitcode }}
2829

2930
steps:
31+
# Set-up Google authentication if configured
32+
- name: Set-up GCP auth
33+
if: ${{ env.GOOGLE_APPLICATION_CREDENTIALS_CONTENT != '' }}
34+
run: cat - <<<"${GOOGLE_APPLICATION_CREDENTIALS_CONTENT}" > "$GOOGLE_APPLICATION_CREDENTIALS"
35+
env:
36+
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_CONTENT }}"
37+
3038
# Checkout the repository to the GitHub Actions runner
3139
- name: Checkout
3240
uses: actions/checkout@v3
@@ -119,6 +127,13 @@ jobs:
119127
needs: [terraform-plan]
120128

121129
steps:
130+
# Set-up Google authentication if configured
131+
- name: Set-up GCP auth
132+
if: ${{ env.GOOGLE_APPLICATION_CREDENTIALS_CONTENT != '' }}
133+
run: cat - <<<"${GOOGLE_APPLICATION_CREDENTIALS_CONTENT}" > "$GOOGLE_APPLICATION_CREDENTIALS"
134+
env:
135+
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_CONTENT }}"
136+
122137
# Checkout the repository to the GitHub Actions runner
123138
- name: Checkout
124139
uses: actions/checkout@v3

0 commit comments

Comments
 (0)