Description
Terraform CLI and Terraform MongoDB Atlas Provider Version
Using Terraform Cloud VCS Workflow for Applying state changes.
Terraform v1.3.5
+ provider registry.terraform.io/mongodb/mongodbatlas v1.6.0
Terraform Configuration File
terraform {
cloud {
organization = "tf-mongo-org"
workspaces {
name = "mongo-organization"
}
}
}
terraform {
required_providers {
mongodbatlas = {
source = "mongodb/mongodbatlas"
}
}
}
provider "mongodbatlas" {
public_key = var.public_key
private_key = var.private_key
}
resource "mongodbatlas_org_invitation" "invitation" {
username = "[email protected]"
org_id = var.mongo_org_id
roles = ["ORG_MEMBER"]
}
Steps to Reproduce
- Perform Plan&Apply on Terraform Cloud
- Users accepts invitations email
- Perform Plan&Apply on Terraform Cloud
- Remove
mongodbatlas_org_invitation.invitation
from configuration - Perform Plan&Apply on Terraform Cloud
Expected Behavior
Step 3: It would be expected that the state is updated in the way that the invitation is removed from Terraform state.
Step 5: It would be expected that the plan does not detected any changes as state has been already been updated or the removal of invitation from configuration is working if state still contains the resource.
Actual Behavior
Step 3: The Terraform state is not updated. No state changes are detected during plan or apply and the invitation is still part of the Terraform state afterwards. Even a "Refresh State" (aka terraform apply -refresh-only
) does not detect that the invitation is no longer active.
Step 5: The Plan phase shows a deletion of the invitation . Applying the invitation fails as the resource cannot be deleted as it is not found (HTTP 404)
Debug Output
Debug output of trying to delete the resource in Step 5 (see above)
2022-11-30T14:12:23.870Z [INFO] provider.terraform-provider-mongodbatlas_v1.6.0: 2022/11/30 14:12:23 [DEBUG] MongoDB Atlas API Request Details:
---[ REQUEST ]---------------------------------------
DELETE /api/atlas/v1.0/orgs/63839ba5b41c43346b8708ff/invites/6384f323dd49394ed60495d1 HTTP/1.1
Host: cloud.mongodb.com
User-Agent: terraform-provider-mongodbatlas/1.6.0 go-mongodbatlas/0.18.0 (linux;amd64)
Accept: application/json
Accept-Encoding: gzip
-----------------------------------------------------: timestamp=2022-11-30T14:12:23.870Z
2022-11-30T14:12:23.918Z [INFO] provider.terraform-provider-mongodbatlas_v1.6.0: 2022/11/30 14:12:23 [DEBUG] MongoDB Atlas API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 404 Not Found
Content-Length: 188
Content-Type: application/json
Date: Wed, 30 Nov 2022 14:12:23 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: envoy
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 23
X-Frame-Options: DENY
X-Mongodb-Service-Version: gitHash=6f960f6384e938f185ba29e3a46877f5157a4d6b; versionString=v20221116
X-Permitted-Cross-Domain-Policies: none
{
"detail": "An invalid invitation ID 6384F323DD49394ED60495D1 was specified.",
"error": 404,
"errorCode": "INVALID_INVITATION_ID",
"parameters": [
],
"reason": "Not Found"
}
-----------------------------------------------------: timestamp=2022-11-30T14:12:23.918Z
2022-11-30T14:12:23.919Z [ERROR] provider.terraform-provider-mongodbatlas_v1.6.0: Response contains error diagnostic: @module=sdk.proto diagnostic_detail= tf_proto_version=5.3 tf_resource_type=mongodbatlas_org_invitation @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 tf_provider_addr=provider tf_req_id=4de73b68-3926-9005-0934-7df666e3533a tf_rpc=ApplyResourceChange diagnostic_severity=ERROR diagnostic_summary="error deleting Organization invitation for user [email protected]: DELETE https://cloud.mongodb.com/api/atlas/v1.0/orgs/63839ba5b41c43346b8708ff/invites/6384f323dd49394ed60495d1: 404 (request "INVALID_INVITATION_ID") An invalid invitation ID 6384F323DD49394ED60495D1 was specified." timestamp=2022-11-30T14:12:23.919Z