A mongodbatlas_project_api_key resource does not properly evaluate existing project_assignment in the plan.
The provider attempts to recreate existing project access and fails on the atlas api with:
╷
│ Error: error assigning api_keys into the project(66f1): https://cloud.mongodb.com/api/atlas/v2/groups/*/apiKeys/* POST: HTTP 400 Bad Request (Error code: "API_KEY_ALREADY_IN_GROUP") Detail: API key is already in the group. Reason: Bad Request. Params: []
│
│ with mongodbatlas_project_api_key.project,
│ on main.tf line 116, in resource "mongodbatlas_project_api_key" "project":
│ 116: resource "mongodbatlas_project_api_key" "project" {
│
╵
Operation failed: failed running terraform apply (exit 1)
State show for resource
terraform state show mongodbatlas_project_api_key.project
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
mongodbatlas_project_api_key.project will be updated in-place
~ resource "mongodbatlas_project_api_key" "project" {
id = "*"
Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:
Terraform configuration file used to reproduce the issue
Terraform log files from the run where the issue occurred
Terraform Atlas provider version used to reproduce the issue
Terraform version used to reproduce the issue
Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment
The ticket CLOUDP-276228 was created for internal tracking.
Is there an existing issue for this?
Provider Version
v1.20.0
Terraform Version
v1.9.3
Terraform Edition
Terraform Cloud
Current Behavior
A
mongodbatlas_project_api_key
resource does not properly evaluate existing project_assignment in the plan.The provider attempts to recreate existing project access and fails on the atlas api with:
State show for resource
}
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place
Terraform will perform the following actions:
mongodbatlas_project_api_key.project will be updated in-place
~ resource "mongodbatlas_project_api_key" "project" { id = "*"
(4 unchanged attributes hidden)
Plan: 0 to add, 1 to change, 0 to destroy.
Terraform v1.9.3 on linux_amd64
Terraform configuration to reproduce the issue
Steps To Reproduce
mongodbatlas_project
andmongodbatlas_project_api_key
in the same terraformAPI_KEY_ALREADY_IN_GROUP
Logs
No response
Code of Conduct