Skip to content

Commit

Permalink
feat: update google_alloydb_instance resource to have outbound public…
Browse files Browse the repository at this point in the history
… IP field from TF
  • Loading branch information
nancynh committed Sep 16, 2024
1 parent 3149f12 commit 59466ff
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ can have regional availability (nodes are present in 2 or more zones in a region
},
RequiredWith: []string{"network_config.0.enable_public_ip"},
},
"enable_outbound_public_ip": {
Type: schema.TypeBool,
Optional: true,
Description: `Enabling outbound public ip for the instance.`,
},
"enable_public_ip": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -194,6 +199,16 @@ can have regional availability (nodes are present in 2 or more zones in a region
Computed: true,
Description: `The name of the instance resource.`,
},
"outbound_public_ip_addresses": {
Type: schema.TypeList,
Computed: true,
Description: `The outbound public IP addresses for the instance. This is available ONLY when
networkConfig.enableOutboundPublicIp is set to true. These IP addresses are used
for outbound connections.`,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"public_ip_address": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -428,6 +443,9 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error
if err := d.Set("public_ip_address", flattenAlloydbInstancePublicIpAddress(res["publicIpAddress"], d, config)); err != nil {
return fmt.Errorf("Error reading Instance: %s", err)
}
if err := d.Set("outbound_public_ip_addresses", flattenAlloydbInstanceOutboundPublicIpAddresses(res["outboundPublicIpAddresses"], d, config)); err != nil {
return fmt.Errorf("Error reading Instance: %s", err)
}

return nil
}
Expand Down Expand Up @@ -794,6 +812,8 @@ func flattenAlloydbInstanceNetworkConfig(v interface{}, d *schema.ResourceData,
flattenAlloydbInstanceNetworkConfigAuthorizedExternalNetworks(original["authorizedExternalNetworks"], d, config)
transformed["enable_public_ip"] =
flattenAlloydbInstanceNetworkConfigEnablePublicIp(original["enablePublicIp"], d, config)
transformed["enable_outbound_public_ip"] =
flattenAlloydbInstanceNetworkConfigEnableOutboundPublicIp(original["enableOutboundPublicIp"], d, config)
return []interface{}{transformed}
}
func flattenAlloydbInstanceNetworkConfigAuthorizedExternalNetworks(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
Expand Down Expand Up @@ -822,10 +842,17 @@ func flattenAlloydbInstanceNetworkConfigEnablePublicIp(v interface{}, d *schema.
return v
}

func flattenAlloydbInstanceNetworkConfigEnableOutboundPublicIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenAlloydbInstancePublicIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenAlloydbInstanceOutboundPublicIpAddresses(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func expandAlloydbInstanceLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
Expand Down Expand Up @@ -945,6 +972,13 @@ func expandAlloydbInstanceNetworkConfig(v interface{}, d tpgresource.TerraformRe
transformed["enablePublicIp"] = transformedEnablePublicIp
}

transformedEnableOutboundPublicIp, err := expandAlloydbInstanceNetworkConfigEnableOutboundPublicIp(original["enable_outbound_public_ip"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEnableOutboundPublicIp); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["enableOutboundPublicIp"] = transformedEnableOutboundPublicIp
}

return transformed, nil
}

Expand Down Expand Up @@ -977,3 +1011,7 @@ func expandAlloydbInstanceNetworkConfigAuthorizedExternalNetworksCidrRange(v int
func expandAlloydbInstanceNetworkConfigEnablePublicIp(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandAlloydbInstanceNetworkConfigEnableOutboundPublicIp(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

0 comments on commit 59466ff

Please sign in to comment.