|
| 1 | +# Locals block to hold and modify the values |
| 2 | +locals { |
| 3 | + tf_sa = var.terraform_service_account |
| 4 | +} |
| 5 | + |
| 6 | +provider "google" { |
| 7 | + alias = "tokengen" |
| 8 | +} |
| 9 | + |
| 10 | +data "google_service_account_access_token" "default" { |
| 11 | + provider = google.tokengen |
| 12 | + target_service_account = local.tf_sa |
| 13 | + |
| 14 | + // To see, edit, configure, and delete your Google Cloud data |
| 15 | + scopes = ["https://www.googleapis.com/auth/cloud-platform"] |
| 16 | + lifetime = "600s" |
| 17 | +} |
| 18 | + |
| 19 | +/****************************************** |
| 20 | + GA Provider credential configuration |
| 21 | + *****************************************/ |
| 22 | + |
| 23 | +provider "google" { |
| 24 | + // configure the default project and region. |
| 25 | + project = var.project_id |
| 26 | + region = var.default_region |
| 27 | + zone = var.default_zone |
| 28 | + |
| 29 | + // A temporary OAuth 2.0 access token obtained from the Google Authorization server |
| 30 | + // used to authenticate HTTP requests to GCP APIs. |
| 31 | + access_token = data.google_service_account_access_token.default.access_token |
| 32 | +} |
| 33 | + |
| 34 | +/****************************************** |
| 35 | + Beta Provider credential configuration |
| 36 | + *****************************************/ |
| 37 | + |
| 38 | +provider "google-beta" { |
| 39 | + // configure the default project and region. |
| 40 | + project = var.project_id |
| 41 | + region = var.default_region |
| 42 | + zone = var.default_zone |
| 43 | + |
| 44 | + // A temporary OAuth 2.0 access token obtained from the Google Authorization server |
| 45 | + // used to authenticate HTTP requests to GCP APIs. |
| 46 | + access_token = data.google_service_account_access_token.default.access_token |
| 47 | +} |
0 commit comments