Skip to content

Commit

Permalink
feat(dms): support port protocols for kafka instance (#6016)
Browse files Browse the repository at this point in the history
  • Loading branch information
saf3dfsa authored Dec 13, 2024
1 parent 6876e8c commit 2717bee
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 5 deletions.
28 changes: 27 additions & 1 deletion docs/resources/dms_kafka_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ In addition to all arguments above, the following attributes are exported:
* `user_id` - Indicates the ID of the user who created the DMS Kafka instance
* `user_name` - Indicates the name of the user who created the DMS Kafka instance
* `connect_address` - Indicates the IP address of the DMS Kafka instance.
* `cross_vpc_accesses` - Indicates the Access information of cross-VPC. The structure is documented below.
* `cross_vpc_accesses` - Indicates the Access information of cross-VPC.
The [cross_vpc_accesses](#attr_cross_vpc_accesses) structure is documented below.
* `charging_mode` - Indicates the charging mode of the instance.
* `public_ip_address` - Indicates the public IP addresses list of the instance.
* `extend_times` - Indicates the extend times. If the value exceeds `20`, disk expansion is no longer allowed.
Expand All @@ -282,13 +283,38 @@ In addition to all arguments above, the following attributes are exported:
* `pod_connect_address` - Indicates the connection address on the tenant side.
* `public_bandwidth` - Indicates the public network access bandwidth.
* `ssl_two_way_enable` - Indicates whether to enable two-way authentication.
* `port_protocols` - Indicates instance connection address. The structure is documented below.
The [port_protocols](#attr_port_protocols) structure is documented below.

<a name="attr_cross_vpc_accesses"></a>
The `cross_vpc_accesses` block supports:

* `listener_ip` - The listener IP address.
* `port` - The port number.
* `port_id` - The port ID associated with the address.

<a name="attr_port_protocols"></a>
The `port_protocols` block supports:

* `private_plain_enable` - Whether the private plain enabled.
* `private_plain_address` - The private plain address.
* `private_plain_domain_name` - The private plain domain name.
* `private_sasl_ssl_enable` - Whether the private sasl ssl enabled.
* `private_sasl_ssl_address` - The private sasl ssl address.
* `private_sasl_ssl_domain_name` - The private sasl ssl domain name.
* `private_sasl_plaintext_enable` - Whether the private sasl plaintext enabled.
* `private_sasl_plaintext_address` - The private sasl plaintext address.
* `private_sasl_plaintext_domain_name` - The private sasl plaintext domain name.
* `public_plain_enable` - Whether the public plain enabled.
* `public_plain_address` - The public plain address.
* `public_plain_domain_name` - The public plain domain name.
* `public_sasl_ssl_enable` - Whether the public sasl ssl enabled.
* `public_sasl_ssl_address` - The public sasl ssl address.
* `public_sasl_ssl_domain_name` - The public sasl ssl domain name.
* `public_sasl_plaintext_enable` - Whether the public sasl plaintext enabled.
* `public_sasl_plaintext_address` - The public sasl plaintext address.
* `public_sasl_plaintext_domain_name` - The public sasl plaintext domain name.

## Timeouts

This resource provides the following timeouts configuration options:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
github.com/chnsz/golangsdk v0.0.0-20241209021804-a2c6b786dd27
github.com/chnsz/golangsdk v0.0.0-20241213035404-0fa410816029
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chnsz/golangsdk v0.0.0-20241209021804-a2c6b786dd27 h1:qktzho3qYRW5AolHoIN6PwMTGiCKJCYjpwKTMzezih0=
github.com/chnsz/golangsdk v0.0.0-20241209021804-a2c6b786dd27/go.mod h1:Erm4hDWxXgAdbkG3+hhJFgRzEL1TvvcroWzw2Gax4uI=
github.com/chnsz/golangsdk v0.0.0-20241213035404-0fa410816029 h1:76LXmVL0hOBGnQqKm8wEr/7T6UpYTirefLUj4pQbglQ=
github.com/chnsz/golangsdk v0.0.0-20241213035404-0fa410816029/go.mod h1:Erm4hDWxXgAdbkG3+hhJFgRzEL1TvvcroWzw2Gax4uI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down
106 changes: 106 additions & 0 deletions huaweicloud/services/dms/resource_huaweicloud_dms_kafka_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,86 @@ func ResourceDmsKafkaInstance() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"port_protocols": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"private_plain_enable": {
Type: schema.TypeBool,
Computed: true,
},
"private_plain_address": {
Type: schema.TypeString,
Computed: true,
},
"private_plain_domain_name": {
Type: schema.TypeString,
Computed: true,
},
"private_sasl_ssl_enable": {
Type: schema.TypeBool,
Computed: true,
},
"private_sasl_ssl_address": {
Type: schema.TypeString,
Computed: true,
},
"private_sasl_ssl_domain_name": {
Type: schema.TypeString,
Computed: true,
},
"private_sasl_plaintext_enable": {
Type: schema.TypeBool,
Computed: true,
},
"private_sasl_plaintext_address": {
Type: schema.TypeString,
Computed: true,
},
"private_sasl_plaintext_domain_name": {
Type: schema.TypeString,
Computed: true,
},
"public_plain_enable": {
Type: schema.TypeBool,
Computed: true,
},
"public_plain_address": {
Type: schema.TypeString,
Computed: true,
},
"public_plain_domain_name": {
Type: schema.TypeString,
Computed: true,
},
"public_sasl_ssl_enable": {
Type: schema.TypeBool,
Computed: true,
},
"public_sasl_ssl_address": {
Type: schema.TypeString,
Computed: true,
},
"public_sasl_ssl_domain_name": {
Type: schema.TypeString,
Computed: true,
},
"public_sasl_plaintext_enable": {
Type: schema.TypeBool,
Computed: true,
},
"public_sasl_plaintext_address": {
Type: schema.TypeString,
Computed: true,
},
"public_sasl_plaintext_domain_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"manager_user": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1074,6 +1154,7 @@ func resourceDmsKafkaInstanceRead(ctx context.Context, d *schema.ResourceData, m
d.Set("pod_connect_address", v.PodConnectAddress),
d.Set("public_bandwidth", v.PublicBandWidth),
d.Set("ssl_two_way_enable", v.SslTwoWayEnable),
d.Set("port_protocols", flattenKafkaSecurityConfig(v.PortProtocols)),
)

// set tags
Expand Down Expand Up @@ -1144,6 +1225,31 @@ func setKafkaInstanceParameters(ctx context.Context, d *schema.ResourceData, cli
return nil
}

func flattenKafkaSecurityConfig(kafkaSecurityConfig instances.PortProtocols) interface{} {
return []map[string]interface{}{
{
"private_plain_enable": kafkaSecurityConfig.PrivatePlainEnable,
"private_plain_address": kafkaSecurityConfig.PrivatePlainAddress,
"private_plain_domain_name": kafkaSecurityConfig.PrivatePlainDomainName,
"private_sasl_ssl_enable": kafkaSecurityConfig.PrivateSaslSslEnable,
"private_sasl_ssl_address": kafkaSecurityConfig.PrivateSaslSslAddress,
"private_sasl_ssl_domain_name": kafkaSecurityConfig.PrivateSaslSslDomainName,
"private_sasl_plaintext_enable": kafkaSecurityConfig.PrivateSaslPlaintextEnable,
"private_sasl_plaintext_address": kafkaSecurityConfig.PrivateSaslPlaintextAddress,
"private_sasl_plaintext_domain_name": kafkaSecurityConfig.PrivateSaslPlaintextDomainName,
"public_plain_enable": kafkaSecurityConfig.PublicPlainEnable,
"public_plain_address": kafkaSecurityConfig.PublicPlainAddress,
"public_plain_domain_name": kafkaSecurityConfig.PublicPlainDomainName,
"public_sasl_ssl_enable": kafkaSecurityConfig.PublicSaslSslEnable,
"public_sasl_ssl_address": kafkaSecurityConfig.PublicSaslSslAddress,
"public_sasl_ssl_domain_name": kafkaSecurityConfig.PublicSaslSslDomainName,
"public_sasl_plaintext_enable": kafkaSecurityConfig.PublicSaslPlaintextEnable,
"public_sasl_plaintext_address": kafkaSecurityConfig.PublicSaslPlaintextAddress,
"public_sasl_plaintext_domain_name": kafkaSecurityConfig.PublicSaslPlaintextDomainName,
},
}
}

func resourceDmsKafkaInstanceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
cfg := meta.(*config.Config)
client, err := cfg.DmsV2Client(cfg.GetRegion(d))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ github.com/apparentlymart/go-cidr/cidr
# github.com/apparentlymart/go-textseg/v13 v13.0.0
## explicit; go 1.16
github.com/apparentlymart/go-textseg/v13/textseg
# github.com/chnsz/golangsdk v0.0.0-20241209021804-a2c6b786dd27
# github.com/chnsz/golangsdk v0.0.0-20241213035404-0fa410816029
## explicit; go 1.14
github.com/chnsz/golangsdk
github.com/chnsz/golangsdk/auth
Expand Down

0 comments on commit 2717bee

Please sign in to comment.