-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from volcengine/Feat/pg-allowlist
Feat/pg allowlist
- Loading branch information
Showing
28 changed files
with
1,248 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "volcengine_rds_postgresql_allowlists" "foo" { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resource "volcengine_rds_postgresql_allowlist" "foo" { | ||
allow_list_name = "acc-test-allowlist" | ||
allow_list_desc = "acc-test" | ||
allow_list_type = "IPv4" | ||
allow_list = ["192.168.0.0/24", "192.168.1.0/24"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
data "volcengine_zones" "foo" { | ||
} | ||
|
||
resource "volcengine_vpc" "foo" { | ||
vpc_name = "acc-test-vpc" | ||
cidr_block = "172.16.0.0/16" | ||
} | ||
|
||
resource "volcengine_subnet" "foo" { | ||
subnet_name = "acc-test-subnet" | ||
cidr_block = "172.16.0.0/24" | ||
zone_id = data.volcengine_zones.foo.zones[0].id | ||
vpc_id = volcengine_vpc.foo.id | ||
} | ||
|
||
|
||
resource "volcengine_rds_postgresql_instance" "foo" { | ||
db_engine_version = "PostgreSQL_12" | ||
node_spec = "rds.postgres.1c2g" | ||
primary_zone_id = data.volcengine_zones.foo.zones[0].id | ||
secondary_zone_id = data.volcengine_zones.foo.zones[0].id | ||
storage_space = 40 | ||
subnet_id = volcengine_subnet.foo.id | ||
instance_name = "acc-test-postgresql" | ||
charge_info { | ||
charge_type = "PostPaid" | ||
} | ||
project_name = "default" | ||
tags { | ||
key = "tfk1" | ||
value = "tfv1" | ||
} | ||
parameters { | ||
name = "auto_explain.log_analyze" | ||
value = "off" | ||
} | ||
parameters { | ||
name = "auto_explain.log_format" | ||
value = "text" | ||
} | ||
} | ||
|
||
resource "volcengine_rds_postgresql_allowlist" "foo" { | ||
allow_list_name = "acc-test-allowlist" | ||
allow_list_desc = "acc-test" | ||
allow_list_type = "IPv4" | ||
allow_list = ["192.168.0.0/24", "192.168.1.0/24"] | ||
} | ||
|
||
resource "volcengine_rds_postgresql_allowlist_associate" "foo" { | ||
instance_id = volcengine_rds_postgresql_instance.foo.id | ||
allow_list_id = volcengine_rds_postgresql_allowlist.foo.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...s_postgresql/rds_postgresql_allowlist/data_source_volcengine_rds_postgresql_allowlists.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package rds_postgresql_allowlist | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/validation" | ||
ve "github.com/volcengine/terraform-provider-volcengine/common" | ||
) | ||
|
||
func DataSourceVolcengineRdsPostgresqlAllowlists() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceVolcengineRdsPostgresqlAllowlistsRead, | ||
Schema: map[string]*schema.Schema{ | ||
"instance_id": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "The id of the postgresql Instance.", | ||
}, | ||
"name_regex": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validation.StringIsValidRegExp, | ||
Description: "A Name Regex of Resource.", | ||
}, | ||
"output_file": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Description: "File name where to save data source results.", | ||
}, | ||
"total_count": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "The total count of query.", | ||
}, | ||
|
||
"postgresql_allow_lists": { | ||
Description: "The list of postgresql allowed list.", | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of the postgresql allow list.", | ||
}, | ||
"allow_list_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of the postgresql allow list.", | ||
}, | ||
"allow_list_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The name of the postgresql allow list.", | ||
}, | ||
"allow_list_desc": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The description of the postgresql allow list.", | ||
}, | ||
"allow_list_type": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The type of the postgresql allow list.", | ||
}, | ||
"allow_list_ip_num": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "The total number of IP addresses (or address ranges) in the whitelist.", | ||
}, | ||
"associated_instance_num": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Description: "The total number of instances bound under the whitelist.", | ||
}, | ||
"allow_list": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
}, | ||
Description: "The IP address or a range of IP addresses in CIDR format.", | ||
}, | ||
"associated_instances": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "The list of postgresql instances.", | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"instance_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of the postgresql instance.", | ||
}, | ||
"instance_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The name of the postgresql instance.", | ||
}, | ||
"vpc": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The id of the vpc.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceVolcengineRdsPostgresqlAllowlistsRead(d *schema.ResourceData, meta interface{}) error { | ||
service := NewRdsPostgresqlAllowlistService(meta.(*ve.SdkClient)) | ||
return service.Dispatcher.Data(service, d, DataSourceVolcengineRdsPostgresqlAllowlists()) | ||
} |
Oops, something went wrong.