Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodbatlas_network_container doesn't form a valid json request #83

Closed
ruXlab opened this issue Dec 4, 2019 · 5 comments
Closed

mongodbatlas_network_container doesn't form a valid json request #83

ruXlab opened this issue Dec 4, 2019 · 5 comments

Comments

@ruXlab
Copy link

ruXlab commented Dec 4, 2019

Hello here

I have this resource configuration, very much as in the documentation:

resource "mongodbatlas_network_container" "mongo_network_container" {
    project_id       = "${var.mongodbatlas_project_id}"
    atlas_cidr_block = "${var.cidr_block}"
    provider_name    = "AWS"
    region_name      = "${lower(var.region)}"
}

And that gives me an error:

Error: error updating MongoDB Network Peering Container (XXXXXX): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/XXXXX/containers/YYYYYY: 400 (request "Bad Request") Received JSON does not match expected format.

I enabled tracing and found following records:

2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 2019/12/04 16:36:42 [DEBUG] MongoDB Atlas API Request Details:
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: ---[ REQUEST ]---------------------------------------
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: PATCH /api/atlas/v1.0/groups/XXXX/containers/YYYYY HTTP/1.1
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Host: cloud.mongodb.com
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: User-Agent: go-mongodbatlas0.1
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Content-Length: 27
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Accept: application/json
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Content-Type: application/json
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Accept-Encoding: gzip
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: {
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4:  "regionName": "US_EAST_1"
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: }
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 
2019-12-04T16:36:42.763Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: -----------------------------------------------------
................

2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 2019/12/04 16:36:43 [DEBUG] MongoDB Atlas API Response Details:
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: ---[ RESPONSE ]--------------------------------------
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: HTTP/2.0 400 Bad Request
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Content-Length: 136
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Content-Type: application/json
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Date: Wed, 04 Dec 2019 16:36:43 GMT
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: Strict-Transport-Security: max-age=300
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: X-Mongodb-Service-Version: gitHash=622ff596a38c2d3230739807f62553444920cb91; versionString=v20191112
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: {
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4:  "detail": "Received JSON does not match expected format.",
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4:  "error": 400,
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4:  "errorCode": "INVALID_JSON",
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4:  "parameters": [],
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4:  "reason": "Bad Request"
2019-12-04T16:36:43.846Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: }
2019-12-04T16:36:43.847Z [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: -----------------------------------------------------

It seems to me that request is not complete, as per documentation this API requires additional fields


versions

  • provider.aws v2.39.0
  • provider.mongodbatlas v0.3.0(tried with v0.3.1 as well)
  • provider.random v2.2.1
  • provider.template v2.1.2

Is it a bug or I'm doing something wrong?

Thanks

@ardiesaeidi
Copy link

I had a similar issue, try changing region_name to use uppercase and underscore for aws region name. So instead of us-west-2 -> US_WEST_2.

@ruXlab
Copy link
Author

ruXlab commented Dec 16, 2019

@ardiesaeidi thanks for your response. I have seen people had the similar issue with capitalisation of the regions names, so I actually enforced it using upper function to avoid typos

@ardiesaeidi
Copy link

thanks @ruXlab that would be really helpful. How do you guys feel about normalizing wherever you ask for region so that it is consistent?

Some modules like mongodbatlas_network_peering ask for region using lowercase-hyphen, while the rest of the modules ask for region using uppercase and underscore. (like mongodbatlas_network_container)

@ruXlab
Copy link
Author

ruXlab commented Dec 18, 2019

@ardiesaeidi as an API consumer I'd expect to have the same naming across the resources. Ideally to make them match AWS plugin naming.

In any way if malformed parameter is passed the validation error should be thrown as early as possible giving a clear direction for error resolution for the API consumer

Thanks!

@themantissa
Copy link
Collaborator

@ruXlab and @ardiesaeidi thank you very much for helping each other out here! Please do note that support is provided within the MongoDB Atlas support system. I realize this was reported here as it was assumed to be a bug.

Agree the variations in region naming can be challenging. Our Provider developers have worked to improve this as it's come up and will continue to do so as it makes sense, same with error messages where it's the provider, though what you hit here is the underlying API's error. It really comes down to consuming the underlying API which is where this stems from (https://docs.atlas.mongodb.com/reference/amazon-aws/#amazon-aws). I'll ensure this feedback gets back to our internal teams regarding future improvements.

With that I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants