hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.32k stars 1.72k forks source link

Missing key/value separator #10809

Closed tightly-clutched closed 2 years ago

tightly-clutched commented 2 years ago

Community Note

Terraform Version

% terraform -v Terraform v0.13.5

Affected Resource(s)

google_compute_router

Terraform Configuration Files

module "cloud_router-ue4" {
  source  = "terraform-google-modules/cloud-router/google"
  version = "0.3.0"

  name    = "stage-router-ue4"
  project = var.project_id
  region  = var.region3
  network = module.vpc.network_name
  bgp = {
      asn               = 65000
      advertise_mode    = "CUSTOM"
      advertised_groups = ["ALL_SUBNETS"]
      advertised_ip_ranges {
        description = "aws subnets"
        range       = "10.0.0.0/16"
      }
  }

Debug Output

Panic Output

Expected Behavior

I expected that the advertised_ip_ranges would be included in the plan, since I'm following the example shown on the module page here: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_router which does not have an "=" sign.

Actual Behavior


Error: Missing key/value separator

  on main.tf line 212, in module "cloud_router-ue4":
 208:   bgp = {
 209:       asn               = 65000
 210:       advertise_mode    = "CUSTOM"
 211:       advertised_groups = ["ALL_SUBNETS"]
 212:       advertised_ip_ranges {

Expected an equals sign ("=") to mark the beginning of the attribute value.

Steps to Reproduce

I remove advertised_ip_ranges and plan works without error. Re-inserting it produces the same error.

Important Factoids

I guess I wonder if this is version-dependent and if advertised_ip_ranges was not supported in my configuration?

References

shuyama1 commented 2 years ago

Hi @tightly-clutched! Can you remove the = sign after bgp and see if that works?

tightly-clutched commented 2 years ago

I tried the suggestion and terraform plan still failed. The documentation seems to clearly be wrong.

 % terraform plan
Running plan in the remote backend. Output will stream here. Pressing Ctrl-C
will stop streaming the logs, but will not stop the plan running remotely.

Preparing the remote plan...

The remote workspace is configured to work with configuration at
vpc/stage relative to the target repository.

Terraform will upload the contents of the following directory,
excluding files or directories as defined by a .terraformignore file
at /Users/mike.james/Github/terraformCloudGCP/.terraformignore (if it is present),
in order to capture the filesystem context the remote workspace expects:
    /Users/mike.james/Github/terraformCloudGCP

Waiting for the plan to start...

Terraform v0.13.5
Configuring remote state backend...
Initializing Terraform configuration...

Error: Unsupported block type

  on main.tf line 208, in module "cloud_router-ue4":
 208:   bgp {

Blocks of type "bgp" are not expected here. Did you mean to define argument
"bgp"? If so, use the equals sign to assign it a value.
shuyama1 commented 2 years ago

Hey @tightly-clutched. Sorry for the late reply. Can you try adding = after both bgp and advertised_ip_ranges and see if that works.

  bgp = {
      asn               = 65000
      advertise_mode    = "CUSTOM"
      advertised_groups = ["ALL_SUBNETS"]
      advertised_ip_ranges = {
        description = "aws subnets"
        range       = "10.0.0.0/16"
      }
  }

Sorry that I missed the fact that you were using modules. Our documentation provides the examples of configuration using resources. So sometimes the format of it may be a little different from using modules, depends on how modules define. It looks like that https://github.com/terraform-google-modules/terraform-google-cloud-router does not provide an example of how to use advertised_ip_ranges. If adding = is not working in your case, I would suggest you file an issue against https://github.com/terraform-google-modules/terraform-google-cloud-router to ask for example/clarification of how to configure advertised_ip_ranges.

tightly-clutched commented 2 years ago

Hi, @shuyama1 . I tried it with and without the "=" signs and I can't get the advertised_ip_ranges to configure correctly. I'm taking your suggestion to file and issue with the module maintainers. I appreciate your help!

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.