Skip to content

Commit 7372b07

Browse files
authored
Feat: Added GCP authentication more inputs (#139)
1 parent 3d06831 commit 7372b07

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

.github/workflows/terraform_workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ on:
6161
required: false
6262
type: string
6363
description: 'ID of the default project to use for future API calls and invocations.'
64+
create_credentials_file:
65+
required: false
66+
type: string
67+
default: false
68+
description: 'If true, the action will securely generate a credentials file which can be used for authentication via gcloud and Google Cloud SDKs.'
6469
secrets:
6570
AZURE_CREDENTIALS:
6671
required: false
@@ -134,6 +139,7 @@ jobs:
134139
uses: 'google-github-actions/auth@v2'
135140
with:
136141
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
142+
create_credentials_file: ${{ inputs.create_credentials_file }}
137143
token_format: ${{ inputs.token_format }}
138144
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
139145
service_account: ${{ secrets.SERVICE_ACCOUNT }}

.github/workflows/tf-checks.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
required: false
1111
type: string
1212
default: './examples/complete/'
13+
provider:
14+
required: true
15+
type: string
16+
default: gcp
17+
description: 'Cloud provider to run the workflow. e.g. azurerm or aws or gcp'
1318
terraform_version:
1419
description: 'Terraform version to use. Leave empty for the latest version.'
1520
required: false
@@ -24,6 +29,25 @@ on:
2429
required: false
2530
default: false
2631
type: string
32+
token_format:
33+
required: false
34+
type: string
35+
default: access_token
36+
description: 'Output format for the generated authentication token. For OAuth 2.0 access tokens, specify "access_token". For OIDC tokens, specify "id_token". To skip token generation, leave this value empty'
37+
access_token_lifetime:
38+
required: false
39+
type: string
40+
default: 300s
41+
description: 'Desired lifetime duration of the access token, in seconds'
42+
project_id:
43+
required: false
44+
type: string
45+
description: 'ID of the default project to use for future API calls and invocations.'
46+
create_credentials_file:
47+
required: false
48+
type: string
49+
default: false
50+
description: 'If true, the action will securely generate a credentials file which can be used for authentication via gcloud and Google Cloud SDKs.'
2751
secrets:
2852
AWS_ACCESS_KEY_ID:
2953
description: 'aws access keys'
@@ -34,6 +58,12 @@ on:
3458
GCP_CREDENTIALS:
3559
description: 'The Google Cloud JSON service account key to use for authentication'
3660
required: false
61+
WORKLOAD_IDENTITY_PROVIDER:
62+
required: false
63+
description: 'The full identifier of the Workload Identity Provider'
64+
SERVICE_ACCOUNT:
65+
required: false
66+
description: 'The service account to be used'
3767

3868

3969
jobs:
@@ -84,10 +114,16 @@ jobs:
84114
aws-region: us-east-1
85115

86116
- name: 'Authenticate to Google Cloud'
87-
if: ${{ inputs.gcp_credentials == 'true' }}
117+
if: ${{ inputs.provider == 'gcp' }}
88118
uses: 'google-github-actions/auth@v2'
89119
with:
90120
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
121+
create_credentials_file: ${{ inputs.create_credentials_file }}
122+
token_format: ${{ inputs.token_format }}
123+
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
124+
service_account: ${{ secrets.SERVICE_ACCOUNT }}
125+
access_token_lifetime: ${{ inputs.access_token_lifetime }}
126+
project_id: ${{ inputs.project_id }}
91127

92128
# - Installing terraform version based on version extract.
93129
- name: Install Terraform v${{ inputs.terraform_version || needs.versionExtract.outputs.maxVersion }}

.github/workflows/tfdrift.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
required: true
1313
type: string
1414
default: azurerm
15-
description: 'Cloud provider to run the workflow. e.g. azurerm or aws'
15+
description: 'Cloud provider to run the workflow. e.g. azurerm or aws or gcp'
1616
aws_region:
1717
required: false
1818
type: string
@@ -41,6 +41,11 @@ on:
4141
required: false
4242
type: string
4343
description: 'ID of the default project to use for future API calls and invocations.'
44+
create_credentials_file:
45+
required: false
46+
type: string
47+
default: false
48+
description: 'If true, the action will securely generate a credentials file which can be used for authentication via gcloud and Google Cloud SDKs.'
4449
secrets:
4550
AZURE_CREDENTIALS:
4651
required: false
@@ -117,6 +122,7 @@ jobs:
117122
uses: 'google-github-actions/auth@v2'
118123
with:
119124
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
125+
create_credentials_file: ${{ inputs.create_credentials_file }}
120126
token_format: ${{ inputs.token_format }}
121127
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
122128
service_account: ${{ secrets.SERVICE_ACCOUNT }}

0 commit comments

Comments
 (0)