diff --git a/.changelog/8876.txt b/.changelog/8876.txt new file mode 100644 index 00000000000..e85de6d494b --- /dev/null +++ b/.changelog/8876.txt @@ -0,0 +1,12 @@ +```release-note:enhancement +containeraws: added support for `auto_repair` in `container_aws_node_pool` +``` +```release-note:enhancement +containerazure: added support for `auto_repair` in `container_azure_node_pool` +``` +```release-note:enhancement +networkconnectivity: added support for `linked_vpc_network` in `network_connectivity_spoke` +``` +```release-note:bug +eventarc: field `event_data_content_type` in `eventarc_trigger` now marked as computed +``` diff --git a/go.mod b/go.mod index 99b3c0f062d..a3146d8a851 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ go 1.19 require ( cloud.google.com/go/bigtable v1.19.0 - github.com/GoogleCloudPlatform/declarative-resource-client-library v1.50.0 + github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0 github.com/apparentlymart/go-cidr v1.1.0 github.com/davecgh/go-spew v1.1.1 github.com/dnaeon/go-vcr v1.0.1 diff --git a/go.sum b/go.sum index 20520324106..f1131ffa5f8 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,8 @@ cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+K cloud.google.com/go/longrunning v0.5.1 h1:Fr7TXftcqTudoyRJa113hyaqlGdiBQkp0Gq7tErFDWI= cloud.google.com/go/longrunning v0.5.1/go.mod h1:spvimkwdz6SPWKEt/XBij79E9fiTkHSQl/fRUUQJYJc= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.50.0 h1:tsuB2FrGmDXIPUdhRD6YdUuvIzAly6+RYpyRkKWwk9E= -github.com/GoogleCloudPlatform/declarative-resource-client-library v1.50.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0 h1:YhWTPhOf6gVpA9mSfnLOuL8Y6j8W5pzmHE7flXjTke4= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= @@ -466,3 +466,5 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0 h1:YhWTPhOf6gVpA9mSfnLOuL8Y6j8W5pzmHE7flXjTke4= +github.com/GoogleCloudPlatform/declarative-resource-client-library v1.51.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k= diff --git a/google/services/containeraws/resource_container_aws_node_pool.go b/google/services/containeraws/resource_container_aws_node_pool.go index b34048e8c5a..9a6cf33f4f3 100644 --- a/google/services/containeraws/resource_container_aws_node_pool.go +++ b/google/services/containeraws/resource_container_aws_node_pool.go @@ -119,6 +119,15 @@ func ResourceContainerAwsNodePool() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, + "management": { + Type: schema.TypeList, + Computed: true, + Optional: true, + Description: "The Management configuration for this node pool.", + MaxItems: 1, + Elem: ContainerAwsNodePoolManagementSchema(), + }, + "project": { Type: schema.TypeString, Computed: true, @@ -214,7 +223,6 @@ func ContainerAwsNodePoolConfigSchema() *schema.Resource { Type: schema.TypeString, Computed: true, Optional: true, - ForceNew: true, Description: "Optional. The AWS instance type. When unspecified, it defaults to `m5.large`.", }, @@ -418,6 +426,19 @@ func ContainerAwsNodePoolMaxPodsConstraintSchema() *schema.Resource { } } +func ContainerAwsNodePoolManagementSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "auto_repair": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + Description: "Optional. Whether or not the nodes will be automatically repaired.", + }, + }, + } +} + func resourceContainerAwsNodePoolCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) @@ -435,6 +456,7 @@ func resourceContainerAwsNodePoolCreate(d *schema.ResourceData, meta interface{} SubnetId: dcl.String(d.Get("subnet_id").(string)), Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), + Management: expandContainerAwsNodePoolManagement(d.Get("management")), Project: dcl.String(project), } @@ -492,6 +514,7 @@ func resourceContainerAwsNodePoolRead(d *schema.ResourceData, meta interface{}) SubnetId: dcl.String(d.Get("subnet_id").(string)), Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), + Management: expandContainerAwsNodePoolManagement(d.Get("management")), Project: dcl.String(project), } @@ -544,6 +567,9 @@ func resourceContainerAwsNodePoolRead(d *schema.ResourceData, meta interface{}) if err = d.Set("annotations", res.Annotations); err != nil { return fmt.Errorf("error setting annotations in state: %s", err) } + if err = d.Set("management", tpgresource.FlattenContainerAwsNodePoolManagement(res.Management, d, config)); err != nil { + return fmt.Errorf("error setting management in state: %s", err) + } if err = d.Set("project", res.Project); err != nil { return fmt.Errorf("error setting project in state: %s", err) } @@ -585,6 +611,7 @@ func resourceContainerAwsNodePoolUpdate(d *schema.ResourceData, meta interface{} SubnetId: dcl.String(d.Get("subnet_id").(string)), Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), + Management: expandContainerAwsNodePoolManagement(d.Get("management")), Project: dcl.String(project), } directive := tpgdclresource.UpdateDirective @@ -637,6 +664,7 @@ func resourceContainerAwsNodePoolDelete(d *schema.ResourceData, meta interface{} SubnetId: dcl.String(d.Get("subnet_id").(string)), Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), + Management: expandContainerAwsNodePoolManagement(d.Get("management")), Project: dcl.String(project), } @@ -986,3 +1014,29 @@ func flattenContainerAwsNodePoolMaxPodsConstraint(obj *containeraws.NodePoolMaxP return []interface{}{transformed} } + +func expandContainerAwsNodePoolManagement(o interface{}) *containeraws.NodePoolManagement { + if o == nil { + return nil + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return nil + } + obj := objArr[0].(map[string]interface{}) + return &containeraws.NodePoolManagement{ + AutoRepair: dcl.Bool(obj["auto_repair"].(bool)), + } +} + +func flattenContainerAwsNodePoolManagement(obj *containeraws.NodePoolManagement) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "auto_repair": obj.AutoRepair, + } + + return []interface{}{transformed} + +} diff --git a/google/services/containeraws/resource_container_aws_node_pool_generated_test.go b/google/services/containeraws/resource_container_aws_node_pool_generated_test.go index b991bb1ad69..40419613a40 100644 --- a/google/services/containeraws/resource_container_aws_node_pool_generated_test.go +++ b/google/services/containeraws/resource_container_aws_node_pool_generated_test.go @@ -63,7 +63,7 @@ func TestAccContainerAwsNodePool_BasicHandWritten(t *testing.T) { ResourceName: "google_container_aws_node_pool.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"fleet.0.project"}, + ImportStateVerifyIgnore: []string{"fleet.0.project", "management.#", "management.0.%", "management.0.auto_repair"}, }, { Config: testAccContainerAwsNodePool_BasicHandWrittenUpdate0(context), @@ -72,7 +72,7 @@ func TestAccContainerAwsNodePool_BasicHandWritten(t *testing.T) { ResourceName: "google_container_aws_node_pool.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"fleet.0.project"}, + ImportStateVerifyIgnore: []string{"fleet.0.project", "management.#", "management.0.%", "management.0.auto_repair"}, }, }, }) @@ -107,7 +107,7 @@ func TestAccContainerAwsNodePool_BasicEnumHandWritten(t *testing.T) { ResourceName: "google_container_aws_node_pool.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"fleet.0.project"}, + ImportStateVerifyIgnore: []string{"fleet.0.project", "management.#", "management.0.%", "management.0.auto_repair"}, }, { Config: testAccContainerAwsNodePool_BasicEnumHandWrittenUpdate0(context), @@ -116,7 +116,7 @@ func TestAccContainerAwsNodePool_BasicEnumHandWritten(t *testing.T) { ResourceName: "google_container_aws_node_pool.primary", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"fleet.0.project"}, + ImportStateVerifyIgnore: []string{"fleet.0.project", "management.#", "management.0.%", "management.0.auto_repair"}, }, }, }) @@ -272,6 +272,10 @@ resource "google_container_aws_node_pool" "primary" { label-one = "value-one" } + management { + auto_repair = true + } + project = "%{project_name}" } @@ -428,6 +432,10 @@ resource "google_container_aws_node_pool" "primary" { label-two = "value-two" } + management { + auto_repair = false + } + project = "%{project_name}" } diff --git a/google/services/containerazure/resource_container_azure_node_pool.go b/google/services/containerazure/resource_container_azure_node_pool.go index 56f790deb28..166901e8f1b 100644 --- a/google/services/containerazure/resource_container_azure_node_pool.go +++ b/google/services/containerazure/resource_container_azure_node_pool.go @@ -127,6 +127,15 @@ func ResourceContainerAzureNodePool() *schema.Resource { Description: "Optional. The Azure availability zone of the nodes in this nodepool. When unspecified, it defaults to `1`.", }, + "management": { + Type: schema.TypeList, + Computed: true, + Optional: true, + Description: "The Management configuration for this node pool.", + MaxItems: 1, + Elem: ContainerAzureNodePoolManagementSchema(), + }, + "project": { Type: schema.TypeString, Computed: true, @@ -301,6 +310,19 @@ func ContainerAzureNodePoolMaxPodsConstraintSchema() *schema.Resource { } } +func ContainerAzureNodePoolManagementSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "auto_repair": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + Description: "Optional. Whether or not the nodes will be automatically repaired.", + }, + }, + } +} + func resourceContainerAzureNodePoolCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) project, err := tpgresource.GetProject(d, config) @@ -319,6 +341,7 @@ func resourceContainerAzureNodePoolCreate(d *schema.ResourceData, meta interface Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), AzureAvailabilityZone: dcl.StringOrNil(d.Get("azure_availability_zone").(string)), + Management: expandContainerAzureNodePoolManagement(d.Get("management")), Project: dcl.String(project), } @@ -377,6 +400,7 @@ func resourceContainerAzureNodePoolRead(d *schema.ResourceData, meta interface{} Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), AzureAvailabilityZone: dcl.StringOrNil(d.Get("azure_availability_zone").(string)), + Management: expandContainerAzureNodePoolManagement(d.Get("management")), Project: dcl.String(project), } @@ -432,6 +456,9 @@ func resourceContainerAzureNodePoolRead(d *schema.ResourceData, meta interface{} if err = d.Set("azure_availability_zone", res.AzureAvailabilityZone); err != nil { return fmt.Errorf("error setting azure_availability_zone in state: %s", err) } + if err = d.Set("management", tpgresource.FlattenContainerAzureNodePoolManagement(res.Management, d, config)); err != nil { + return fmt.Errorf("error setting management in state: %s", err) + } if err = d.Set("project", res.Project); err != nil { return fmt.Errorf("error setting project in state: %s", err) } @@ -474,6 +501,7 @@ func resourceContainerAzureNodePoolUpdate(d *schema.ResourceData, meta interface Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), AzureAvailabilityZone: dcl.StringOrNil(d.Get("azure_availability_zone").(string)), + Management: expandContainerAzureNodePoolManagement(d.Get("management")), Project: dcl.String(project), } directive := tpgdclresource.UpdateDirective @@ -527,6 +555,7 @@ func resourceContainerAzureNodePoolDelete(d *schema.ResourceData, meta interface Version: dcl.String(d.Get("version").(string)), Annotations: tpgresource.CheckStringMap(d.Get("annotations")), AzureAvailabilityZone: dcl.StringOrNil(d.Get("azure_availability_zone").(string)), + Management: expandContainerAzureNodePoolManagement(d.Get("management")), Project: dcl.String(project), } @@ -743,3 +772,29 @@ func flattenContainerAzureNodePoolMaxPodsConstraint(obj *containerazure.NodePool return []interface{}{transformed} } + +func expandContainerAzureNodePoolManagement(o interface{}) *containerazure.NodePoolManagement { + if o == nil { + return nil + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return nil + } + obj := objArr[0].(map[string]interface{}) + return &containerazure.NodePoolManagement{ + AutoRepair: dcl.Bool(obj["auto_repair"].(bool)), + } +} + +func flattenContainerAzureNodePoolManagement(obj *containerazure.NodePoolManagement) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "auto_repair": obj.AutoRepair, + } + + return []interface{}{transformed} + +} diff --git a/google/services/containerazure/resource_container_azure_node_pool_generated_test.go b/google/services/containerazure/resource_container_azure_node_pool_generated_test.go index 07747f1789b..7d34a52a5aa 100644 --- a/google/services/containerazure/resource_container_azure_node_pool_generated_test.go +++ b/google/services/containerazure/resource_container_azure_node_pool_generated_test.go @@ -56,17 +56,19 @@ func TestAccContainerAzureNodePool_BasicHandWritten(t *testing.T) { Config: testAccContainerAzureNodePool_BasicHandWritten(context), }, { - ResourceName: "google_container_azure_node_pool.primary", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_container_azure_node_pool.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"management.#", "management.0.%", "management.0.auto_repair"}, }, { Config: testAccContainerAzureNodePool_BasicHandWrittenUpdate0(context), }, { - ResourceName: "google_container_azure_node_pool.primary", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_container_azure_node_pool.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"management.#", "management.0.%", "management.0.auto_repair"}, }, }, }) @@ -166,6 +168,10 @@ resource "google_container_azure_node_pool" "primary" { annotation-one = "value-one" } + management { + auto_repair = true + } + project = "%{project_name}" } @@ -268,6 +274,10 @@ resource "google_container_azure_node_pool" "primary" { annotation-two = "value-two" } + management { + auto_repair = false + } + project = "%{project_name}" } diff --git a/google/services/eventarc/resource_eventarc_trigger.go b/google/services/eventarc/resource_eventarc_trigger.go index 50b9b0fd54c..6b5f79692f9 100644 --- a/google/services/eventarc/resource_eventarc_trigger.go +++ b/google/services/eventarc/resource_eventarc_trigger.go @@ -92,6 +92,7 @@ func ResourceEventarcTrigger() *schema.Resource { "event_data_content_type": { Type: schema.TypeString, + Computed: true, Optional: true, Description: "Optional. EventDataContentType specifies the type of payload in MIME format that is expected from the CloudEvent data field. This is set to `application/json` if the value is not defined.", }, @@ -334,7 +335,7 @@ func resourceEventarcTriggerCreate(d *schema.ResourceData, meta interface{}) err MatchingCriteria: expandEventarcTriggerMatchingCriteriaArray(d.Get("matching_criteria")), Name: dcl.String(d.Get("name").(string)), Channel: dcl.String(d.Get("channel").(string)), - EventDataContentType: dcl.String(d.Get("event_data_content_type").(string)), + EventDataContentType: dcl.StringOrNil(d.Get("event_data_content_type").(string)), Labels: tpgresource.CheckStringMap(d.Get("labels")), Project: dcl.String(project), ServiceAccount: dcl.String(d.Get("service_account").(string)), @@ -391,7 +392,7 @@ func resourceEventarcTriggerRead(d *schema.ResourceData, meta interface{}) error MatchingCriteria: expandEventarcTriggerMatchingCriteriaArray(d.Get("matching_criteria")), Name: dcl.String(d.Get("name").(string)), Channel: dcl.String(d.Get("channel").(string)), - EventDataContentType: dcl.String(d.Get("event_data_content_type").(string)), + EventDataContentType: dcl.StringOrNil(d.Get("event_data_content_type").(string)), Labels: tpgresource.CheckStringMap(d.Get("labels")), Project: dcl.String(project), ServiceAccount: dcl.String(d.Get("service_account").(string)), @@ -481,7 +482,7 @@ func resourceEventarcTriggerUpdate(d *schema.ResourceData, meta interface{}) err MatchingCriteria: expandEventarcTriggerMatchingCriteriaArray(d.Get("matching_criteria")), Name: dcl.String(d.Get("name").(string)), Channel: dcl.String(d.Get("channel").(string)), - EventDataContentType: dcl.String(d.Get("event_data_content_type").(string)), + EventDataContentType: dcl.StringOrNil(d.Get("event_data_content_type").(string)), Labels: tpgresource.CheckStringMap(d.Get("labels")), Project: dcl.String(project), ServiceAccount: dcl.String(d.Get("service_account").(string)), @@ -533,7 +534,7 @@ func resourceEventarcTriggerDelete(d *schema.ResourceData, meta interface{}) err MatchingCriteria: expandEventarcTriggerMatchingCriteriaArray(d.Get("matching_criteria")), Name: dcl.String(d.Get("name").(string)), Channel: dcl.String(d.Get("channel").(string)), - EventDataContentType: dcl.String(d.Get("event_data_content_type").(string)), + EventDataContentType: dcl.StringOrNil(d.Get("event_data_content_type").(string)), Labels: tpgresource.CheckStringMap(d.Get("labels")), Project: dcl.String(project), ServiceAccount: dcl.String(d.Get("service_account").(string)), diff --git a/google/services/eventarc/resource_eventarc_trigger_generated_test.go b/google/services/eventarc/resource_eventarc_trigger_generated_test.go index 0299d522672..7c42708051e 100644 --- a/google/services/eventarc/resource_eventarc_trigger_generated_test.go +++ b/google/services/eventarc/resource_eventarc_trigger_generated_test.go @@ -325,7 +325,7 @@ func testAccCheckEventarcTriggerDestroyProducer(t *testing.T) func(s *terraform. Location: dcl.String(rs.Primary.Attributes["location"]), Name: dcl.String(rs.Primary.Attributes["name"]), Channel: dcl.String(rs.Primary.Attributes["channel"]), - EventDataContentType: dcl.String(rs.Primary.Attributes["event_data_content_type"]), + EventDataContentType: dcl.StringOrNil(rs.Primary.Attributes["event_data_content_type"]), Project: dcl.StringOrNil(rs.Primary.Attributes["project"]), ServiceAccount: dcl.String(rs.Primary.Attributes["service_account"]), CreateTime: dcl.StringOrNil(rs.Primary.Attributes["create_time"]), diff --git a/google/services/networkconnectivity/resource_network_connectivity_spoke.go b/google/services/networkconnectivity/resource_network_connectivity_spoke.go index dee3cf5da64..9461d02aa6e 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_spoke.go +++ b/google/services/networkconnectivity/resource_network_connectivity_spoke.go @@ -94,7 +94,7 @@ func ResourceNetworkConnectivitySpoke() *schema.Resource { Description: "A collection of VLAN attachment resources. These resources should be redundant attachments that all advertise the same prefixes to Google Cloud. Alternatively, in active/passive configurations, all attachments should be capable of advertising the same prefixes.", MaxItems: 1, Elem: NetworkConnectivitySpokeLinkedInterconnectAttachmentsSchema(), - ConflictsWith: []string{"linked_vpn_tunnels", "linked_router_appliance_instances"}, + ConflictsWith: []string{"linked_vpn_tunnels", "linked_router_appliance_instances", "linked_vpc_network"}, }, "linked_router_appliance_instances": { @@ -104,7 +104,17 @@ func ResourceNetworkConnectivitySpoke() *schema.Resource { Description: "The URIs of linked Router appliance resources", MaxItems: 1, Elem: NetworkConnectivitySpokeLinkedRouterApplianceInstancesSchema(), - ConflictsWith: []string{"linked_vpn_tunnels", "linked_interconnect_attachments"}, + ConflictsWith: []string{"linked_vpn_tunnels", "linked_interconnect_attachments", "linked_vpc_network"}, + }, + + "linked_vpc_network": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: "VPC network that is associated with the spoke.", + MaxItems: 1, + Elem: NetworkConnectivitySpokeLinkedVPCNetworkSchema(), + ConflictsWith: []string{"linked_vpn_tunnels", "linked_interconnect_attachments", "linked_router_appliance_instances"}, }, "linked_vpn_tunnels": { @@ -114,7 +124,7 @@ func ResourceNetworkConnectivitySpoke() *schema.Resource { Description: "The URIs of linked VPN tunnel resources", MaxItems: 1, Elem: NetworkConnectivitySpokeLinkedVpnTunnelsSchema(), - ConflictsWith: []string{"linked_interconnect_attachments", "linked_router_appliance_instances"}, + ConflictsWith: []string{"linked_interconnect_attachments", "linked_router_appliance_instances", "linked_vpc_network"}, }, "project": { @@ -216,6 +226,28 @@ func NetworkConnectivitySpokeLinkedRouterApplianceInstancesInstancesSchema() *sc } } +func NetworkConnectivitySpokeLinkedVPCNetworkSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "uri": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + Description: "The URI of the VPC network resource.", + }, + + "exclude_export_ranges": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: "IP ranges encompassing the subnets to be excluded from peering.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + } +} + func NetworkConnectivitySpokeLinkedVpnTunnelsSchema() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -252,6 +284,7 @@ func resourceNetworkConnectivitySpokeCreate(d *schema.ResourceData, meta interfa Labels: tpgresource.CheckStringMap(d.Get("labels")), LinkedInterconnectAttachments: expandNetworkConnectivitySpokeLinkedInterconnectAttachments(d.Get("linked_interconnect_attachments")), LinkedRouterApplianceInstances: expandNetworkConnectivitySpokeLinkedRouterApplianceInstances(d.Get("linked_router_appliance_instances")), + LinkedVPCNetwork: expandNetworkConnectivitySpokeLinkedVPCNetwork(d.Get("linked_vpc_network")), LinkedVpnTunnels: expandNetworkConnectivitySpokeLinkedVpnTunnels(d.Get("linked_vpn_tunnels")), Project: dcl.String(project), } @@ -308,6 +341,7 @@ func resourceNetworkConnectivitySpokeRead(d *schema.ResourceData, meta interface Labels: tpgresource.CheckStringMap(d.Get("labels")), LinkedInterconnectAttachments: expandNetworkConnectivitySpokeLinkedInterconnectAttachments(d.Get("linked_interconnect_attachments")), LinkedRouterApplianceInstances: expandNetworkConnectivitySpokeLinkedRouterApplianceInstances(d.Get("linked_router_appliance_instances")), + LinkedVPCNetwork: expandNetworkConnectivitySpokeLinkedVPCNetwork(d.Get("linked_vpc_network")), LinkedVpnTunnels: expandNetworkConnectivitySpokeLinkedVpnTunnels(d.Get("linked_vpn_tunnels")), Project: dcl.String(project), } @@ -355,6 +389,9 @@ func resourceNetworkConnectivitySpokeRead(d *schema.ResourceData, meta interface if err = d.Set("linked_router_appliance_instances", flattenNetworkConnectivitySpokeLinkedRouterApplianceInstances(res.LinkedRouterApplianceInstances)); err != nil { return fmt.Errorf("error setting linked_router_appliance_instances in state: %s", err) } + if err = d.Set("linked_vpc_network", flattenNetworkConnectivitySpokeLinkedVPCNetwork(res.LinkedVPCNetwork)); err != nil { + return fmt.Errorf("error setting linked_vpc_network in state: %s", err) + } if err = d.Set("linked_vpn_tunnels", flattenNetworkConnectivitySpokeLinkedVpnTunnels(res.LinkedVpnTunnels)); err != nil { return fmt.Errorf("error setting linked_vpn_tunnels in state: %s", err) } @@ -391,6 +428,7 @@ func resourceNetworkConnectivitySpokeUpdate(d *schema.ResourceData, meta interfa Labels: tpgresource.CheckStringMap(d.Get("labels")), LinkedInterconnectAttachments: expandNetworkConnectivitySpokeLinkedInterconnectAttachments(d.Get("linked_interconnect_attachments")), LinkedRouterApplianceInstances: expandNetworkConnectivitySpokeLinkedRouterApplianceInstances(d.Get("linked_router_appliance_instances")), + LinkedVPCNetwork: expandNetworkConnectivitySpokeLinkedVPCNetwork(d.Get("linked_vpc_network")), LinkedVpnTunnels: expandNetworkConnectivitySpokeLinkedVpnTunnels(d.Get("linked_vpn_tunnels")), Project: dcl.String(project), } @@ -442,6 +480,7 @@ func resourceNetworkConnectivitySpokeDelete(d *schema.ResourceData, meta interfa Labels: tpgresource.CheckStringMap(d.Get("labels")), LinkedInterconnectAttachments: expandNetworkConnectivitySpokeLinkedInterconnectAttachments(d.Get("linked_interconnect_attachments")), LinkedRouterApplianceInstances: expandNetworkConnectivitySpokeLinkedRouterApplianceInstances(d.Get("linked_router_appliance_instances")), + LinkedVPCNetwork: expandNetworkConnectivitySpokeLinkedVPCNetwork(d.Get("linked_vpc_network")), LinkedVpnTunnels: expandNetworkConnectivitySpokeLinkedVpnTunnels(d.Get("linked_vpn_tunnels")), Project: dcl.String(project), } @@ -605,6 +644,34 @@ func flattenNetworkConnectivitySpokeLinkedRouterApplianceInstancesInstances(obj } +func expandNetworkConnectivitySpokeLinkedVPCNetwork(o interface{}) *networkconnectivity.SpokeLinkedVPCNetwork { + if o == nil { + return networkconnectivity.EmptySpokeLinkedVPCNetwork + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return networkconnectivity.EmptySpokeLinkedVPCNetwork + } + obj := objArr[0].(map[string]interface{}) + return &networkconnectivity.SpokeLinkedVPCNetwork{ + Uri: dcl.String(obj["uri"].(string)), + ExcludeExportRanges: tpgdclresource.ExpandStringArray(obj["exclude_export_ranges"]), + } +} + +func flattenNetworkConnectivitySpokeLinkedVPCNetwork(obj *networkconnectivity.SpokeLinkedVPCNetwork) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "uri": obj.Uri, + "exclude_export_ranges": obj.ExcludeExportRanges, + } + + return []interface{}{transformed} + +} + func expandNetworkConnectivitySpokeLinkedVpnTunnels(o interface{}) *networkconnectivity.SpokeLinkedVpnTunnels { if o == nil { return networkconnectivity.EmptySpokeLinkedVpnTunnels diff --git a/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_test.go b/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_test.go index 9e32b2dc8be..2fa41dc1404 100644 --- a/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_test.go +++ b/google/services/networkconnectivity/resource_network_connectivity_spoke_generated_test.go @@ -33,6 +33,39 @@ import ( transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" ) +func TestAccNetworkConnectivitySpoke_LinkedVPCNetworkHandWritten(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "project_name": envvar.GetTestProjectFromEnv(), + "region": envvar.GetTestRegionFromEnv(), + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckNetworkConnectivitySpokeDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccNetworkConnectivitySpoke_LinkedVPCNetworkHandWritten(context), + }, + { + ResourceName: "google_network_connectivity_spoke.primary", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccNetworkConnectivitySpoke_LinkedVPCNetworkHandWrittenUpdate0(context), + }, + { + ResourceName: "google_network_connectivity_spoke.primary", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} func TestAccNetworkConnectivitySpoke_RouterApplianceHandWritten(t *testing.T) { t.Parallel() @@ -68,6 +101,76 @@ func TestAccNetworkConnectivitySpoke_RouterApplianceHandWritten(t *testing.T) { }) } +func testAccNetworkConnectivitySpoke_LinkedVPCNetworkHandWritten(context map[string]interface{}) string { + return acctest.Nprintf(` + +resource "google_compute_network" "network" { + name = "tf-test-network%{random_suffix}" + auto_create_subnetworks = false +} + +resource "google_network_connectivity_hub" "basic_hub" { + name = "tf-test-hub%{random_suffix}" + description = "A sample hub" + labels = { + label-two = "value-one" + } +} + +resource "google_network_connectivity_spoke" "primary" { + name = "tf-test-name%{random_suffix}" + location = "global" + description = "A sample spoke with a linked routher appliance instance" + labels = { + label-one = "value-one" + } + hub = google_network_connectivity_hub.basic_hub.id + linked_vpc_network { + exclude_export_ranges = [ + "198.51.100.0/24", + "10.10.0.0/16" + ] + uri = google_compute_network.network.self_link + } +} +`, context) +} + +func testAccNetworkConnectivitySpoke_LinkedVPCNetworkHandWrittenUpdate0(context map[string]interface{}) string { + return acctest.Nprintf(` + +resource "google_compute_network" "network" { + name = "tf-test-network%{random_suffix}" + auto_create_subnetworks = false +} + +resource "google_network_connectivity_hub" "basic_hub" { + name = "tf-test-hub%{random_suffix}" + description = "A sample hub" + labels = { + label-two = "value-one" + } +} + +resource "google_network_connectivity_spoke" "primary" { + name = "tf-test-name%{random_suffix}" + location = "global" + description = "A sample spoke with a linked routher appliance instance" + labels = { + label-one = "value-one" + } + hub = google_network_connectivity_hub.basic_hub.id + linked_vpc_network { + exclude_export_ranges = [ + "198.51.100.0/24", + "10.10.0.0/16" + ] + uri = google_compute_network.network.self_link + } +} +`, context) +} + func testAccNetworkConnectivitySpoke_RouterApplianceHandWritten(context map[string]interface{}) string { return acctest.Nprintf(` diff --git a/google/tpgresource/common_diff_suppress.go b/google/tpgresource/common_diff_suppress.go index 8f3bf07a9a1..6413a654e0f 100644 --- a/google/tpgresource/common_diff_suppress.go +++ b/google/tpgresource/common_diff_suppress.go @@ -56,6 +56,11 @@ func EmptyOrDefaultStringSuppress(defaultVal string) schema.SchemaDiffSuppressFu } } +func EmptyOrFalseSuppressBoolean(k, old, new string, d *schema.ResourceData) bool { + o, n := d.GetChange(k) + return (o == nil && !n.(bool)) +} + func IpCidrRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { // The range may be a: // A) single IP address (e.g. 10.2.3.4) diff --git a/google/tpgresource/tpgtools_custom_flattens.go b/google/tpgresource/tpgtools_custom_flattens.go new file mode 100644 index 00000000000..ce67f6e3ed8 --- /dev/null +++ b/google/tpgresource/tpgtools_custom_flattens.go @@ -0,0 +1,41 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 +package tpgresource + +import ( + containeraws "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/containeraws" + containerazure "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/containerazure" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" +) + +func FlattenContainerAwsNodePoolManagement(obj *containeraws.NodePoolManagement, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if obj == nil { + return nil + } + transformed := make(map[string]interface{}) + + if obj.AutoRepair == nil || obj.Empty() { + transformed["auto_repair"] = false + } else { + transformed["auto_repair"] = obj.AutoRepair + } + + return []interface{}{transformed} +} + +func FlattenContainerAzureNodePoolManagement(obj *containerazure.NodePoolManagement, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if obj == nil { + return nil + } + transformed := make(map[string]interface{}) + + if obj.AutoRepair == nil || obj.Empty() { + transformed["auto_repair"] = false + } else { + transformed["auto_repair"] = obj.AutoRepair + } + + return []interface{}{transformed} +} diff --git a/website/docs/r/container_aws_node_pool.html.markdown b/website/docs/r/container_aws_node_pool.html.markdown index fce276da3ec..262ad6686d5 100644 --- a/website/docs/r/container_aws_node_pool.html.markdown +++ b/website/docs/r/container_aws_node_pool.html.markdown @@ -175,6 +175,10 @@ resource "google_container_aws_node_pool" "primary" { label-one = "value-one" } + management { + auto_repair = true + } + project = "my-project-name" } @@ -626,6 +630,10 @@ The `max_pods_constraint` block supports: (Optional) Optional. Annotations on the node pool. This field has the same restrictions as Kubernetes annotations. The total size of all keys and values combined is limited to 256k. Key can have 2 segments: prefix (optional) and name (required), separated by a slash (/). Prefix must be a DNS subdomain. Name must be 63 characters or less, begin and end with alphanumerics, with dashes (-), underscores (_), dots (.), and alphanumerics between. +* `management` - + (Optional) + The Management configuration for this node pool. + * `project` - (Optional) The project for the resource @@ -706,6 +714,12 @@ The `taints` block supports: (Required) Value for the taint. +The `management` block supports: + +* `auto_repair` - + (Optional) + Optional. Whether or not the nodes will be automatically repaired. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/container_azure_node_pool.html.markdown b/website/docs/r/container_azure_node_pool.html.markdown index 66cf7a65f57..7d9150ea966 100644 --- a/website/docs/r/container_azure_node_pool.html.markdown +++ b/website/docs/r/container_azure_node_pool.html.markdown @@ -119,6 +119,10 @@ resource "google_container_azure_node_pool" "primary" { annotation-one = "value-one" } + management { + auto_repair = true + } + project = "my-project-name" } @@ -221,6 +225,10 @@ The `max_pods_constraint` block supports: (Optional) Optional. The Azure availability zone of the nodes in this nodepool. When unspecified, it defaults to `1`. +* `management` - + (Optional) + The Management configuration for this node pool. + * `project` - (Optional) The project for the resource @@ -243,6 +251,12 @@ The `root_volume` block supports: (Optional) Optional. The size of the disk, in GiBs. When unspecified, a default value is provided. See the specific reference in the parent resource. +The `management` block supports: + +* `auto_repair` - + (Optional) + Optional. Whether or not the nodes will be automatically repaired. + ## Attributes Reference In addition to the arguments listed above, the following computed attributes are exported: diff --git a/website/docs/r/network_connectivity_spoke.html.markdown b/website/docs/r/network_connectivity_spoke.html.markdown index fc7dc76f56e..dfddbc6529e 100644 --- a/website/docs/r/network_connectivity_spoke.html.markdown +++ b/website/docs/r/network_connectivity_spoke.html.markdown @@ -22,6 +22,39 @@ description: |- The NetworkConnectivity Spoke resource +## Example Usage - linked_vpc_network +```hcl + +resource "google_compute_network" "network" { + name = "network" + auto_create_subnetworks = false +} + +resource "google_network_connectivity_hub" "basic_hub" { + name = "hub" + description = "A sample hub" + labels = { + label-two = "value-one" + } +} + +resource "google_network_connectivity_spoke" "primary" { + name = "name" + location = "global" + description = "A sample spoke with a linked routher appliance instance" + labels = { + label-one = "value-one" + } + hub = google_network_connectivity_hub.basic_hub.id + linked_vpc_network { + exclude_export_ranges = [ + "198.51.100.0/24", + "10.10.0.0/16" + ] + uri = google_compute_network.network.self_link + } +} +``` ## Example Usage - router_appliance ```hcl @@ -130,6 +163,10 @@ The `instances` block supports: (Optional) The URIs of linked Router appliance resources +* `linked_vpc_network` - + (Optional) + VPC network that is associated with the spoke. + * `linked_vpn_tunnels` - (Optional) The URIs of linked VPN tunnel resources @@ -160,6 +197,16 @@ The `linked_router_appliance_instances` block supports: (Required) A value that controls whether site-to-site data transfer is enabled for these resources. Note that data transfer is available only in supported locations. +The `linked_vpc_network` block supports: + +* `exclude_export_ranges` - + (Optional) + IP ranges encompassing the subnets to be excluded from peering. + +* `uri` - + (Required) + The URI of the VPC network resource. + The `linked_vpn_tunnels` block supports: * `site_to_site_data_transfer` -