Looping over google_secret_manager_secret to create secrets fails

Not sure this should be here on with the google provider.

If I have a series of locals defined:

locals {
  exports = {
    "test-secret1" = { name = "test-secret", object = "secret data" }
    "test-secret2" = { name = "test-secret", object = "secret data" }
  }
}

If I then create a resource, the following works:

resource "google_secret_manager_secret" "test-secret" {
  secret_id = local.exports.test-secret.name

  replication {
    automatic = true
  }

}

However if I loop using ‘for_each’:

resource "google_secret_manager_secret" "test-secrets" {
  for_each = local.exports
  secret_id = each.value.name

  replication {
    automatic = false
  }
}

this does not work and produces the following error:

2020-07-16T17:36:56.014+0100 [DEBUG] plugin.terraform-provider-google_v3.30.0_x5: 
2020/07/16 17:36:56 [DEBUG] Retry Transport: Returning after 1 attempts
2020/07/16 17:36:56 [DEBUG] google_secret_manager_secret.test-secrets["test-secret1"]: 
apply errored, but we're indicating that via the Error pointer rather than returning it: Error 
creating Secret: googleapi: Error 400: Secret must be provided.
2020/07/16 17:36:56 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Error creating 
Secret: googleapi: Error 400: Secret must be provided.
2020/07/16 17:36:56 [ERROR] <root>: eval: *terraform.EvalSequence, err: Error creating 
Secret: googleapi: Error 400: Secret must be provided.

Error: Error creating Secret: googleapi: Error 400: Secret must be provided.

  on test.tf line 1, in resource "google_secret_manager_secret" "test-secrets":
   1: resource "google_secret_manager_secret" "test-secrets" {



Error: Error creating Secret: googleapi: Error 400: Secret must be provided.

  on test.tf line 1, in resource "google_secret_manager_secret" "test-secrets":
   1: resource "google_secret_manager_secret" "test-secrets" {

Does anyone have any idea if this is a bug in Terraform, the Google provider (have tried versions 3.8 and 3.30) or whether this is something I am doing wrong?

Same issue. Can’t figure out whether it is provider bug or not.

@westdart have you figured out how to make it work?