hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.19k forks source link

[Bug]: Both AuthType and SecretArn/Password should be specified on aws_docdbelastic_cluster #39534

Open leandroandrade-hotmart opened 1 month ago

leandroandrade-hotmart commented 1 month ago

Terraform Core Version

v1.9.3

AWS Provider Version

v5.69.0

Affected Resource(s)

Attempting to create a test aws_docdbelastic_cluster with auth_type set to "PLAIN_TEXT", has led you down an error-riddled path of "Both AuthType and SecretArn/Password should be specified."

Code:

resource "aws_docdbelastic_cluster" "testdb" {
  name                         = "mytest-cluster"
  admin_user_name              = "root"
  admin_user_password          = "initialpassword"
  auth_type                    = "PLAIN_TEXT"
  shard_capacity               = 2
  shard_count                  = 1
  subnet_ids                   = data.terraform_remote_state.vpc.outputs.database_subnets
  vpc_security_group_ids       = [data.terraform_remote_state.sgr.outputs.secgroup-documentdb]
  backup_retention_period      = 7
  preferred_maintenance_window = "Mon:00:00-Mon:03:00"
  preferred_backup_window      = "03:01-06:00"
  tags = {
    Team        = "TEST"
    Environment = "production"
    Kind        = "documentdb"
    Name        = "mytest" 
    Repository  = "test-iac"
  }
}

Expected Behavior

Resource aws_docdbelastic_cluster created using a plain_text password.

Actual Behavior

Error: updating AWS DocumentDB Elastic Cluster (arn:aws:docdb-elastic:us-east-1:xxx:cluster/id_cluster): operation error DocDB Elastic: UpdateCluster, https response error StatusCode: 400, RequestID: adfa742c-b992-43ca-9727-6dbf52c2f2d0, ValidationException: Both AuthType and SecretArn/Password should be specified.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

version.tf file
terraform {
  required_version = ">= 1.0"
  backend "s3" {
    bucket  = "mybucket-terraform-states"
    region  = "us-east-1"
    key     = "documentdb/terraform.tfstate"
    profile = "terraform"
  }

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.69.0"
    }
  }
}

provider "aws" {
  region  = "us-east-1"
  profile = "terraform"
}

Steps to Reproduce

  1. Run terraform plan
 # aws_docdbelastic_cluster.facetecdb will be created
  + resource "aws_docdbelastic_cluster" "testdb" {
      + admin_user_name              = "root"
      + admin_user_password          = (sensitive value)
      + arn                          = (known after apply)
      + auth_type                    = "PLAIN_TEXT"
      + backup_retention_period      = 7
      + endpoint                     = (known after apply)
      + id                           = (known after apply)
      + kms_key_id                   = (known after apply)
      + name                         = "facetecdb-cluster"
      + preferred_backup_window      = "03:01-06:00"
      + preferred_maintenance_window = "Mon:00:00-Mon:03:00"
      + shard_capacity               = 1
      + shard_count                  = 1
      + subnet_ids                   = [
          + "subnet-xxx",
          + "subnet-xyz",
          + "subnet-yyy",
        ]
      + tags                         = {
          + "Environment" = "production"
          + "Kind"        = "documentdb"
          + "Name"        = "testdb"
          + "Repository"  = "test-iac"
          + "Team"        = "TEST"
        }
      + tags_all                     = {
          + "Environment" = "production"
          + "Kind"        = "documentdb"
          + "Name"        = "testdb"
          + "Repository"  = "test-iac"
          + "Team"        = "TEST"
        }
      + vpc_security_group_ids       = [
          + "sg-xxx",
        ]
    }

Plan: 1 to add, 0 to change, 0 to destroy.
  1. Run terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

Benbig09 commented 1 month ago

i also got this once i try to update the secret. the cluster was already deployed, and i got this error after the change.