cloudamqp / terraform-provider-cloudamqp

Terraform Provider for CloudAMQP
https://registry.terraform.io/providers/cloudamqp/cloudamqp
Mozilla Public License 2.0
35 stars 39 forks source link

Update Stackdriver integration to use raw credentials #184

Closed tbroden84 closed 1 year ago

tbroden84 commented 1 year ago

Improve use of credentials for Stackdriver, fetched from Google Service Account key when enable log and metric integrations.

New arguments

Argument updated with Computed

Log & metric: Use google_service_account_key resource from google provider to populate new argument credentials. That will base64decode the data and map it into json, to further set values for project_id, client_email, private_key, private_key_id.

resource "google_service_account_key" "service_account_key" {
  service_account_id = google_service_account.service_account.name
}

resource "cloudamqp_integration_log" "stackdriver" {
  instance_id = cloudamqp_instance.instance.id
  name = "stackdriver"
  credentials = google_service_account_key.service_account_key.private_key
}

resource "cloudamqp_integration_metric" "stackdriver" {
  instance_id = cloudamqp_instance.instance.id
  name = "stackdriver"
  credentials = google_service_account_key.service_account_key.private_key
}

Make sure to exclude argument tags if not used or set to "" in request body.

Old way to add the private_key is still supported. But clarified in documentation on what decoding is needed.

resource "cloudamqp_integration_log" "stackdriver" {
  ...
  private_key = jsondecode(base64decode(google_service_account_key.service_account_key.private_key)).private_key
}

Metrics: Make sure to exclude arguments queue_allowlist, vhost_allowlist if not used or set to "" in request body.