diff --git a/README.md b/README.md index 6e7b4d8..12741cd 100644 --- a/README.md +++ b/README.md @@ -43,23 +43,7 @@ _Custom Role_ permissions: • storage.buckets.list ``` -The customer also needs to provide Bishop Fox with the WIF credentials file that is exported using the following command: - -```bash -gcloud iam workload-identity-pools create-cred-config \ -projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/providers/PROVIDER_ID \ - --service-account=SERVICE_ACCOUNT_EMAIL \ - --aws \ - --enable-imdsv2 \ - --output-file=FILEPATH.json - -Replace the following values: -• PROJECT_NUMBER: The project number of the project that contains the workload identity pool -• POOL_ID: The ID of the workload identity pool, ex. bfidentitypool -• PROVIDER_ID: The ID of the workload identity pool provider, ex. bfawsprovider -• SERVICE_ACCOUNT_EMAIL: The email address of the service account -• FILEPATH: The file to save configuration to -``` +The customer also needs to provide Bishop Fox with the WIF credentials file that is exported to gcp-wif-config.json during the terraform run. Lastly, Bishop Fox requires the customer GCP Organization ID which can be retrieved using the following command: diff --git a/main.tf b/main.tf index 4743d44..4c94a47 100644 --- a/main.tf +++ b/main.tf @@ -53,6 +53,13 @@ resource "google_service_account_iam_policy" "bishopfox" { depends_on = [google_service_account.bishopfox] } +resource "null_resource" "bishopfox" { + provisioner "local-exec" { + command = "gcloud iam workload-identity-pools create-cred-config projects/${var.projectNumber}/locations/global/workloadIdentityPools/${var.poolID}/providers/${var.providerID} --service-account=${google_service_account.bishopfox.email} --aws --enable-imdsv2 --output-file=gcp-wif-config.json --quiet" + } + depends_on = [google_iam_workload_identity_pool_provider.bishopfox] +} + diff --git a/outputs.tf b/outputs.tf index 8e78384..c6d46d5 100644 --- a/outputs.tf +++ b/outputs.tf @@ -16,3 +16,8 @@ output "service_account" { sensitive = false } +# output value of exportet WIF credential config file +output "gcp_wif_config" { + value = file("gcp-wif-config.json") +} +