Closed bobhlo closed 5 years ago
Hello @bobhlo thanks for your review, could you share us your terraform configuration to recreate the issue? just avoiding sensitive information.
Hi @PacoDw,
Please see following configuration in the module. One thing noted is terraform tried to update resource "mongodbatlas_network_peering.rest" with atlas_cidr_block which was not changed.
~ resource "mongodbatlas_network_peering" "rest" {
Code starts below:
# Create file for peering role
data "template_file" "peering_role" {
template = "${file("${path.module}/templates/peering-role.tpl")}"
vars = {
subscription_id = "${var.subscription_id}"
rg = "${var.rg}"
vnet = "${var.vnet}"
}
}
# Peering role files
resource "local_file" "peering_role" {
content = "${data.template_file.peering_role.rendered}"
filename = "${path.module}/files/{var.environment}-${var.customer}-${var.site}-peering-role.json"
}
# Configure the MongoDB Atlas Provider
provider "mongodbatlas" {
public_key = "${var.atlas_public_key}"
private_key = "${var.atlas_private_key}"
}
# Create a Group
resource "mongodbatlas_project" "rest" {
org_id = "${var.atlas_org_id}"
name = "${var.environment}-${var.customer}-${var.site}"
}
# Create a Container
resource "mongodbatlas_network_container" "rest" {
project_id = "${mongodbatlas_project.rest.id}"
atlas_cidr_block = "${var.atlas_cidr_block}"
provider_name = "${var.atlas_provider_name}"
region = "${var.atlas_region}"
}
#Create a Network Peering Connection
resource "mongodbatlas_network_peering" "rest" {
project_id = "${mongodbatlas_project.rest.id}"
atlas_cidr_block = "${var.atlas_cidr_block}"
container_id = "${mongodbatlas_network_container.rest.container_id}"
provider_name = "${var.atlas_provider_name}"
azure_directory_id = "${var.tenant_id}"
azure_subscription_id = "${var.subscription_id}"
resource_group_name = "${var.rg}"
vnet_name = "${var.vnet}"
}
# Whitelist REST and JConnect vnets
resource "mongodbatlas_project_ip_whitelist" "rest" {
project_id = "${mongodbatlas_project.rest.id}"
whitelist {
cidr_block = "${var.vnet_cidr}"
comment = "cidr block for ${var.vnet}"
}
whitelist {
cidr_block = "${var.prod_jcdigital_jconnect_cidr}"
comment = "cidr block for ${var.prod_jcdigital_jconnect_vnet}"
}
}
# Create Atlas cluster for sense-rest
resource "mongodbatlas_cluster" "rest" {
project_id = "${mongodbatlas_project.rest.id}"
name = "${var.environment}-${var.customer}-${var.site}"
disk_size_gb = 64
num_shards = 1
mongo_db_major_version = "${var.atlas_mongodb_version}"
replication_factor = 3
backup_enabled = true
auto_scaling_disk_gb_enabled = true
//Provider Settings "block"
provider_name = "${var.atlas_provider_name}"
provider_encrypt_ebs_volume = false
provider_instance_size_name = "${var.atlas_cluster_tier}"
provider_region_name = "${var.atlas_region}"
provider_disk_type_name = "P6"
}
# DB admin user to manage the database
resource "mongodbatlas_database_user" "rest" {
username = "${var.dbuser}"
password = "${var.atlas_dbuser_password}"
project_id = "${mongodbatlas_project.rest.id}"
database_name = "admin" # DB where db user created
roles {
role_name = "readWrite"
database_name = "${var.rest_db_name}"
}
}
Thanks, we will check it to find the solution as soon as possible 👍
@bobhlo, Modified your code to make it more readable.
Hello @@bobhlo, the issue was resolved you can test it on pr #22
If you have another issue or comments just let us know, thank you.
@PacoDw , thanks for the fix. The issue is resolved.
The initial deployment succeeded with peer successfully created, but subsequent deployment failed with following error even without any changes. The error indicates that the peer is Not Found under the project, but the peer does exist.
module.dev_jcdigital_test345_prep.null_resource.prep (local-exec): WARNING: The behavior of this command has been altered by the following extension: aks-preview 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: 2019/08/30 11:15:50 [DEBUG] MongoDB Atlas API Response Details: 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: ---[ RESPONSE ]-------------------------------------- 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: HTTP/2.0 404 Not Found 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: Content-Length: 228 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: Content-Type: application/json 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: Date: Fri, 30 Aug 2019 18:15:50 GMT 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: Strict-Transport-Security: max-age=300 2019-08-30T11:15:50.785-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: { 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: "detail": "No peer with ID 5d696758014b767112cf712c exists in project 5d68017b014b767112c77330.", 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: "error": 404, 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: "errorCode": "PEER_NOT_FOUND", 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: "parameters": [ 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: "5d696758014b767112cf712c", 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: "5d68017b014b767112c77330" 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: ], 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: "reason": "Not Found" 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: } 2019-08-30T11:15:50.786-0700 [DEBUG] plugin.terraform-provider-mongodbatlas: ----------------------------------------------------- 2019/08/30 11:15:50 [DEBUG] module.dev_jcdigital_test345_atlas.mongodbatlas_network_peering.rest: apply errored, but we're indicating that via the Error pointer rather than returning it: error updating MongoDB Network Peering Connection (5d696758014b767112cf712c): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/5d68017b014b767112c77330/peers/5d696758014b767112cf712c: 404 (request "Not Found") No peer with ID 5d696758014b767112cf712c exists in project 5d68017b014b767112c77330. 2019/08/30 11:15:50 [ERROR] module.dev_jcdigital_test345_atlas: eval: terraform.EvalApplyPost, err: error updating MongoDB Network Peering Connection (5d696758014b767112cf712c): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/5d68017b014b767112c77330/peers/5d696758014b767112cf712c: 404 (request "Not Found") No peer with ID 5d696758014b767112cf712c exists in project 5d68017b014b767112c77330. 2019/08/30 11:15:50 [ERROR] module.dev_jcdigital_test345_atlas: eval: terraform.EvalSequence, err: error updating MongoDB Network Peering Connection (5d696758014b767112cf712c): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/5d68017b014b767112c77330/peers/5d696758014b767112cf712c: 404 (request "Not Found") No peer with ID 5d696758014b767112cf712c exists in project 5d68017b014b767112c77330.
cdsfmbbl1:bob-jc-sense-tf cdsfblo$ curl --user "unllvfyp:" --digest \