cloudposse / cloudposse/terraform-aws-documentdb-cluster
Invalid count argument when password provide using random_password
- Dominant language
- HCL
- Stars
- 70
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
╷
│ Error: Invalid count argument
│
│ on .terraform/modules/ac2ui_documentdb_cluster/main.tf line 43, in resource "random_password" "password":
│ 43: count = module.this.enabled && var.master_password != "" ? 0 : 1
│
│ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict
│ how many instances will be created. To work around this, use the -target argument to first apply only the resources
│ that the count depends on.
### Expected Behavior
Terraform plan should be applied without this issue.
### Steps to Reproduce
set password to the value of an ssm param, for example:
```
resource "random_password" "ac2ui_master_password" {
length = 8
special = false
}
master_password = random_password.master_password.result
```
### Screenshots
_No response_
### Environment
_No response_
### Additional Context
_No response_
Contributor guide
Research direction
Start by inspecting .terraform/modules/ac2ui_documentdb_cluster/main.tf at line 43 and the random_password count expression. Reproduce the plan with master_password set from another random_password result, then trace the Terraform dependency behavior. Done means the documented configuration can be planned and applied without the invalid count argument.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, terraform
- Domain
- cloud, databases, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100