GoogleCloudPlatform / policy-library

A library of constraint templates and sample constraints for Constraint Framework tools
Apache License 2.0
223 stars 129 forks source link

gcp_enforce_naming DOES NOT work when a random string added to resource name #404

Open zack-amirakulov opened 2 years ago

zack-amirakulov commented 2 years ago

gcp_enforce_naming DOES NOT work when a random string is added to the resource name. An error with placeholder-BpLnfgDs

Reproduced with the following TF code:

resource "random_string" "random_prefix" {
  length  = 8
  special = false
  upper   = false
}

resource "google_storage_bucket" "bucket" {
  name     = "${var.name}-${var.environment}-${random_string.random_prefix.result}"
  project  = var.project_id
  location = var.location
}

Getting error: //storage.googleapis.com/placeholder-BpLnfgDs: placeholder-BpLnfgDs does not obey the naming convention. Use built-in Terraform modules for provisioning resources. Full address: //storage.googleapis.com/placeholder-BpLnfgDs