cloudposse / cloudposse/terraform-aws-documentdb-cluster

Error: Invalid count argument when password comes from an aws_ssm_parameter resource

Open
#68 3 comments 7 reactions 0 assignees View on GitHub
bug
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/cms.db/main.tf line 54, in resource "random_password" "password":
│ 54: count = module.this.enabled && var.master_password == "" ? 1 : 0

│ 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 can be applied without resource targeting.

### Steps to Reproduce

set password to the value of an ssm param, for example:
```
master_password = aws_ssm_parameter.db_password.value
```

### Screenshots

_No response_

### Environment

Terraform 1.5

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the configuration in the issue with Terraform 1.5 and an aws_ssm_parameter value. Inspect .terraform/modules/cms.db/main.tf at the random_password resource on line 54 and trace how its count depends on master_password. Done means Terraform can plan and apply this configuration without resource targeting.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.