mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
238 stars 167 forks source link

mongodbatlas_network_peering outputting invalid json #59

Closed nathankodilla closed 4 years ago

nathankodilla commented 4 years ago

POST /api/atlas/v1.0/groups/xxxxxx/peers returns a 500, and putting terraform in debug outputs invalid json:

2019-11-04T11:18:24.944-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: ---[ REQUEST ]---------------------------------------
2019-11-04T11:18:24.944-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: POST /api/atlas/v1.0/groups/xxxxxxx/peers HTTP/1.1
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: Host: cloud.mongodb.com
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: User-Agent: go-mongodbatlas0.1
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: Content-Length: 272
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: Accept: application/json
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: Content-Type: application/json
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: Accept-Encoding: gzip
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: {
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:  "accepterRegionName": "us-east-1",
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:  "awsAccountId": "xxxxxxxx",
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:  "containerId": "xxxxxxxxx",
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:  "providerName": "AWS",
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:  "routeTableCidrBlock": "10.171.0.0/16"k,
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:  "vpcId": "vpc-xxxxxxx"
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: }
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe:
2019-11-04T11:18:24.945-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4.exe: -----------------------------------------------------

Note the random k after the routeTableCidrBlock value.

Terraform script is as follows:

resource "mongodbatlas_network_peering" "main" {
  count                  = "${length(var.vpc_ids)}"
  project_id             = "${mongodbatlas_project.main.id}"
  container_id           = "${mongodbatlas_network_container.main.id}"
  provider_name          = "AWS"
  aws_account_id         = "${data.aws_caller_identity.current.account_id}"
  accepter_region_name   = "us-east-1"
  route_table_cidr_block = "${element(data.aws_vpc.main.*.cidr_block, count.index)}"
  vpc_id                 = "${element(var.vpc_ids, count.index)}"
}
nathankodilla commented 4 years ago

Upgraded to 0.3.0 and once it output a random . instead of the k and then a third time it outputted correct json, but still gave the 500. So, maybe we can chop the random trailing characters to a logging issue, but the 500 from mongo cloud api still remains.

nathankodilla commented 4 years ago

Found the issue. Needed to use mongodbatlas_network_container.main.container_id instead of mongodbatlas_network_container.main.id.

themantissa commented 4 years ago

@nathankodilla great you were able to solve the issue! I'll close this but if you have any other potential bugs to report please do. Otherwise please note that per the README support is provided under MongoDB Atlas support agreements.