Giter VIP home page Giter VIP logo

mongodb / terraform-provider-mongodbatlas Goto Github PK

View Code? Open in Web Editor NEW
228.0 31.0 166.0 33.02 MB

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform

Home Page: https://registry.terraform.io/providers/mongodb/mongodbatlas

License: Mozilla Public License 2.0

Makefile 0.20% Go 97.71% Shell 1.23% HCL 0.86%
terraform-provider mongodbatlas terraform mongodb-atlas-provider atlas

terraform-provider-mongodbatlas's Introduction

MongoDB Atlas Provider

Code Health Acceptance Tests

This is the repository for the Terraform MongoDB Atlas Provider, which allows one to use Terraform with MongoDB's Database as a Service offering, Atlas. Learn more about Atlas at https://www.mongodb.com/cloud/atlas

For general information about Terraform, visit the official website and the GitHub project page.

Support, Bugs, Feature Requests

Support for the Terraform MongoDB Atlas Provider is provided under MongoDB Atlas support plans. Please submit support questions within the Atlas UI. Support questions submitted under the Issues section of this repo will be handled on a "best effort" basis.

Bugs should be filed under the Issues section of this repo.

Feature requests can be submitted at https://feedback.mongodb.com/forums/924145-atlas - just select the Terraform plugin as the category or vote for an already suggested feature.

Requirements

Using the Provider

To use a released provider in your Terraform environment, run terraform init and Terraform will automatically install the provider. To specify a particular provider version when installing released providers, see the Terraform documentation on provider versioning.

Documentation about the provider specific configuration options can be found on the provider's website.

Preview Features

In order to use and/or test preview resources and datasources in this provider you'll need to set the environment variable MONGODB_ATLAS_ENABLE_PREVIEW to true.

export MONGODB_ATLAS_ENABLE_PREVIEW=true

Logs

To help with issues, you can turn on Logs with export TF_LOG=TRACE. Note: this is very noisy.

To export logs to file, you can use export TF_LOG_PATH=terraform.log

Supported OS and Architectures

As per HashiCorp's recommendations, we fully support the following operating system / architecture combinations:

  • Darwin / AMD64
  • Darwin / ARMv8
  • Linux / AMD64
  • Linux / ARMv8 (sometimes referred to as AArch64 or ARM64)
  • Linux / ARMv6
  • Windows / AMD64

We ship binaries but do not prioritize fixes for the following operating system / architecture combinations:

  • Linux / 386
  • Windows / 386
  • FreeBSD / 386
  • FreeBSD / AMD64

Troubleshooting

See Troubleshooting.

Developing the Provider

See our contributing guides.

Issues

Autoclose stale issues and PRs

  • After 5 days of no activity (no comments or commits on an issue/PR) we automatically tag it as "stale" and add a message: This issue/PR has gone 5 days without any activity and meets the project's definition of "stale". This will be auto-closed if there is no new activity over the next 5 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!
  • After 5 more days of no activity we automatically close the issue/PR.

One-click reproducible issues principle

Our support will prioritise issues that contain all the required information that follows the following principles:

  • We should be able to make no changes to your provided script and successfully run a local execution reproducing the issue.
    • This means that you should kindly provide all the required instructions. This includes but not limited to:
      • Terraform Atlas provider version used to reproduce the issue
      • Terraform version used to reproduce the issue
    • Configurations that cannot be properly executed will be de-prioritised in favour of the ones that succeed.
  • Before opening an issue, you have to try to specifically isolate it to Terraform MongoDB Atlas provider by removing as many dependencies as possible. If the issue only happens with other dependencies, then:
    • If other terraform providers are required, please make sure you also include those. Same "one-click reproducible issue" principle applies.
    • If external components are required to replicate it, please make sure you also provides instructions on those parts.
  • Please confirm if the platform being used is Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment

Thanks

We'd like to thank Akshay Karle for writing the first version of a Terraform Provider for MongoDB Atlas and paving the way for the creation of this one.

terraform-provider-mongodbatlas's People

Contributors

abner-dou avatar agustinbettati avatar andreaangiolillo avatar basst avatar cgriggs01 avatar codergo93 avatar dependabot[bot] avatar espenalbert avatar evertsd avatar github-actions[bot] avatar gmlp avatar gssbzn avatar horgix avatar keisukeyamashita avatar lantoli avatar leofigy avatar maastha avatar marcosuma avatar marinsalinas avatar martinstibbe avatar mihaibojin avatar nikhil-mongo avatar nsmith78660 avatar oarbusi avatar pacodw avatar svc-apix-bot avatar themantissa avatar wtrocki avatar zach-carr avatar zuhairahmed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-mongodbatlas's Issues

Whitelisted Project IPs when manually deleted causes failure at next plan/apply

Version affected
terraform-provider-mongodbatlas 0.3.1

How to reproduce
Use mongodbatlas_project_ip_whitelist to whitelist a list of IPs
Terraform plan & apply
Delete all of the IP whitelisted addresses.
Run terraform plan & apply

Expected Behaviour
The whitelisted IP is recreated.

Actual behaviour
Upon re-running the terraform plan this is reported (example):

Error: error getting project IP whitelist information: GET https://cloud.mongodb.com/api/atlas/v1.0/groups/5dc3051579358e9725c677e8/whitelist/139.14.250.168%2F29: 404 (request "Not Found") IP Address 139.14.250.168/29 not on Atlas whitelist for group 5dc3021579358e9745c677e8.

Workaround
The above error will be reported individually for each IP that is missing, but only one error per plan until each is manually re-added (which is quite tedious, to say the least, especially if some are dynamically generated).

Notes
The resource also does not notice changes in the comment field and therefore does not modify them to match the terraform.

expose 'paused' as an argument for mongodbatlas_cluster

It would be great if you are able to expose paused as an argument for mongodbatlas_cluster

We have a requirement to pause our non-prod Atlas MongoDB estate on a nightly basis so being able to use this argument for the mongodbatlas_cluster resource would really help

missing schema for provider "mongodbatlas" resource type mongodbatlas_ip_whitelist

I'm trying to update our mongodbatlas provider to the latest but I'm running into an error during the planning phase:

Error: no schema available for <censored>.mongodbatlas_ip_whitelist.ip_whitelist while reading state; this is a bug in Terraform and should be reported

Trying to look at the state fails with the same error:

terraform state show <censored>.mongodbatlas_ip_whitelist.ip_whitelist
# <censored>.mongodbatlas_ip_whitelist.ip_whitelist:
# missing schema for provider "mongodbatlas" resource type mongodbatlas_ip_whitelist

Any idea what's going on? :)

Failed to create Atlas network peering container

The json payload looks fine but the plugin throws a 400 error.

main.tf

Configure the MongoDB Atlas Provider

provider "mongodbatlas" {
public_key = "${var.mongodb_atlas_username}"
private_key = "${var.mongodb_atlas_api_key}"
version = "=0.1.0"
}

Create a Group

resource "mongodbatlas_project" "rest" {
org_id = "${var.mongodb_atlas_org_id}"
name = "${var.project_name}"
}

Create a Container

resource "mongodbatlas_network_container" "rest" {
project_id = "${mongodbatlas_project.rest.id}"
atlas_cidr_block = "192.168.32.0/21"
provider_name = "Azure"
region = "US_EAST_2"
}

Excerpt from terraform apply
mongodbatlas_network_container.rest: Creating...
2019/08/27 10:33:33 [DEBUG] mongodbatlas_network_container.rest: applying the planned Create change
2019/08/27 10:33:33 [TRACE] GRPCProvider: ApplyResourceChange
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 2019/08/27 10:33:33 [DEBUG] MongoDB Atlas API Request Details:
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: ---[ REQUEST ]---------------------------------------
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: POST /api/atlas/v1.0/groups/5d6567b9cf09a25f515f8a89/containers HTTP/1.1
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Host: cloud.mongodb.com
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: User-Agent: go-mongodbatlas0.1
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Content-Length: 81
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Accept: application/json
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Content-Type: application/json
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Accept-Encoding: gzip
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: {
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "atlasCidrBlock": "192.168.32.0/21",
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "providerName": "Azure",
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "region": "US_EAST_2"
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: }
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:
2019-08-27T10:33:33.203-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: -----------------------------------------------------
2019-08-27T10:33:33.830-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 2019/08/27 10:33:33 [DEBUG] MongoDB Atlas API Response Details:
2019-08-27T10:33:33.830-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: ---[ RESPONSE ]--------------------------------------
2019-08-27T10:33:33.830-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: HTTP/2.0 400 Bad Request
2019-08-27T10:33:33.830-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Content-Length: 136
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Content-Type: application/json
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Date: Tue, 27 Aug 2019 17:33:33 GMT
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Strict-Transport-Security: max-age=300
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: {
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "detail": "Received JSON does not match expected format.",
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "error": 400,
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "errorCode": "INVALID_JSON",
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "parameters": [],
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: "reason": "Bad Request"
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: }
2019-08-27T10:33:33.831-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: -----------------------------------------------------
2019/08/27 10:33:33 [DEBUG] mongodbatlas_network_container.rest: apply errored, but we're indicating that via the Error pointer rather than returning it: error creating MongoDB Network Peering Container: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/5d6567b9cf09a25f515f8a89/containers: 400 (request "Bad Request") Received JSON does not match expected format.
2019/08/27 10:33:33 [TRACE] : eval: *terraform.EvalMaybeTainted
2019/08/27 10:33:33 [TRACE] EvalMaybeTainted: mongodbatlas_network_container.rest encountered an error during creation, so it is now marked as tainted
2019/08/27 10:33:33 [ERROR] : eval: *terraform.EvalSequence, err: error creating MongoDB Network Peering Container: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/5d6567b9cf09a25f515f8a89/containers: 400 (request "Bad Request") Received JSON does not match expected format.

Error: error creating MongoDB Network Peering Container: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/5d6567b9cf09a25f515f8a89/containers: 400 (request "Bad Request") Received JSON does not match expected format.

on main.tf line 15, in resource "mongodbatlas_network_container" "rest":
15: resource "mongodbatlas_network_container" "rest" {

2019-08-27T10:33:33.847-0700 [DEBUG] plugin: plugin process exited: path=/Users/cdsfblo/workspace/tf/bob-jc-sense-tf/modules/site/atlas/.terraform/plugins/darwin_amd64/terraform-provider-mongodbatlas_v0.1.0_x4 pid=76507
2019-08-27T10:33:33.847-0700 [DEBUG] plugin: plugin exited

Version 0.3.0

Hey guys, thanks for the amazing work, this Terraform provider is very useful. I see a number of improvements have been done in the last days. Could you please release a new 0.3.0 version with all the fixes? ๐Ÿ™ At the moment I am stuck because of #29, which was already solved in #43.

Add pitEnabled feature of mongodbatlas_cluster resource

Iโ€™m trying to automate the deployment of our MongoDB Atlas estate. MongoDB Atlas has an API as part of the cluster configuration which allows to set point in time restore pitEnabled

https://docs.atlas.mongodb.com/reference/api/clusters-create-one/

Looking in the documentation for the terraform resource mongodbatlas_cluster it doesnโ€™t have this option

https://www.terraform.io/docs/providers/mongodbatlas/r/cluster.html

Is there a plan to implement this?

Cluster fails to build on 0.3.1 when mongo_db_major_version is not specified

Hey folks,

Using version 0.3.1, if you omit mongo_db_major_version on the mongodbatlas_cluster resource then you'll hit an API error as the provider is sending along the following:

2019-11-27T22:06:32.115-0500 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4:  "mongoDBMajorVersion": "0.0",

This doesn't seem to be an issue with 0.3.0, so is likely something introduced in 0.3.1.

The docs for the mongodbatlas_cluster resource indicate that this argument is optional, so this does appear to be a bug.

Thanks for having a look!

--Matt

mongodbatlas_network_peering outputting invalid json

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)}"
}

Cannot update GCP network peer

What I did: Import a mongodbatlas_network_peering resource and run terraform apply to apply the route_table_cidr_block change it thinks it needs to make (asserting the same value)

What I expected: The change to be successful

What happened:
Error: error updating MongoDB Network Peering Connection (our-group-id): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/our-group-id/peers/our-peer-id: 404 (request "Not Found") No peer with ID our-peer-id exists in project our-group-id

Looking at the MongoDB API and the code, it looks like the default provider of AWS is being applied and thus the peering connection isn't found since we are using GCP.

Plugin version: 0.3.1
Terraform version: v0.12.17

Syntax are not mandatory and creates confusion

To launch a cluster using terraform,
mongo_db_major_version = โ€œ4.0โ€ // this is in documentation and requires the version to be in string, but with version 4.2
mongo_db_major_version = 4.2 // this will work without the โ€œโ€.

Please see if any changes need to be made to make this mandatory.

Bug: Invalid attribute diskIOPS specified.

Good morning,

I use Terraform v0.12.5 and I try to create a Atlas Mongodb cluster :

resource "mongodbatlas_cluster" "cluster" {
  project_id    = "XXXXX"
  name         = "cluster-test"
  disk_size_gb = 40
  num_shards   = 1
  replication_factor           = 3
  backup_enabled               = true
  provider_name               = "GCP"
  provider_disk_iops          = 1200
  provider_instance_size_name = "M30"
  provider_region_name        = "US_EAST_4"
}

It return this error:
error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxx/clusters: 400 (request "Bad Request") Invalid attribute diskIOPS specified.

I change remove provider_disk_iops and disk_size_gb but the error is always the same.

Thank you

Problem encryption_at_rest

Good morning,

I create an IAM service account, KMS keyring and key in my own GCP account.

#Service Account for KMS
resource "google_service_account" "encryption_at_rest" {
  count         = var.encryption_at_rest_provider == true ? 1 : 0
  project       = var.gcp_project_id
  account_id    = "atlas-encrypt-${var.cluster_name}"
  display_name  = "atlas-encrypt-${var.cluster_name}"
}

#IAM Policy for KMS
resource "google_project_iam_member" "encryption_at_rest" {
  count   = var.encryption_at_rest_provider == true ? 1 : 0
  project = var.gcp_project_id
  role    = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
  member  = "serviceAccount:atlas-encrypt-${var.cluster_name}@${var.gcp_project_id}.iam.gserviceaccount.com"
}

#Create service account key
resource "google_service_account_key" "encryption_at_rest" {
  count               = var.encryption_at_rest_provider == true ? 1 : 0
  service_account_id  = google_service_account.encryption_at_rest[count.index].name
  public_key_type     = "TYPE_X509_PEM_FILE"
}

#######################
#        KMS          #
#######################

# Create keyring for encryption_at_rest
resource "google_kms_key_ring" "encryption_at_rest" {
  count     = var.encryption_at_rest_provider == true ? 1 : 0
  project   = var.gcp_project_id
  name      = "atlas-${var.cluster_name}"
  location  = "global"
}
resource "google_kms_crypto_key" "crypto_key" {
  count     = var.encryption_at_rest_provider == true ? 1 : 0
  name      = "atlas-crypto-key"
  key_ring  = google_kms_key_ring.encryption_at_rest[count.index].id

  depends_on = [ "google_kms_key_ring.encryption_at_rest" ]
}

# Atlas encryption_at_rest
resource "mongodbatlas_encryption_at_rest" "kms" {
  count                     = var.encryption_at_rest_provider == true ? 1 : 0
  project_id                = mongodbatlas_project.project.id
  google_cloud_kms = {
    enabled                 = var.encryption_at_rest_provider
    service_account_key     = base64decode(google_service_account_key.encryption_at_rest[count.index].private_key)
    key_version_resource_id = "${google_kms_crypto_key.crypto_key[count.index].id}/cryptoKeyVersions/1"
  }

  depends_on = [ "mongodbatlas_project.project", "google_kms_crypto_key.crypto_key", "google_service_account_key.encryption_at_rest" ]
}

It returns the following error:
Error: error creating Encryption at Rest: PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxxx/encryptionAtRest: 400 (request "Bad Request") Invalid Google Cloud credentials.

If I only specified encryption_at_rest_provider = true in mongodbatlas_cluster resource

resource "mongodbatlas_cluster" "cluster" {
  project_id                   = mongodbatlas_project.project.id
  name                         = var.cluster_name
  backup_enabled               = var.backup_enabled
  auto_scaling_disk_gb_enabled = true
  mongo_db_major_version       = var.mongodb_version
   encryption_at_rest_provider = true

  //Provider Settings "block"
  provider_name               = "GCP"
  disk_size_gb                = var.size_gb
  provider_instance_size_name = var.instance_type
  provider_region_name        = var.region

  //depends_on                  = ["mongodbatlas_project.project", "mongodbatlas_encryption_at_rest.kms"]
}

It returns the following error:
Error: error updating MongoDB Cluster (mongodb-ag-dev): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxxx/clusters/mongodb-ag-dev: 400 (request "Bad Request") An invalid enumeration value true was specified.

Is my code right? Could you explain me how to implement encryption_at_rest in Atlas?

Thank you so much.

specify oplog size?

hello,

when will the mongodbatlas_cluster resource have support for setting the oplog size? i dont see anything in the docs atm.

i also stood up a cluster via tf, set the oplog size manually in the console, and then ran a terraform plan which results in No changes. Infrastructure is up-to-date. . This would imply oplog size isn't supported at all yet.

thanks.

Upgrade from M2 to M10 fails

Upgrade from M2 to M10 fails

It does not seem to be possible to upgrade an M2 cluster to an M10 cluster even though it's possible via the Atlas UI (and I assume via the API).

I have attached two tf files that show the cluster definitions before and after. Both can be used to create new clusters without any error.

To reproduce, use the following commands:

export MONGODB_ATLAS_PUBLIC_KEY="abcd"
export MONGODB_ATLAS_PRIVATE_KEY="abcd-abcd"
export TF_VAR_project_id="1234"

cp main.tf.1 main.tf 
terraform init
terraform apply

cp main.tf.2 main.tf
terraform apply

This fails with the error message "400 (request "Bad Request") Invalid attribute backingProviderName specified." which leads me to speculate that even though backing_provider_name is not set in the main.tf.2 it somehow gets transferred to the atlas API.

If I do instead

 terraform taint mongodbatlas_cluster.issue  
 terraform apply

it works but (of course) the data in the cluster is lost.

main.tf.zip

GCP peering problem

I am trying to configure peering atlas to GCP account

resource "mongodbatlas_network_container" "network_container" {
  project_id       = "PROJECT_ID"
  atlas_cidr_block = "192.168.0.0/16"
  provider_name    = "GCP"
}

resource "mongodbatlas_network_peering" "network_peering" {
  project_id        = "PROJECT_ID"
  container_id      = mongodbatlas_network_container.network_container.id
  provider_name     = "GCP"
  gcp_project_id  = "GCP_PROJECT_ID"
  network_name    = "VPC_ID"
}

resource "google_compute_network_peering" "atlas_peer" {
  name = "atlas-peer"
  network = "VPC_ID"
  peer_network = "https://www.googleapis.com/compute/v1/projects/${mongodbatlas_network_peering.network_peering.gcp_project_id}/global/networks/${mongodbatlas_network_peering.network_peering.network_name}"
  depends_on = [mongodbatlas_network_peering.network_peering]
}

The resource mongodbatlas_network_peering is stuck,
The Atlas API for getting the peering, show the status WAITING_FOR_USER.

I see on the documentation of MongoDB that the status of network peering on GCP are
ADDING_PEER
WAITING_FOR_USER
AVAILABLE
FAILED
DELETING

So the mongodbatlas_network_peering resource should be finished on WAITING_FOR_USER,
be able to apply the google_compute_network_peering

terraform version: v0.12.1
Atlas provider version: 0.1.0

Creating M2 cluster without specifying disk_size_gb results in 400 Bad Request

Excerpt from my main.tf file:

resource "mongodbatlas_cluster" "cluster-test" {
  project_id   = mongodbatlas_project.testing.id
  name         = "testing-cluster"

  backup_enabled               = false
  auto_scaling_disk_gb_enabled = false
  mongo_db_major_version       = "4.0"

  //Provider Settings "block"
  provider_name               = "TENANT"
  backing_provider_name       = "AWS"
  provider_instance_size_name = "M2"
  provider_region_name        = "eu-west-1"
}

According to the documentation, disk_size_gb is optional and should default to the minimum (2GB for an M2) but I get an error: 400 (request "Bad Request") The cluster's disk size of 0.0 GB is invalid".

If I specify disk_size_gb = 2 it works as expected.

mongodbatlas_network_container Already exists

I think this is the valid scenario to reproduce the issue:

Terraform:

  1. In Terraform, Create project, container, cluster, VPC peering to AWS VPC, from scratch.
  2. Outside of Terraform, in dashboard, add a new cluster to that project.
  3. In Terraform, destroy resources. Successful. Project remains though because manually created cluster.
  4. In Terraform, try and recreate cluster (just destroyed) with same variables. You will get error A container already exists for group. (Also get similar project error but it makes sense to do terraform import for that)

When querying the API manually to GET containers, it is returning provisioned to a AWS VPC that no longer exists (we destroyed the VPC peering with the initial cluster):

    "results": [
        {
            "atlasCidrBlock": "10.251.0.0/24",
            "id": "5d4eeb35cf09a24bd2acec99",
            "providerName": "AWS",
            "provisioned": true,
            "regionName": "US_EAST_1",
            "vpcId": "vpc-02b97143f09238a26"
        }
    ],

Expected:
Ignore existing container with old VPC and create new one. Maybe Atlas backend hasn't purged it yet?

Workaround:
Import existing container so terraform can apply/deploy the new cluster.

BUG after deploy:

Error creating MongoDB Cluster

Error: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxxx/clusters: 500 (request "Internal Server Error") Unexpected error.

Seems like API servers had issue.

terraform version: v0.12.3
Atlas provider version: 0.1.0
terraform configuration: https://gist.github.com/deepak7093/c286f09316142d424832148f36d47c4a
Debug Logs

2019/08/22 18:49:29 [DEBUG] mongodbatlas_cluster.clusters-copilot[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxxx/clusters: 500 (request "Internal Server Error") Unexpected error.
2019/08/22 18:49:29 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2019/08/22 18:49:29 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxx/clusters: 500 (request "Internal Server Error") Unexpected error.
2019/08/22 18:49:29 [ERROR] <root>: eval: *terraform.EvalSequence, err: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxxx/clusters: 500 (request "Internal Server Error") Unexpected error.
2019/08/22 18:49:29 [TRACE] [walkApply] Exiting eval tree: mongodbatlas_cluster.clusters-copilot[0]
2019/08/22 18:49:29 [TRACE] vertex "mongodbatlas_cluster.clusters-copilot[0]": visit complete
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 2019/08/22 18:49:29 [DEBUG] MongoDB Atlas API Response Details:
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: ---[ RESPONSE ]--------------------------------------
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: HTTP/2.0 500 Internal Server Error
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Content-Length: 122
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Content-Type: application/json
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Date: Thu, 22 Aug 2019 13:19:29 GMT
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: Strict-Transport-Security: max-age=300
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: {
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  "detail": "Unexpected error.",
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  "error": 500,
2019-08-22T18:49:29.324+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  "errorCode": "UNEXPECTED_ERROR",
2019-08-22T18:49:29.325+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  "parameters": [],
2019-08-22T18:49:29.325+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  "reason": "Internal Server Error"
2019-08-22T18:49:29.325+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: }
2019-08-22T18:49:29.325+0530 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: -----------------------------------------------------
2019/08/22 18:49:29 [DEBUG] mongodbatlas_cluster.clusters-fabric[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxx/clusters: 500 (request "Internal Server Error") Unexpected error.
2019/08/22 18:49:29 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2019/08/22 18:49:29 [TRACE] EvalMaybeTainted: mongodbatlas_cluster.clusters-fabric[0] encountered an error during creation, so it is now marked as tainted

Error: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxxx/clusters: 500 (request "Internal Server Error") Unexpected error.

Bug VPC Peering between GCP and Atlas

Good morning,

I try to create peering between MongoDB Atlas Project and my VPC in GCP.

resource "mongodbatlas_network_peering" "main_peering" {
  project_id        = mongodbatlas_project.project.id
  container_id      = mongodbatlas_network_container.container.container_id
  provider_name     = "GCP"
  gcp_project_id    = var.gcp_project_id
  network_name      = var.gcp_main_network_name
  depends_on       = ["mongodbatlas_network_container.container"]
}

resource "google_compute_network_peering" "gcp_main_atlas_peering" {
  name = "atlas-gcp-main"
  network = var.gcp_main_network_link
 peer_network="projects/${mongodbatlas_network_peering.main_peering.project_id}/global/networks/${mongodbatlas_network_peering.main_peering.network_name}"
}

But It never finish. I try it several times but it always finished with the same error:

module.atlas.mongodbatlas_network_peering.main_peering: Still creating... [45m3s elapsed]

Error: rpc error: code = Unavailable desc = transport is closing

In the Atlas website appear this message:
Create a reciprocal connection from GCP to Atlas to complete this connection. Show me how

Thank you,

Confirmation on timelimit for a terraform apply

I created a create cluster file and the terraform ran for 12m to create the cluster. But then it threw 500 server error. Is this the time limit to complete a plan?

Error:
mongodbatlas_cluster.atlas_cluster: Still creating... [12m0s elapsed]

Error: error creating MongoDB Cluster: GET https://cloud.mongodb.com/api/atlas/v1.0/groups/5cd520dca6f239768087f39e/clusters/cluster-atlas: 500 (request "Server Error") 

  on cluster.tf line 1, in resource "mongodbatlas_cluster" "atlas_cluster":
   1: resource "mongodbatlas_cluster" "atlas_cluster" {

On the other hand, the cluster is created in the Atlas. And now when I run terraform destroy it shows no plan.

data source mongodbatlas_network_peering retrieves the same for id and connection_id

Hi, I am requesting network peering from Atlas to my VPC and would like to accept it with aws_vpc_peering_connection_accepter. I tested many ways but still cannot get the pcx- identifier.
Now I tried data source mongodbatlas_network_peering but it retrieves internal Atlas connection ID when I use the id and connection_id attribute of the data source.

Error: Error reading VPC Peering Connection: InvalidVpcPeeringConnectionId.Malformed: Invalid id: "5dbxxxxxxxxxxxxxxxx" (expecting "pcx-...")
	status code: 400, request id: 7a220e0c-6278-47ed-bffd-e3bbe55a85cc

I would like to get the pcx- identifier for the accepter resource but can't figure out how.
I see that Atlas API doesn't return this value in the responses - can Atlas add this into the response so this could be retrieved with the data source? Or even better - refer to it as attribute of the mongodbatlas_network_peering resource?

Cluster creation with Azure provider failed

Provider settings diskIOPS and EncryptEBSVolume should be excluded in the payload when creating a cluster with Azure provider. Need conditional checks for providers in a few places such as https://github.com/terraform-providers/terraform-provider-mongodbatlas/blob/master/mongodbatlas/resource_mongodbatlas_cluster.go#L600-L601. See Atlas API doc - https://docs.atlas.mongodb.com/reference/api/clusters-create-one/ which indicates the two optional settings for AWS.

An invalid enumeration value US_EAST_1 was specified.

Can anyone explain why I'm getting the below error?

Error: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/5d9d6380014b76f54c449b2b/clusters: 400 (request "Bad Request") An invalid enumeration value US_EAST_1 was specified.

This is my tf file

resource "mongodbatlas_project" "project" {
    name   = "project"
    org_id = "${var.mongodb_atlas_organization_id}"
}

resource "mongodbatlas_cluster" "cluster" {
  project_id   = "${mongodbatlas_project.project.id}"
  name         = "cluster"

  cluster_type                 = "REPLICASET"
  replication_factor           = 3
  backup_enabled               = true
  auto_scaling_disk_gb_enabled = true
  mongo_db_major_version       = "4.0"

  provider_instance_size_name = "M10"
  provider_name               = "GCP"
  disk_size_gb                = 10
  provider_region_name        = "US_EAST_1"
}

Not able to create M0 clusters

Hello,

For some reason I can't create M0 clusters via terraform. Meanwhile I can do it in the UI.

resource "mongodbatlas_cluster" "default" {
  name                        = "M0"
  project_id                  = mongodbatlas_project.backend.id
  provider_name               = "GCP"
  provider_region_name        = "WESTERN_EUROPE"
  provider_instance_size_name = "M0"
}

Error: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/XXX/clusters: 400 (request "Bad Request") An invalid enumeration value M0 was specified.

resource "mongodbatlas_cluster" "default" {
  name                        = "M0"
  project_id                  = mongodbatlas_project.backend.id
  provider_name               = "TENANT"
  provider_region_name        = "WESTERN_EUROPE"
  provider_instance_size_name = "M0"
}

Error: error creating MongoDB Cluster: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/XXX/clusters: 400 (request "Bad Request") Invalid attribute instanceSizeName specified.

mongodbatlas_encryption_at_rest outputs IAM secrets to stdout

Hi,

I'm using the module mongodbatlas_encryption_at_rest to setup encryption and i noticed that the module is outputting my IAM secre to console/stdout. It would be great if this information can be redacted in some way since i wouldn't want this leaked through my logs.

"terraform" 0.11.14
"mongodbatlas" 0.3.1
"template" 2.1.2
"aws" 2.42.0

Terraform will perform the following actions:

  + mongodbatlas_encryption_at_rest.encryption
      id:                                                          <computed>
      aws_kms.%:                                                   "5"
      aws_kms.access_key_id:                                       "SOMEKEY"
      aws_kms.customer_master_key_id:                              "SOMEMASTERKEY"
      aws_kms.enabled:                                             "1"
      aws_kms.region:                                              "US_WEST_2"
      aws_kms.secret_access_key:                                   "oopsmysecrets"
      project_id:                                                  "MYPROJECT"



Problem destroying network peering container

Good morning,

I try to destroy my Atlas stack:

provider "mongodbatlas" {
  public_key = "xxxxxx"
  private_key  = "yyyyy"
}

resource "mongodbatlas_project" "project" {
  name   = var.project_name
  org_id = var.org_id
}

resource "mongodbatlas_network_container" "container" {
  project_id       = mongodbatlas_project.project.id
  atlas_cidr_block = var.atlas_cidr
  provider_name    = "GCP"
  depends_on       = ["mongodbatlas_project.project"]
}


resource "null_resource" "atlas_private_mode" {
  provisioner "local-exec" {
    command = <<EOF
      curl --user  "xxxxxx:yyyyyyy" --digest --header "Accept: application/json" \
      --header "Content-Type: application/json" \
      --include \
      --request PATCH "https://cloud.mongodb.com/api/atlas/v1.0/groups/${mongodbatlas_project.project.id}/privateIpMode?pretty=true" \
      --data '{"enabled" : true}'
    EOF
  }
  depends_on = ["mongodbatlas_project.project"]
}

resource "mongodbatlas_cluster" "cluster" {
  project_id                   = mongodbatlas_project.project.id
  name                         = var.cluster_name

  backup_enabled               = var.backup_enabled
  auto_scaling_disk_gb_enabled = true
  mongo_db_major_version       = var.mongodb_version

  //Provider Settings "block"
  provider_name               = "GCP"
  disk_size_gb                = var.size_gb
  provider_instance_size_name = var.instance_type
  provider_region_name        = var.region

  depends_on                  = ["mongodbatlas_project.project"]
}

It shows this error:

Error: error deleting MongoDB Network Peering Container (5d7ba8a9c56c98b9eec8448d): DELETE https://cloud.mongodb.com/api/atlas/v1.0/groups/5d7ba8a7f2a30b18d0bcc33b/containers/5d7ba8a9c56c98b9eec8448d: 409 (request "Conflict") Cannot modify in use containers. The container still contained resources.

It isn't any cluster or network parameter in the Atlas console. Finally, I have to remove this resource manually from terraform tfstate.

Thank you,

plugin.terraform-provider-mongodbatlas_v0.2.0_x4: panic: runtime error: index out of range

Terraform Version

v0.11.14

Terraform Configuration Files

resource "mongodbatlas_cluster" "ff3_dev" {
  auto_scaling_disk_gb_enabled = false
  backing_provider_name        = "AWS"
  backup_enabled               = false
  mongo_db_major_version       = "4.0"
  name                         = "ff3_dev"
  project_id                   = "foobarbaz"
  provider_instance_size_name  = "M0"
  provider_name                = "TENANT"
  provider_region_name         = "${upper(replace(var.aws_region, "-", "_"))}"
}

Crash Output

https://gist.github.com/acim/38b1f36ab10db14ba7460b7a7f130b07

Expected Behavior

Plan should display what has to be modified.

Actual Behavior

Crash.

Steps to Reproduce

  1. terraform init
  2. terraform plan -target=mongodbatlas_cluster.ff3_dev

Additional Context

I previously used 3rd party mongodbatlas provider when no other version was available. Now I switched to the official version but terraform crashes.

Renaming a project forces replacement

Changing the name of a mongodbatlas_project causes a replacement which then trickles down and causes a replacement for all the clusters (and other resources) as well. A simple rename should not cause a replacement, as I can rename a project in the Atlas Web UI and it does not force anything to be recreated.

# module.name.mongodbatlas_project.main must be replaced
-/+ resource "mongodbatlas_project" "main" {
      ~ cluster_count = 1 -> (known after apply)
      ~ created       = "2019-11-01T23:57:42Z" -> (known after apply)
      ~ id            = "xxxxxxxxxxxx" -> (known after apply)
      ~ name          = "Old Name" -> "New Name" # forces replacement
        org_id        = "yyyyyyyyyyyyy"
    }

Error encryption_at_rest rpc unavailable desc

Good morning,

I create an IAM service account, KMS keyring and key in my own GCP account.

#Service Account for KMS
resource "google_service_account" "encryption_at_rest" {
  count         = var.encryption_at_rest_provider == "GCP" ? 1 : 0
  project       = var.gcp_project_id
  account_id    = "atlas-encrypt-${var.cluster_name}"
  display_name  = "atlas-encrypt-${var.cluster_name}"
}

#IAM Policy for KMS
resource "google_project_iam_member" "encryption_at_rest_admin" {
  count   = var.encryption_at_rest_provider == "GCP" ? 1 : 0
  project = var.gcp_project_id
  role    = "roles/cloudkms.admin"
  member  = "serviceAccount:atlas-encrypt-${var.cluster_name}@${var.gcp_project_id}.iam.gserviceaccount.com"
}
resource "google_project_iam_member" "encryption_at_rest_decrypt" {
  count   = var.encryption_at_rest_provider == "GCP" ? 1 : 0
  project = var.gcp_project_id
  role    = "roles/
cloudkms.cryptoKeyEncrypterDecrypter"
  member  = "serviceAccount:atlas-encrypt-${var.cluster_name}@${var.gcp_project_id}.iam.gserviceaccount.com"
}

#Create service account key
resource "google_service_account_key" "encryption_at_rest" {
  count               = var.encryption_at_rest_provider == "GCP" ? 1 : 0
  service_account_id  = google_service_account.encryption_at_rest[count.index].name
  public_key_type     = "TYPE_X509_PEM_FILE"
}

# Atlas encryption_at_rest
resource "mongodbatlas_encryption_at_rest" "kms" {
  count      = var.encryption_at_rest_provider == "GCP" ? 1 : 0
  project_id = mongodbatlas_project.project.id

  google_cloud_kms = {
    enabled                 = true
    service_account_key     = jsonencode(base64decode(google_service_account_key.encryption_at_rest[count.index].private_key))
    key_version_resource_id = var.encryption_at_rest_key_version
  }
  depends_on = [ "mongodbatlas_project.project" ]
}

It returns the following error:

  # module.atlas.mongodbatlas_encryption_at_rest.kms[0] will be created
  + resource "mongodbatlas_encryption_at_rest" "kms" {
      + google_cloud_kms = {
          + "enabled"                 = "true"
          + "key_version_resource_id" = "projects/XXXX/locations/global/keyRings/XXXXX/cryptoKeys/XXXXXX/cryptoKeyVersions/1"
          + "service_account_key"     = jsonencode(
                {
                  + auth_provider_x509_cert_url = "https://www.googleapis.com/oauth2/v1/certs"
                  + auth_uri                    = "https://accounts.google.com/o/oauth2/auth"
                  + client_email                = "XXXXXX"
                  + client_id                   = "XXXXXXX"
                  + client_x509_cert_url        = "XXXXXXX"
                  + private_key                 = "-----BEGIN PRIVATE KEY-----\nXXXXXXXXXXXXX\n-----END PRIVATE KEY-----\n"
                  + private_key_id              = "XXXX"
                  + project_id                  = "XXXXXX"
                  + token_uri                   = "https://oauth2.googleapis.com/token"
                  + type                        = "service_account"
                }
            )
        }
      + id               = (known after apply)
      + project_id       = "XXXXXX"
module.atlas.mongodbatlas_encryption_at_rest.kms[0]: Creating...

Error: rpc error: code = Unavailable desc = transport is closing

I try to create encryption at rest manually with the same service_account_key and key_version_resouce_id and it works.

Is my code right?

Thank you so much!!

Bug: VPC Peering Atlas-GCP

Good afternoon,

I try to create VPC Peering between Atlas and GCP:

resource "mongodbatlas_project" "project" {
  name   = var.project_name
  org_id = var.org_id
}
resource "mongodbatlas_network_container" "container" {
  project_id       = mongodbatlas_project.project.id
  atlas_cidr_block = "10.8.0.0/18"
  provider_name    = "GCP"
  depends_on       = ["mongodbatlas_project.project"]
}

resource "mongodbatlas_network_peering" "main_peering" {
  project_id        = mongodbatlas_project.project.id
  container_id      = mongodbatlas_network_container.container.id
  provider_name     = "GCP"
  gcp_project_id    = var.gcp_project_id
  network_name      = var.gcp_main_network_name
  depends_on       = ["mongodbatlas_network_container.container"]
}

It return this error:
Error: error creating MongoDB Network Peering Connection: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/xxxxxxxx/peers: 500 (request "Internal Server Error") Unexpected error.

Thank you,

PATCH network peering failed with no peer found

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 \

--header "Accept: application/json"
-- request GET "https://cloud.mongodb.com/api/atlas/v1.0/groups/5d68017b014b767112c77330/peers/5d696758014b767112cf712c"
curl: (6) Could not resolve host: request
curl: (6) Could not resolve host: GET
{"azureDirectoryId":"bd2ac3b4-122a-4000-ac98-779c8efd4722","azureSubscriptionId":"38171a42-9a9e-4fa6-ac1f-43b126efd341","containerId":"5d68017d79358ee73ce91501","errorState":null,"id":"5d696758014b767112cf712c","resourceGroupName":"dev-jcdigital-test345-rg","status":"AVAILABLE","vnetName":"dev-jcdigital-test345-vnet"}

Support the vscode terraform extension

Originally posted here but it seems that repo is deprecated and this repo is its replacement.

The terraform extension for vscode uses a language server to provide information to the IDE. When I have this extension enabled within a project using the mongodb atlas provider I get an error in the logs. I have included below. It seems to be trying to call a function named GetSchema against the mongodb atlas provider and then exiting. I tried searching through the terraform-provider-mongodbatlas github repo and did not find any function named GetSchema. I did a similar search against the terrraform repo and it does seem to a be a function that is part of the terraform provider interface here

2019/09/04 17:42:51 [DEBUG] plugin dirs: []string{".", "/home/davidarata/.vscode/extensions/mauve.terraform-1.4.0/lspbin", "terraform.d/plugins/linux_amd64", "/home/davidarata/projects/double-helix/.terraform/plugins/linux_amd64", "/home/davidarata/.terraform.d/plugins", "/home/davidarata/.terraform.d/plugins/linux_amd64", "/home/davidarata/go/bin"}
2019/09/04 17:42:51 [DEBUG] checking for provider in "."
2019/09/04 17:42:51 [DEBUG] checking for provider in "/home/davidarata/.vscode/extensions/mauve.terraform-1.4.0/lspbin"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-alicloud_v1.55.2_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-archive_v1.2.2_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-aws_v2.26.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-azurerm_v1.33.1_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-external_v1.2.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-google_v2.14.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-helm_v0.10.2_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-kubernetes_v1.9.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-null_v2.1.2_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-random_v2.2.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-template_v2.1.2_x4"
2019/09/04 17:42:51 [DEBUG] checking for provider in "/home/davidarata/projects/double-helix/.terraform/plugins/linux_amd64"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-aws_v2.26.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-mongodbatlas_v0.1.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-random_v2.2.0_x4"
2019/09/04 17:42:51 [DEBUG] found provider "terraform-provider-template_v2.1.2_x4"
2019/09/04 17:42:51 [DEBUG] checking for provider in "/home/davidarata/.terraform.d/plugins"
2019/09/04 17:42:51 [DEBUG] checking for provider in "/home/davidarata/.terraform.d/plugins/linux_amd64"
2019-09-04T17:42:51.436-0400 [INFO]  plugin: configuring client automatic mTLS
2019-09-04T17:42:51.545-0400 [DEBUG] plugin: starting plugin: path=/home/davidarata/projects/double-helix/.terraform/plugins/linux_amd64/terraform-provider-mongodbatlas_v0.1.0_x4 args=[/home/davidarata/projects/double-helix/.terraform/plugins/linux_amd64/terraform-provider-mongodbatlas_v0.1.0_x4]
2019-09-04T17:42:51.545-0400 [DEBUG] plugin: plugin started: path=/home/davidarata/projects/double-helix/.terraform/plugins/linux_amd64/terraform-provider-mongodbatlas_v0.1.0_x4 pid=19941
2019-09-04T17:42:51.547-0400 [DEBUG] plugin: waiting for RPC address: path=/home/davidarata/projects/double-helix/.terraform/plugins/linux_amd64/terraform-provider-mongodbatlas_v0.1.0_x4
2019-09-04T17:42:51.565-0400 [INFO]  plugin.terraform-provider-mongodbatlas_v0.1.0_x4: configuring server automatic mTLS: timestamp=2019-09-04T17:42:51.565-0400
2019-09-04T17:42:51.661-0400 [DEBUG] plugin: using plugin: version=5
2019/09/04 17:42:51 [TRACE] GRPCProvider: GetSchema
2019-09-04T17:42:51.661-0400 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: plugin address: address=/tmp/plugin114849465 network=unix timestamp=2019-09-04T17:42:51.661-0400
2019-09-04T17:42:51.878-0400 [DEBUG] plugin: plugin process exited: path=/home/davidarata/projects/double-helix/.terraform/plugins/linux_amd64/terraform-provider-mongodbatlas_v0.1.0_x4 pid=19941
2019-09-04T17:42:51.878-0400 [DEBUG] plugin: plugin exited

mongodbatlas_network_container doesn't form a valid json request

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

mongodbatlas_encryption_at_rest key rotation impossible to perform with Azure KeyVault

When using customer keys for encryption at rest it is possible to rotate encryption keys with no downtime through the MongoDB atlas portal by just specifying a different (and accessible) key ID (it even works by changing any credentials, even using a different KeyVault).

The problem is when using this module's mongodbatlas_encryption_at_rest resource: having a complete project + cluster + encryption set of resources, like so:

resource "mongodbatlas_project" "project" {
  name   = "test-project"
  org_id = "some-org-id"
}

resource "mongodbatlas_cluster" "cluster" {
  project_id = mongodbatlas_project.project.id
  name       = "test-cluster"
  encryption_at_rest_provider = "AZURE"
  provider_name               = "AZURE"
  
  # Other settings...
}

resource "mongodbatlas_encryption_at_rest" "encryption" {
  project_id = mongodbatlas_project.project.id

  # Disabled AWS KMS...

  azure_key_vault = {
    enabled             = true
    #...
    key_identifier      = "SOME-KEY-IDENTIFIER"
    #...
  }

  # Disabled GCE KMS...
}

Now, rotating the encryption key should just be changing the key_identifier value and applying the change. I.e.:

# no changes here...

resource "mongodbatlas_encryption_at_rest" "encryption" {
  project_id = mongodbatlas_project.project.id

  # Disabled AWS KMS...

  azure_key_vault = {
    enabled             = true
    #...
    key_identifier      = "OTHER-KEY-IDENTIFIER"
    #...
  }

  # Disabled GCE KMS...
}

However, the plan for this is not an unpdate-in-place, rather a recreation of the whole encryption configuration.

$ terraform plan

Terraform will perform the following actions:

  # mongodbatlas_encryption_at_rest.encryption must be replaced
-/+ resource "mongodbatlas_encryption_at_rest" "encryption" {
    ...

      ~ azure_key_vault  = { # forces replacement
            "azure_environment"   = "AZURE"
            "client_id"           = "38448f6a-0d05-4100-a883-23fc9bc5d1fa"
            "enabled"             = "true"
          ~ "key_identifier"      = "SOME-KEY-IDENTIFIER" -> "OTHER-KEY-IDENTIFIER"
          ...
      }
      ~ id               = "some-id" -> (known after apply)

...

If these encryption settings are used by a cluster, and if attempting to apply, you get the following error:

Error: error deleting a encryptionAtRest (some-id): PATCH https://cloud.mongodb.com/api/atlas/v1.0/groups/some-id/encryptionAtRest: 409 (request "Conflict") Cannot disable Encryption at Rest on the group because it is still enabled on one or more clusters in the group.

This makes it pragmatically impossible to perform an encryption key rotation from this module without first disabling encryption at rest entirely.

Crash (panic, interface conversion error) when creating mongodbatlas_encryption_at_rest in Azure

$ terraform --version
Terraform v0.12.16
+ provider.mongodbatlas v0.3.1

I have these mongodbatlas_project and a mongodbatlas_cluster resources created properly and managed with terraform. I now want to add the mongodbatlas_encryption_at_rest resource so I can encrypt my clusters with my own keys in my Azure KeyVault.

Here's my .tf (secrets edited) file:

resource "mongodbatlas_encryption_at_rest" "encryption" {
  project_id = mongodbatlas_project.project.id

  azure_key_vault = {
    enabled             = true
    client_id           = "my-service-principal-client-id"
    azure_environment   = "AZURE"
    subscription_id     = "my-subscription-id"
    resource_group_name = "my-resource-group"
    key_vault_name      = "my-key-vault-name"
    key_identifier      = "https://my-vault-name.vault.azure.net/keys/my-key-name/my-key-ID"
    secret              = "some-secret-value"
    tenant_id           = "my-tenant-id"
  }
}

Terraform crashes as soon as I type yes in the apply confirmation dialogue (after the plan) with the following message:

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

mongodbatlas_encryption_at_rest.encryption: Creating...

Error: rpc error: code = Unavailable desc = transport is closing

panic: interface conversion: interface {} is nil, not string

The error stack trace is:

2019/11/22 16:05:58 [TRACE] GRPCProvider: ApplyResourceChange
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: panic: interface conversion: interface {} is nil, not string
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: goroutine 8 [running]:
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.expandAwsKms(0xc00049f020, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_encryption_at_rest.go:142 +0x3be
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.resourceMongoDBAtlasEncryptionAtRestCreate(0xc0002ea930, 0x1b46760, 0xc000177200, 0x2, 0x27d1620)
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_encryption_at_rest.go:154 +0xec
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc000187f80, 0xc0000b8640, 0xc00046e7a0, 0x1b46760, 0xc000177200, 0xc00049e901, 0xc0001d04a0, 0x1afad80)
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:286 +0x3b4
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc000496080, 0xc0003c1a58, 0xc0000b8640, 0xc00046e7a0, 0xc000444868, 0xc000446010, 0x1afcbe0)
2019-11-22T16:05:58.587-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:285 +0x18f
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc00009a530, 0x1eb85c0, 0xc00049e000, 0xc000070420, 0xc00009a530, 0xc00049e000, 0xc0001bbbd0)
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:842 +0x894
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x1c28740, 0xc00009a530, 0x1eb85c0, 0xc00049e000, 0xc0000b8280, 0x0, 0x1eb85c0, 0xc00049e000, 0xc00049c000, 0x3f4)
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:3019 +0x23e
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc000001680, 0x1ec3880, 0xc00009f380, 0xc000177300, 0xc0003001b0, 0x27a6880, 0x0, 0x0, 0x0)
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:966 +0x470
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).handleStream(0xc000001680, 0x1ec3880, 0xc00009f380, 0xc000177300, 0x0)
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:1245 +0xd25
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0000360a0, 0xc000001680, 0x1ec3880, 0xc00009f380, 0xc000177300)
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:685 +0x9f
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: created by github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
2019-11-22T16:05:58.588-0300 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.3.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:683 +0xa1
2019/11/22 16:05:58 [DEBUG] mongodbatlas_encryption_at_rest.encryption: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing

Note that terraform validate and terraform plan go through with no errors.

I'm discarding wrong credentials in the resource parameters as the error cause because I'm using the same service principal for Atlas custom key encryption in another cluster.

I'm at a loss here. Please help?

panic: runtime error: index out of range

Hi!

I started creating my resources using the mongodb repo, I was on commit hashicorp@2b90e03. I switched to this "official" provider and now I'm getting the following when trying to plan:

panic: runtime error: index out of range
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: goroutine 81 [running]:
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.decodeStateID(0xc00064a130, 0xb, 0x1)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/provider.go:96 +0x235
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.resourceMongoDBAtlasProjectIPWhitelistRead(0xc0002e64d0, 0x1b3d640, 0xc0002ea540, 0xc0002e64d0, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_project_ip_whitelist.go:127 +0x80
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0002c9800, 0xc0002206e0, 0x1b3d640, 0xc0002ea540, 0xc00014d890, 0xc0002206e0, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:447 +0x119
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00000e4f0, 0x1eacb60, 0xc00014d470, 0xc0000dba00, 0xc00000e4f0, 0xc00014d470, 0xc0002f1bd0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:496 +0x334
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5._Provider_ReadResource_Handler(0x1c1ec60, 0xc00000e4f0, 0x1eacb60, 0xc00014d470, 0xc0002205a0, 0x0, 0x1eacb60, 0xc00014d470, 0xc000228150, 0x66)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:2983 +0x23e
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc000556600, 0x1eb7d60, 0xc000556d80, 0xc00039c000, 0xc0000987e0, 0x2795850, 0x0, 0x0, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:966 +0x470
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).handleStream(0xc000556600, 0x1eb7d60, 0xc000556d80, 0xc00039c000, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:1245 +0xd25
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00003c2d0, 0xc000556600, 0x1eb7d60, 0xc000556d80, 0xc00039c000)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:685 +0x9f
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: created by github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:683 +0xa1
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalRefresh, err: rpc error: code = Unavailable desc = transport is closing
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2019/08/22 00:28:01 [TRACE] [walkRefresh] Exiting eval tree: module.sle_development.mongodbatlas_project_ip_whitelist.vpc
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_project_ip_whitelist.vpc": visit complete
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_project_ip_whitelist.vpc": dynamic subgraph encountered errors
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_project_ip_whitelist.vpc": visit complete
2019/08/22 00:28:01 [TRACE] module.sle_development: eval: *terraform.EvalSequence
2019/08/22 00:28:01 [TRACE] module.sle_development: eval: *terraform.EvalGetProvider
2019/08/22 00:28:01 [TRACE] module.sle_development: eval: *terraform.EvalReadState
2019/08/22 00:28:01 [TRACE] EvalReadState: reading state for module.sle_development.mongodbatlas_cluster.sle
2019/08/22 00:28:01 [TRACE] UpgradeResourceState: schema version of module.sle_development.mongodbatlas_cluster.sle is still 0; calling provider "mongodbatlas" for any other minor fixups
2019/08/22 00:28:01 [TRACE] GRPCProvider: UpgradeResourceState
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalReadState, err: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: <nil>
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: <nil>
2019/08/22 00:28:01 [TRACE] [walkRefresh] Exiting eval tree: module.sle_development.mongodbatlas_cluster.sle
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_cluster.sle": visit complete
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_cluster.sle": dynamic subgraph encountered errors
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_cluster.sle": visit complete
2019/08/22 00:28:01 [TRACE] module.sle_production: eval: *terraform.EvalSequence
2019/08/22 00:28:01 [TRACE] module.sle_production: eval: *terraform.EvalOpFilter
2019/08/22 00:28:01 [TRACE] module.sle_production: eval: *terraform.EvalWriteOutput
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.mongodbatlas_network_container.sle" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.output.collaboration_db_url" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.mongodbatlas_network_peering.vpc" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.mongodbatlas_database_user.sle" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "output.collaboration_db_url_development" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.provider.mongodbatlas (close)" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.aws_vpc_peering_connection_accepter.vpc" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.aws_route.mongodb" errored, so skipping

Did you make breaking changes? Should I delete my state and re-import my resources?

accepter_region_name not required for AWS on read/import/update

According the documentation, the accepter_region_name is required for resource mongodbatlas_network_peering. Nevertheless, when we first imported our resources (migrating from the original third-party provider), we didn't encounter an error when we left out accepter_region_name.

Checking mongodbatlas/resource-mongodbatlas_network_container.go, it appears that this constraint is only enforced upon create. While this is a bit of an edge case, it might be worth enforcing this constraint across all operations for consistency.

importing a mongodbatlas_project_ip_whitelist resource does not save project_id to state

There seems to be a bug with importing mongodbatlas_project_ip_whitelist resources. The project_ip attribute is not saved in state, so the next time you run terraform, it wants to destroy and create the resource because project_id is not set.

Here is some example code showing this:

provider "mongodbatlas" {}

resource "mongodbatlas_project" "project" {
    name   = "${var.atlas_project_name}"
    org_id = "${var.atlas_organization}"
}

resource "mongodbatlas_project_ip_whitelist" "whitelist" {
  project_id = "${mongodbatlas_project.project.id}"

  whitelist {
    ip_address = "1.2.3.4"
  }
}

I have no problem importing mongodbatlas_project.project &
mongodbatlas_project_ip_whitelist.whitelist

But then when I run terraform plan, terraform indicates that it wants to destroy and create the resource because project_id is not set:

$ terraform plan --target mongodbatlas_project_ip_whitelist.whitelist
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

mongodbatlas_project.project: Refreshing state... [id=<MY_PROJECT_ID>]
mongodbatlas_project_ip_whitelist.whitelist: Refreshing state... [id=<XXXXXXX>==]

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # mongodbatlas_project_ip_whitelist.whitelist must be replaced
-/+ resource "mongodbatlas_project_ip_whitelist" "whitelist" {
      ~ id         = "<XXXXXXX>" -> (known after apply)
      + project_id = "<MY_PROJECT_ID>" # forces replacement

      + whitelist { # forces replacement
          + cidr_block = (known after apply)
          + comment    = (known after apply)
          + ip_address = "1.2.3.4"
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.```

This is using version 0.1.1 of the plugin.

As a side note, I also have a `mongodbatlas_cluster` I can import and that works fine. The project_id is saved in state there.

Thanks.

mongodbatlas_network_peering Internal Servier Error

terraform 0.12.8
mongodbatlas 0.2.0

resource "mongodbatlas_project" "mongodb_project" {
  provider = "mongodbatlas"
  name     = "mongodb"
  org_id   = "XXXXXXXXXX"
}

resource "mongodbatlas_network_container" "mongodb_container" {
  provider         = "mongodbatlas"
  project_id       = "${mongodbatlas_project.mongodb_project.id}"
  atlas_cidr_block = "192.168.248.0/21"
  provider_name    = "AWS"
  region_name      = "US_WEST_2"
}

resource "mongodbatlas_network_peering" "mongodb_peering" {
  provider               = "mongodbatlas"
  accepter_region_name   = "us-west-2"
  project_id             = "${mongodbatlas_project.mongodb_project.id}"
  container_id           = "${mongodbatlas_network_container.mongodb_container.id}"
  provider_name          = "AWS"
  route_table_cidr_block = "10.9.0.0/16"
  vpc_id                 = "${aws_vpc.vpc.id}"
  aws_account_id         = "${local.account_id}"
}

Applying the above yields:

Error: error creating MongoDB Network Peering Connection: POST https://cloud.mongodb.com/api/atlas/v1.0/groups/XXXXXXXXXXXXXX/peers: 500 (request "Internal Server Error") Unexpected error.

Debug log:
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: ---[ RESPONSE ]--------------------------------------
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: HTTP/2.0 500 Internal Server Error
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: Content-Length: 122
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: Content-Type: application/json
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: Date: Fri, 20 Sep 2019 21:03:44 GMT
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: Strict-Transport-Security: max-age=300
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: X-Mongodb-Service-Version: gitHash=ee0546e1abe0c2c3016aeda9abf0e33d70ffd190; versionString=v20190910
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4:
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: {
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: "detail": "Unexpected error.",
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: "error": 500,
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: "errorCode": "UNEXPECTED_ERROR",
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: "parameters": [],
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: "reason": "Internal Server Error"
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: }
2019-09-20T14:03:44.599-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.2.0_x4: -----------------------------------------------------

Add resource for maintenance window

Hi!

I would like to know if there is any plan of supporting a resource for provisioning maintenance windows?

This could be helpful to avoid setting this manually at the project level.

I'm new to Terraform but wouldn't mind to work on it, in case it makes sense.

Thanks

Unable to create project with peering only connections

When creating a GCP peered cluster, the project configuration doesn't allow you to set it for peer networking only.

In order to create a project with peer networking you need to:

  • create the project (terraform)
  • switch to the UI and enable this
  • create your cluster(terraform)

This is supported by the Atlas API (https://docs.atlas.mongodb.com/reference/api/set-private-ip-mode-for-project).

Looking through the source, it may be possible relatively easily to add a field to the project stanza (https://github.com/terraform-providers/terraform-provider-mongodbatlas/blob/master/mongodbatlas/resource_mongodbatlas_project.go#L21-L38) which can then fire off the appropriate API call.

It's possible I've missed some documentation so thoughts would be very welcome

GCP Peering endless terraform apply

Hi

I cant get this provider to work with peering.
I start with an empty project, no container.

This is my code :

data "mongodbatlas_project" "test" {
  name = "test-project"
}

data "google_compute_network" "network" {
  project = var.project
  name    = var.network
}

resource "mongodbatlas_network_container" "test" {
  project_id       = data.mongodbatlas_project.test.id
  atlas_cidr_block = "10.1.0.0/18"
  provider_name    = "GCP"
}

resource "mongodbatlas_network_peering" "test" {
  project_id     = data.mongodbatlas_project.test.id
  container_id   = mongodbatlas_network_container.test.container_id
  provider_name  = "GCP"
  network_name   = data.google_compute_network.network.name
  gcp_project_id = var.project
}

resource "google_compute_network_peering" "atlas_peer" {
  name         = "atlas-peering"
  network      = data.google_compute_network.network.self_link
  peer_network = "https://www.googleapis.com/compute/v1/projects/${mongodbatlas_network_container.test.gcp_project_id}/global/networks/${mongodbatlas_network_container.test.network_name}"
}

The thing is mongodbatlas_network_peering wait for the peering to be up but on the other end mongodbatlas_network_container does not return the values to the google_compute_network_peering resource.

What did i do wrong ?

Modifying project ip whitelist destroy and re-create all resources

Hi,

This seems to be a bug into the mongodbatlas_project_ip_whitelist resource.
Exemple :

resource "mongodbatlas_project_ip_whitelist" "whitelist" {
  project_id = data.mongodbatlas_project.project.id
  whitelist {
    cidr_block = "10.10.0.0/24"
    comment    = "cidr 1"
  }
}

Add a cidr :

resource "mongodbatlas_project_ip_whitelist" "whitelist" {
  project_id = data.mongodbatlas_project.project.id
  whitelist {
    cidr_block = "10.10.0.0/24"
    comment    = "cird 1"
  }
  whitelist {
    cidr_block = "10.10.1.0/24"
    comment    = "cidr 2"
  }
}

Plan :

  # module.atlas.mongodbatlas_project_ip_whitelist.whitelist must be replaced
-/+ resource "mongodbatlas_project_ip_whitelist" "whitelist" {
      ~ id         = "cHJvamVjdF9pZA==:NWQ4OWM4MzJmMmEzMGI4ZTc4Mzc5NDEx-ZW50cmllcw==:MTAuMTAwLjk4LjAvMjM=" -> (known after apply)
        project_id = "xxxxxxxxxxxxxxxxxxxxxxxxxx"

      + whitelist { # forces replacement
          + cidr_block = "10.10.0.0/24"
          + comment    = "cidr 1"
          + ip_address = (known after apply)
        }
      - whitelist { # forces replacement
          - cidr_block = "10.10.0.0/24" -> null
          - comment    = "cidr 1" -> null
        }
      + whitelist { # forces replacement
          + cidr_block = "10.10.1.0/24"
          + comment    = "cidr 2"
          + ip_address = (known after apply)
        }
    }

It happens if i add or delete or modify a cidr_block.
Thanks

Issue with import mongodbatlas_cloud_provider_snapshot_restore_job

This issue was originally opened by @sushilvarma2 as hashicorp/terraform#23903. It was migrated here as a result of the provider split. The original body of the issue is below.


Hello All,

We have an issue where mongo db cluster was created through Terraform. And Snapshot was created manually. I am trying to import snapshot details using terraform import. I have used the command as mentioned here:

Since my clustername has hyphen in it so terraform is not able to understand this request and throwing an error.
clusterName: projectname-environment-mongo-global-cluster
Can someone suggest please how I can overcome this issue ?

Command:
terraform import mongodbatlas_cloud_provider_snapshot_restore_job.test 5cf5a45a9ccf6400e60981b6-MyCluster-5d1b654ecf09a24b888f4c79

Reference:
Project_id, cluster_name and snapshot_id (Unique identifier of the snapshot), in the format PROJECTID-CLUSTERNAME-JOBID
https://www.terraform.io/docs/providers/mongodbatlas/r/cloud_provider_snapshot_restore_job.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.