Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GCP auth at apply and simplify check-secure-estimate workflow #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions .github/workflows/tf-check-secure-estimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ permissions:
pull-requests: write

env:
AWS_ACCESS_KEY_ID : "${{ secrets.AWS_ACCESS_KEY_ID }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be declared to work with the check code step

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, added -backend=false, which should fix the check issue

AWS_SECRET_ACCESS_KEY : "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
TF_ROOT : "."

jobs:
Expand All @@ -32,7 +30,7 @@ jobs:

# Initialize a new or existing Terraform working directory
- name: Terraform Init
run: terraform init
run: terraform init -backend=false

# Validate terraform files
- name: Terraform Validate
Expand Down Expand Up @@ -98,14 +96,9 @@ jobs:
with:
terraform_wrapper: false

# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for this remove of init and plan for estimate cost

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added explicit init back in to ensure that it is executed withbackend = false

- name: Terraform Init
run: terraform init
run: terraform init -backend=false

# Plan change
- name: Terraform Plan
run: terraform plan

- name: Setup Infracost
uses: infracost/actions/setup@v2
with:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/tf-plan-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ permissions:
env:
AWS_ACCESS_KEY_ID : "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY : "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
GOOGLE_APPLICATION_CREDENTIALS : /tmp/gcp.creds
TF_ROOT : "."

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

steps:
# Set-up Google authentication if configured
- name: Set-up GCP auth
if: ${{ env.GOOGLE_APPLICATION_CREDENTIALS_CONTENT != '' }}
run: cat - <<<"${GOOGLE_APPLICATION_CREDENTIALS_CONTENT}" > "$GOOGLE_APPLICATION_CREDENTIALS"
env:
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_CONTENT }}"

# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -119,6 +127,13 @@ jobs:
needs: [terraform-plan]

steps:
# Set-up Google authentication if configured
- name: Set-up GCP auth
if: ${{ env.GOOGLE_APPLICATION_CREDENTIALS_CONTENT != '' }}
run: cat - <<<"${GOOGLE_APPLICATION_CREDENTIALS_CONTENT}" > "$GOOGLE_APPLICATION_CREDENTIALS"
env:
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_CONTENT }}"

# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
Expand Down