Reputation: 2011
I'm working on AWS rds postgresql instance and we are using IAM authentication. I've created couple of roles, But for one role, I need to give a grant permission. I tried to use if condition but i'm getting an error that null values are not allowed for that attribute. I need to pass grant permissions for the users in the dev_role to access the db using IAM credentials.
What are other solutions, I could use to solve this error? I need to ignore the parameter.
# Create roles/groups
resource "postgresql_role" "pgauth_roles" {
provider = postgresql.pg1
for_each = toset(var.role_name)
name = each.value
roles = [each.value == "dev_role" ? "rds_iam" : null ]
}
on ../../../../tf_module_amp_rds/pg_roles.tf line 14, in resource "postgresql_role" "pgauth_roles":
14: roles = [each.value == "dev_role" ? "rds_iam" : null]
Null values are not allowed for this attribute value.
Terraform v0.12.20 + provider.aws v2.60.0 + provider.postgresql v1.5.
Upvotes: 2
Views: 1125
Reputation: 17574
Try with an empty array []
Something like this:
resource "postgresql_role" "pgauth_roles" {
provider = postgresql.pg1
for_each = toset(var.role_name)
name = each.value
roles = each.value == "dev_role" ? ["rds_iam"] : []
}
Upvotes: 4