Thank you Edgar. I was able to by pass the authentication issues. I had to set permission on the API Key to be “Organization Owner”.
I tried with the following options (I also tried it with ip address as it is on the original github sample instead of cidr_block; but I do not believe this is an issue, since both should work and in cidr_block case I even received an email notification success warning about it; so that think worked and I also see it in the response details):
- OPTION:
First I tried with M0 Free cluster (with 4.4 as can be seen on terraform docs). So I have setup the following in terraform files:
cloud_backup = false
auto_scaling_disk_gb_enabled = false
provider_name = var.cloud_provider
provider_instance_size_name = “M0”
-var=“mongodbversion=4.4” (since terraform docs says so)
And I have also setup the Azure region to westeurope. In this case, I get:
mongodbatlas_project.project: Creating…
mongodbatlas_project.project: Creation complete after 5s [id=6262ec38815a200dfa1f42d6]
mongodbatlas_project_ip_access_list.ip: Creating…
mongodbatlas_database_user.user: Creating…
mongodbatlas_cluster.cluster: Creating…
mongodbatlas_database_user.user: Creation complete after 0s [id=YXV0aF9kYXRhYmFzZV9uYW1l:YWRtaW4=-cHJvamVjdF9pZA==:NjI2MmVjMzg4MTVhMjAwZGZhMWY0MmQ2-dXNlcm5hbWU=:dGVzdA==]
mongodbatlas_project_ip_access_list.ip: Creation complete after 4s [id=ZW50cnk=:ODQuMTE1LjIxNi4yNTU=-cHJvamVjdF9pZA==:NjI2MmVjMzg4MTVhMjAwZGZhMWY0MmQ2]
╷
│ Error: error creating MongoDB Cluster: POST …cloud.mongodb.com/api/atlas/v1.0/groups/6262ec38815a200dfa1f42d6/clusters: 400 (request “INVALID_ENUM_VALUE”) An invalid enumeration value M0 was specified.
│
│ with mongodbatlas_cluster.cluster,
│ on atlas_cluster.tf line 1, in resource “mongodbatlas_cluster” “cluster”:
│ 1: resource “mongodbatlas_cluster” “cluster” {
- OPTION:
Then I tried with a different instance size, due to the enum error.
cloud_backup = false
auto_scaling_disk_gb_enabled = false
provider_name = var.cloud_provider
provider_instance_size_name = “M2”
And I have also setup the Azure region to northeurope. (since I saw that M2 is available only in northeurope)
terraform -chdir=“terraform-manifests” apply -state-out=“result.tfstate” -var=“cloud_provider=AZURE” -var=“cluster_name=Foo” -var=“database_name=Bar” -var=“dbuser=test” -var=“dbuser_password=test123$” -var=“cidr_block=0.0.0.0/0” -var=“mongodbversion=4.4” -var=“org_id=my id” -var=“private_key=my key” -var=“project_name=Project_11” -var=“public_key=my key” -var=“region=northeurope”
In this case, I get again:
mongodbatlas_project.project: Creating…
mongodbatlas_project.project: Creation complete after 4s [id=6262f0e8622e084960f1524a]
mongodbatlas_project_ip_access_list.ip: Creating…
mongodbatlas_database_user.user: Creating…
mongodbatlas_cluster.cluster: Creating…
mongodbatlas_database_user.user: Creation complete after 1s [id=YXV0aF9kYXRhYmFzZV9uYW1l:YWRtaW4=-cHJvamVjdF9pZA==:NjI2MmYwZTg2MjJlMDg0OTYwZjE1MjRh-dXNlcm5hbWU=:dGVzdA==]
mongodbatlas_project_ip_access_list.ip: Creation complete after 5s [id=ZW50cnk=:MC4wLjAuMC8w-cHJvamVjdF9pZA==:NjI2MmYwZTg2MjJlMDg0OTYwZjE1MjRh]
╷
│ Error: error creating MongoDB Cluster: POST …cloud.mongodb.com/api/atlas/v1.0/groups/6262f0e8622e084960f1524a/clusters: 400 (request “INVALID_ENUM_VALUE”) An invalid enumeration value M2 was specified
- OPTION: Original as it is in the tf example:
cloud_backup = true
auto_scaling_disk_gb_enabled = true
provider_name = var.cloud_provider
provider_instance_size_name = “M10”
-var=“mongodbversion=5.0”
mongodbatlas_project.project: Creating…
mongodbatlas_project.project: Creation complete after 5s [id=6262f160be944a1535c0f66c]
mongodbatlas_project_ip_access_list.ip: Creating…
mongodbatlas_database_user.user: Creating…
mongodbatlas_cluster.cluster: Creating…
mongodbatlas_database_user.user: Creation complete after 1s [id=YXV0aF9kYXRhYmFzZV9uYW1l:YWRtaW4=-cHJvamVjdF9pZA==:NjI2MmYxNjBiZTk0NGExNTM1YzBmNjZj-dXNlcm5hbWU=:dGVzdA==]
mongodbatlas_project_ip_access_list.ip: Creation complete after 6s [id=ZW50cnk=:MC4wLjAuMC8w-cHJvamVjdF9pZA==:NjI2MmYxNjBiZTk0NGExNTM1YzBmNjZj]
╷
│ Error: error creating MongoDB Cluster: POST …cloud.mongodb.com/api/atlas/v1.0/groups/6262f160be944a1535c0f66c/clusters: 500 (request “UNEXPECTED_ERROR”) Unexpected error.
In the last sample, I even tried to turn on the verbose logging in terraform and I got a api call response details (on the one that failed and the rest that were success); but there is not much info there (which makes sense, since it is a good API practice not to disclose an internal exception; but I wish I could see them at least somehow on the portal in some kind of an audit log):
{
“detail”: “Unexpected error.”,
“error”: 500,
“errorCode”: “UNEXPECTED_ERROR”,
“parameters”: [],
“reason”: “Internal Server Error”
}
Any advice is welcome:)