akshaykarle / terraform-provider-mongodbatlas

Terraform provider for MongoDB Atlas
Mozilla Public License 2.0
123 stars 54 forks source link

IP Whitelist errors #31

Closed mmindenhall closed 5 years ago

mmindenhall commented 5 years ago

Thanks for creating this project! I'm using it to create and manage clusters across several different environments our team uses in AWS (dev, end-to-end testing, staging, performance testing, production). For each cluster we need access from all of our company networks (9 CIDR blocks), as well as from each of the NAT gateways created in our AWS VPCs (two IP addresses). I've created lists for each of these, and am processing them with the terraform "count" attribute.

# Create IP Whitelist for internal networks
resource "mongodbatlas_ip_whitelist" "internal_cidrs" {
  count = "${length(local.internal_all_cidr)}"     # count here is 9
  group = "${data.mongodbatlas_project.mongo_env_prj.id}"
  cidr_block = "${element(local.internal_all_cidr, count.index)}"
  comment = "Internal network"
}

# Create IP Whitelist for AWS VPC subnets
resource "mongodbatlas_ip_whitelist" "aws_subnets" {
  count = "${length(local.nat_ip_whitelist)}"     # count here is 2
  group = "${data.mongodbatlas_project.mongo_env_prj.id}"
  ip_address = "${element(local.nat_ip_whitelist, count.index)}"
  comment = "${var.ENV} VPC subnet"
}

I see most of the resources are created successfully:

mongodbatlas_ip_whitelist.internal_cidrs[2]: Creation complete after 1s (ID: xxx.113.241.176/28)
mongodbatlas_ip_whitelist.internal_cidrs[0]: Creation complete after 1s (ID: xx.250.130.128/27)
mongodbatlas_ip_whitelist.internal_cidrs[5]: Creation complete after 1s (ID: xxx.185.19.0/25)
mongodbatlas_ip_whitelist.aws_subnets[1]: Creation complete after 1s (ID: xxx.210.165.58/32)
mongodbatlas_ip_whitelist.internal_cidrs[7]: Creation complete after 1s (ID: xxx.142.161.224/29)
mongodbatlas_ip_whitelist.internal_cidrs[6]: Creation complete after 1s (ID: xxx.49.68.0/25)
mongodbatlas_ip_whitelist.internal_cidrs[4]: Creation complete after 0s (ID: xxx.244.95.32/28)
mongodbatlas_ip_whitelist.aws_subnets[0]: Creation complete after 1s (ID: xxx.212.28.198/32)

But a few of them are reported as failures by the provider:

Error: Error applying plan:

3 error(s) occurred:

* mongodbatlas_ip_whitelist.internal_cidrs[1]: 1 error(s) occurred:

* mongodbatlas_ip_whitelist.internal_cidrs.1: MongoDB Project IP Whitelist with CIDR block: xxx.113.250.24/29 and IP Address:  could not be found in the response from MongoDB Atlas
* mongodbatlas_ip_whitelist.internal_cidrs[8]: 1 error(s) occurred:

* mongodbatlas_ip_whitelist.internal_cidrs.8: MongoDB Project IP Whitelist with CIDR block: xxx.68.180.88/29 and IP Address:  could not be found in the response from MongoDB Atlas
* mongodbatlas_ip_whitelist.internal_cidrs[3]: 1 error(s) occurred:

* mongodbatlas_ip_whitelist.internal_cidrs.3: MongoDB Project IP Whitelist with CIDR block: xxx.151.81.248/29 and IP Address:  could not be found in the response from MongoDB Atlas

Despite these being reported as failures, the resources are all successfully created (I can verify this via the Atlas web console). Perhaps some of the calls are timing out before the response is received?

akshaykarle commented 5 years ago

closed by #33