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

Use boolean value in condition #118

Closed
wants to merge 1 commit into from

Conversation

dud225
Copy link

@dud225 dud225 commented Apr 29, 2019

The use of an integer value makes Terraform to force the casting of the
other value so that both match the same type.

If the create_db_option_group or create_db_subnet_group parameters
is set as the result of a conditional expression :

  create_db_option_group = "${var.enable ? true : false}"
  create_db_subnet_group = "${var.enable ? true : false}"

then TF fails because of this casting :

* local.enable_create_db_subnet_group: local.enable_create_db_subnet_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.db_subnet_group_name == "" ? var.create_db_subnet_group : 0}
* local.enable_create_db_subnet_group: local.enable_create_db_subnet_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.db_subnet_group_name == "" ? var.create_db_subnet_group : 0}
* local.enable_create_db_option_group: local.enable_create_db_option_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.option_group_name == "" && var.engine != "postgres" ? var.create_db_option_group : 0}
* local.enable_create_db_option_group: local.enable_create_db_option_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.option_group_name == "" && var.engine != "postgres" ? var.create_db_option_group : 0}

The use of an integer value makes Terraform to force the casting of the
other value so that both match the same type.

If the `create_db_option_group` or `create_db_subnet_group` parameters
is set as the result of a conditional expression :
```hcl
  create_db_option_group = "${var.enable ? true : false}"
  create_db_subnet_group = "${var.enable ? true : false}"
```
then TF fails because of this casting :

```
* local.enable_create_db_subnet_group: local.enable_create_db_subnet_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.db_subnet_group_name == "" ? var.create_db_subnet_group : 0}
* local.enable_create_db_subnet_group: local.enable_create_db_subnet_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.db_subnet_group_name == "" ? var.create_db_subnet_group : 0}
* local.enable_create_db_option_group: local.enable_create_db_option_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.option_group_name == "" && var.engine != "postgres" ? var.create_db_option_group : 0}
* local.enable_create_db_option_group: local.enable_create_db_option_group: __builtin_StringToInt: strconv.ParseInt: parsing "false": invalid syntax in:

${var.option_group_name == "" && var.engine != "postgres" ? var.create_db_option_group : 0}
```
@antonbabenko
Copy link
Member

This is now fixed in v2.0.0 which works with Terraform 0.12.

dud225 added a commit to dud225/terraform-aws-rds that referenced this pull request Jul 16, 2019
This PR is a follow-up of PR terraform-aws-modules#118.

This is the exact same changeset than terraform-aws-modules#137 but for the `create_db_subnet_group`
variable.
antonbabenko pushed a commit that referenced this pull request Jul 17, 2019
This PR is a follow-up of PR #118.

This is the exact same changeset than #137 but for the `create_db_subnet_group`
variable.
@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants