Skip to content

Commit 29b852a

Browse files
committed
Add features: role, default_privileges
1 parent fab41d3 commit 29b852a

9 files changed

Lines changed: 826 additions & 7 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "cloudsqlpostgresql_default_privileges Resource - cloudsqlpostgresql"
4+
subcategory: ""
5+
description: |-
6+
The cloudsqlpostgresql_default_privileges resource allows to set the privileges that will be applied to objects created in the future. (It does not affect privileges assigned to already-existing objects.).
7+
---
8+
9+
# cloudsqlpostgresql_default_privileges (Resource)
10+
11+
The `cloudsqlpostgresql_default_privileges` resource allows to set the privileges that will be applied to objects created in the future. (It does not affect privileges assigned to already-existing objects.).
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `database` (String) The database
21+
- `owner` (String) The target role
22+
- `privileges` (Attributes Set) A list of privileges (see [below for nested schema](#nestedatt--privileges))
23+
- `role` (String) The role
24+
25+
### Optional
26+
27+
- `object_type` (String) The object type, can be `TABLES`, `SEQUENCES`, `FUNCTIONS`, `ROUTINES`, `TYPES` or `SCHEMAS`. Defaults to `TABLES`.
28+
- `schema` (String) The schema
29+
30+
<a id="nestedatt--privileges"></a>
31+
### Nested Schema for `privileges`
32+
33+
Required:
34+
35+
- `privilege` (String) The privilege to grant
36+
37+
Optional:
38+
39+
- `with_grant_option` (Boolean) Whether the role can grant the same privileges to others.

docs/resources/grant_role.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "cloudsqlpostgresql_grant_role Resource - cloudsqlpostgresql"
4+
subcategory: ""
5+
description: |-
6+
The cloudsqlpostgresql_grant_role resource creates and manages role membership.
7+
---
8+
9+
# cloudsqlpostgresql_grant_role (Resource)
10+
11+
The `cloudsqlpostgresql_grant_role` resource creates and manages role membership.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `group_role` (String) The `group_role` that will get the `role` as member
21+
- `role` (String) The `role` that will be a member of the `group_role`
22+
23+
### Optional
24+
25+
- `admin_option` (Boolean) Enable admin option

docs/resources/grant_schema.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "cloudsqlpostgresql_grant_schema Resource - cloudsqlpostgresql"
44
subcategory: ""
55
description: |-
6-
The cloudsqlpostgresqlgrantschema resource creates and manages privileges given to a user or role on a schema
6+
The cloudsqlpostgresql_grant_schema resource creates and manages privileges given to a user or role on a schema
77
---
88

99
# cloudsqlpostgresql_grant_schema (Resource)
1010

11-
The cloudsqlpostgresql_grant_schema resource creates and manages privileges given to a user or role on a schema
11+
The `cloudsqlpostgresql_grant_schema` resource creates and manages privileges given to a user or role on a schema
1212

1313
## Example Usage
1414

docs/resources/role.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "cloudsqlpostgresql_role Resource - cloudsqlpostgresql"
4+
subcategory: ""
5+
description: |-
6+
The cloudsqlpostgresql_role resource creates and manages a role. The superuser option is not supported on Cloud SQL.
7+
---
8+
9+
# cloudsqlpostgresql_role (Resource)
10+
11+
The `cloudsqlpostgresql_role` resource creates and manages a role. The superuser option is not supported on Cloud SQL.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `name` (String) The name of the role
21+
22+
### Optional
23+
24+
- `connection_limit` (Number) Specifies how many concurrent connections the role can make. -1 (the default) means no limit
25+
- `has_bypassrls_option` (Boolean) Whether the role has the BYPASSRLS option
26+
- `has_createdb_option` (Boolean) Whether or not this role has the CREATEDB option
27+
- `has_createrole_option` (Boolean) Whether the role has the CREATEROLE option
28+
- `has_inherit_option` (Boolean) Whether the role has the INHERIT option
29+
- `has_replication_option` (Boolean) Whether the role has the REPLICATION option
30+
- `is_user` (Boolean) Is this role a user that can login
31+
- `is_valid_until` (String) Sets a date and time after which the role's password is no longer valid
32+
- `password` (String, Sensitive) Sets the role's password

internal/provider/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (c *Config) connectToPostgresqlDb(dbName string) (*sql.DB, error) {
2525
}
2626

2727
func (c *Config) connectToPostgresqlNoDb() (*sql.DB, error) {
28-
dsn := fmt.Sprintf(c.dsnTemplate, "")
28+
dsn := fmt.Sprintf(c.dsnTemplate, "dbname=postgres")
2929
return c.connectToPostgresql(dsn)
3030
}
3131

internal/provider/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ func (p *CloudSqlPostgresqlProvider) Resources(ctx context.Context) []func() res
230230
newSchemaGrantResource,
231231
newTableGrantResource,
232232
newRoleResource,
233+
newRoleGrantResource,
234+
newDefaultPrivilegesResource,
233235
}
234236
}
235237

0 commit comments

Comments
 (0)