diff --git a/builtin/providers/postgresql/resource_postgresql_role.go b/builtin/providers/postgresql/resource_postgresql_role.go index cf74d6c78..767d9c849 100644 --- a/builtin/providers/postgresql/resource_postgresql_role.go +++ b/builtin/providers/postgresql/resource_postgresql_role.go @@ -65,10 +65,10 @@ func resourcePostgreSQLRole() *schema.Resource { Default: true, Description: "Control whether the password is stored encrypted in the system catalogs", }, - roleValidUntilAttr: { Type: schema.TypeString, Optional: true, + Default: "infinity", Description: "Sets a date and time after which the role's password is no longer valid", }, roleConnLimitAttr: { @@ -188,8 +188,8 @@ func resourcePostgreSQLRoleCreate(d *schema.ResourceData, meta interface{}) erro } case opt.hclKey == roleValidUntilAttr: switch { - case v.(string) == "", strings.ToUpper(v.(string)) == "NULL": - createOpts = append(createOpts, fmt.Sprintf("%s %s", opt.sqlKey, "'infinity'")) + case v.(string) == "", strings.ToLower(v.(string)) == "infinity": + createOpts = append(createOpts, fmt.Sprintf("%s '%s'", opt.sqlKey, "infinity")) default: createOpts = append(createOpts, fmt.Sprintf("%s %s", opt.sqlKey, pq.QuoteIdentifier(val))) } diff --git a/builtin/providers/postgresql/resource_postgresql_role_test.go b/builtin/providers/postgresql/resource_postgresql_role_test.go index 31d0b0ebe..c6ff0dec6 100644 --- a/builtin/providers/postgresql/resource_postgresql_role_test.go +++ b/builtin/providers/postgresql/resource_postgresql_role_test.go @@ -46,7 +46,7 @@ func TestAccPostgresqlRole_Basic(t *testing.T) { resource.TestCheckResourceAttr( "postgresql_role.role_with_defaults", "password", ""), resource.TestCheckResourceAttr( - "postgresql_role.role_with_defaults", "valid_until", "NULL"), + "postgresql_role.role_with_defaults", "valid_until", "infinity"), ), }, }, @@ -165,6 +165,6 @@ resource "postgresql_role" "role_with_defaults" { connection_limit = -1 encrypted_password = true password = "" - valid_until = "NULL" + valid_until = "infinity" } `