Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Provider produced inconsistent result after apply (mongodbatlas_project_ip_access_list) #2313

Closed
2 tasks done
RaniAgus opened this issue May 29, 2024 · 2 comments
Closed
2 tasks done

Comments

@RaniAgus
Copy link
Contributor

RaniAgus commented May 29, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Provider Version

~> 1.0

Terraform Version

v1.8.4

Terraform Edition

Terraform Open Source (OSS)

Current Behavior

I know this isn't production-ready, but I wanted to try out Terraform + MongoDB for an university project and tried to allow all IP addresses to access the project I've created in MongoDB Atlas.

It is applied correctly, however, terraform throws a "Provider produced inconsistent result after apply" error saying that the allowed IP address is an empty string.

Also tried replacing the IP value with an empty string, but it throws an "Invalid Attribute Value" error with this message: "Attribute ip_address string value must be defined as a valid IP Address., got: "

Terraform configuration to reproduce the issue

variable "mongodbatlas_public_key" {
  type = string
  nullable = false
  sensitive = true
}

variable "mongodbatlas_private_key" {
  type = string
  nullable = false
  sensitive = true
}

variable "mongodbatlas_project_name" {
  type        = string
  description = "The MongoDB Atlas Project Name"
  default     = "project"
}

variable "mongodb_allowed_ip_address" {
  type        = string
  description = "The IP Address to add to the IP Access List"
  default     = "0.0.0.0"
}

terraform {
  required_providers {
    mongodbatlas = {
      source  = "mongodb/mongodbatlas"
      version = "~> 1.0"
    }
  }
  required_version = ">= 1.0"
}

provider "mongodbatlas" {
  public_key = var.mongodbatlas_public_key
  private_key  = var.mongodbatlas_private_key
}

data "mongodbatlas_roles_org_id" "project" {
}

resource "mongodbatlas_project" "project" {
  name   = var.mongodbatlas_project_name
  org_id = data.mongodbatlas_roles_org_id.project.org_id
}

resource "mongodbatlas_project_ip_access_list" "ip" {
  project_id = mongodbatlas_project.project.id
  ip_address = var.mongodb_allowed_ip_address
  comment    = "IP Address for accessing the cluster"
}

Steps To Reproduce

  1. Run terraform apply
  2. Provide API public key and private key (could be provided using a terraform.tvars file too)
  3. Enter yes

Logs

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to mongodbatlas_project_ip_access_list.ip, provider "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" produced an unexpected new value: .ip_address:  
│ was cty.StringVal("0.0.0.0"), but now cty.StringVal("").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Code of Conduct

  • I agree to follow this project's Code of Conduct
Copy link
Contributor

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-251134 was created for internal tracking.

@RaniAgus
Copy link
Contributor Author

Nevermind! It works after replacing:

resource "mongodbatlas_project_ip_access_list" "ip" {
  project_id = mongodbatlas_project.project.id
  ip_address = "0.0.0.0"
  comment    = "IP Address for accessing the cluster"
}

With:

resource "mongodbatlas_project_ip_access_list" "ip" {
  project_id = mongodbatlas_project.project.id
  cidr_block = "0.0.0.0/0"
  comment    = "CIDR Block for accessing the cluster"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant