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

Random_string Override special Issue #325

Closed
1 task done
rishabhjain1510 opened this issue Sep 21, 2022 · 7 comments
Closed
1 task done

Random_string Override special Issue #325

rishabhjain1510 opened this issue Sep 21, 2022 · 7 comments
Labels

Comments

@rishabhjain1510
Copy link

rishabhjain1510 commented Sep 21, 2022

Terraform CLI and Provider Versions

Terraform Version : - v0.13.6
Provider version :- 3.75.1
Random Provider version:- v3.4.3

Terraform Configuration

provider "aws" {
version = "~> 3.75.1"
region = var.region
assume_role {
role_arn = var.role_arn
session_name = "Opticloud_Provisioner"
external_id = "Opticloud"
}
}

resource "random_string" "password" {
  length           = 12
  min_lower        = 1
  min_numeric      = 1
  min_upper        = 1
  min_special      = 1
  special          = true
  override_special = "!#$%&*()-_=+[]{}<>:?"
}

Expected Behavior

It should create a password , with all the properties specified .

Actual Behavior

terraform plan throws an error .

Provider "registry.terraform.io/hashicorp/random" planned an invalid value for
module.aurora-pp-26cmbjo6oyplk.random_string.password.override_special:
planned value cty.NullVal(cty.String) does not match config value
cty.StringVal("!#$%&*()-_=+[]{}<>:?").

Steps to Reproduce

  1. terraform plan

How much impact is this issue causing?

High

Logs

https://gist.github.com/rishabhjain1510/65c279d1d2c0149208e109b66fcce29f

Additional Information

No response

Code of Conduct

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

bendbennett commented Sep 21, 2022

Hi @rishabhjain1510 👋
Thanks for raising this issue and apologies for any inconvenience.

Would it be possible for you to show the (redacted if necessary) current state of that particular resource? e.g.

$ terraform state show random_string.password

Thanks

@rishabhjain1510
Copy link
Author

Hi @bendbennett ,

Here is the state.

module.rds-instance-pp-3hdhqno7z4jzo.random_string.password:

resource "random_string" "password" {
id = "LPAzL9WBiOVG"
length = 12
lower = true
min_lower = 1
min_numeric = 1
min_special = 0
min_upper = 1
number = true
result = "LPAzL9WBiOVG"
special = false
upper = true
}

@bendbennett
Copy link
Contributor

bendbennett commented Sep 21, 2022

@rishabhjain1510 looking at your output from terraform state show random_string.password, the absence of the numeric attribute suggests that you were using v3.2.0 or an earlier version of the provider, as numeric was introduced in v3.3.0.

The state also indicates that the configuration for random_string was previously something like:

resource "random_string" "password" {
  length      = 12
  min_lower   = 1
  min_numeric = 1
  min_special = 0
  min_upper   = 1
  special     = false
}

I tried to reproduce the issue you describe by using v3.2.0 of the provider, which gives me a very similar state to that which you described:

terraform state show random_string.password
# random_string.password:
resource "random_string" "password" {
    id          = "tcHyjh5Fuzqi"
    length      = 12
    lower       = true
    min_lower   = 1
    min_numeric = 1
    min_special = 0
    min_upper   = 1
    number      = true
    result      = "tcHyjh5Fuzqi"
    special     = false
    upper       = true
}

I then updated to v3.4.3 and modified the configuration to the following:

resource "random_string" "password" {
  length           = 12
  min_lower        = 1
  min_numeric      = 1
  min_upper        = 1
  min_special      = 1
  special          = true
  override_special = "!#$%&*()-_=+[]{}<>:?"
}

Running terraform plan then produced the following output:

Terraform will perform the following actions:

  # random_string.password must be replaced
-/+ resource "random_string" "password" {
      ~ id               = "tcHyjh5Fuzqi" -> (known after apply)
      ~ min_special      = 0 -> 1 # forces replacement
      + override_special = "!#$%&*()-_=+[]{}<>:?" # forces replacement
      ~ result           = "tcHyjh5Fuzqi" -> (known after apply)
      ~ special          = false -> true # forces replacement
        # (8 unchanged attributes hidden)
    }

Plan: 1 to add, 0 to change, 1 to destroy.

I was unable to reproduce the issue you describe where terraform plan produces an error.

@rishabhjain1510
Copy link
Author

Hi @bendbennett ,

Thanks for update, to re-produce the error you can use the below code

resource "random_string" "password" {
length = 12
min_lower = 1
min_numeric = 1
min_upper = 1
min_special = 1
special = true
override_special = "!#$%&*()-_=+[]{}<>:?"
lifecycle {
ignore_changes = all
}
}

@bendbennett
Copy link
Contributor

Hi @rishabhjain1510,

If I run through the process I described in #325 (comment) and then update the configuration as you describe prior to running terraform plan with v3.4.3 I see the following:

resource "random_string" "password" {
  length           = 12
  min_lower        = 1
  min_numeric      = 1
  min_upper        = 1
  min_special      = 1
  special          = true
  override_special = "!#$%&*()-_=+[]{}<>:?"

  lifecycle {
    ignore_changes = all
  }
}
random_string.password: Refreshing state... [id=tcHyjh5Fuzqi]

No changes. Your infrastructure matches the configuration.

@bendbennett
Copy link
Contributor

@rishabhjain1510 I'm going to close this issue as I'm unable to reproduce the issue you describe and there's been no further feedback. If you are still experiencing problems please file another issue and if possible supply the necessary configuration to reproduce the issue. Thanks.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants