diff --git a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway.go b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway.go index 51ce77cd2a..8d9894f5fb 100644 --- a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway.go +++ b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway.go @@ -43,6 +43,14 @@ func DataSourceIBMISEndpointGateway() *schema.Resource { Computed: true, Description: "Endpoint gateway created date and time", }, + isVirtualEndpointGatewayServiceEndpoints: { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "The fully qualified domain names for the target service. A fully qualified domain name for the target service", + }, isVirtualEndpointGatewayHealthState: { Type: schema.TypeString, Computed: true, @@ -165,6 +173,9 @@ func dataSourceIBMISEndpointGatewayRead( d.Set(isVirtualEndpointGatewayTarget, flattenEndpointGatewayTarget( result.Target.(*vpcv1.EndpointGatewayTarget))) d.Set(isVirtualEndpointGatewayVpcID, result.VPC.ID) + if len(result.ServiceEndpoints) > 0 { + d.Set(isVirtualEndpointGatewayServiceEndpoints, result.ServiceEndpoints) + } tags, err := flex.GetGlobalTagsUsingCRN(meta, *result.CRN, "", isUserTagType) if err != nil { log.Printf( diff --git a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway_test.go b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway_test.go index adf957913e..3bf8afd2aa 100644 --- a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway_test.go +++ b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway_test.go @@ -41,3 +41,35 @@ func testAccCheckIBMISVirtualEndpointGatewayDataSourceConfig(vpcname1, subnetnam name = ibm_is_virtual_endpoint_gateway.endpoint_gateway.name }`) } + +// service endpoints +func TestAccIBMISVirtualEndpointGatewayDataSource_service_endpoints(t *testing.T) { + resName := "data.ibm_is_virtual_endpoint_gateway.data_test" + vpcname1 := fmt.Sprintf("tfvpngw-vpc-%d", acctest.RandIntRange(10, 100)) + subnetname1 := fmt.Sprintf("tfvpngw-subnet-%d", acctest.RandIntRange(10, 100)) + name1 := fmt.Sprintf("tfvpngw-createname-%d", acctest.RandIntRange(10, 100)) + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckisVirtualEndpointGatewayDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMISVirtualEndpointGatewayDataSourceServiceEndpointsConfig(vpcname1, subnetname1, name1), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + resName, "name", name1), + resource.TestCheckResourceAttrSet( + resName, "service_endpoints.#"), + ), + }, + }, + }) +} + +func testAccCheckIBMISVirtualEndpointGatewayDataSourceServiceEndpointsConfig(vpcname1, subnetname1, name1 string) string { + // status filter defaults to empty + return testAccCheckisVirtualEndpointGatewayConfigServiceEndpoints(vpcname1, subnetname1, name1) + fmt.Sprintf(` + data "ibm_is_virtual_endpoint_gateway" "data_test" { + name = ibm_is_virtual_endpoint_gateway.endpoint_gateway.name + }`) +} diff --git a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go index 4243a134a0..2f24c7a017 100644 --- a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go +++ b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go @@ -73,6 +73,14 @@ func DataSourceIBMISEndpointGateways() *schema.Resource { Computed: true, Description: "Endpoint gateway health state", }, + isVirtualEndpointGatewayServiceEndpoints: { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "The fully qualified domain names for the target service. A fully qualified domain name for the target service", + }, isVirtualEndpointGatewayLifecycleState: { Type: schema.TypeString, Computed: true, @@ -209,6 +217,9 @@ func dataSourceIBMISEndpointGatewaysRead(d *schema.ResourceData, meta interface{ endpointGatewayOutput[isVirtualEndpointGatewaySecurityGroups] = flattenDataSourceSecurityGroups(endpointGateway.SecurityGroups) } + if len(endpointGateway.ServiceEndpoints) > 0 { + endpointGatewayOutput[isVirtualEndpointGatewayServiceEndpoints] = endpointGateway.ServiceEndpoints + } endpointGatewayOutput[isVirtualEndpointGatewayIPs] = flattenDataSourceIPs(endpointGateway.Ips) tags, err := flex.GetGlobalTagsUsingCRN(meta, *endpointGateway.CRN, "", isUserTagType) diff --git a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways_test.go b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways_test.go index 04de4137d2..712401fdf0 100644 --- a/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways_test.go +++ b/ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways_test.go @@ -38,6 +38,38 @@ func testAccCheckIBMISVirtualEndpointGatewaysDataSourceConfig(vpcname1, subnetna // status filter defaults to empty return testAccCheckisVirtualEndpointGatewayConfigBasic(vpcname1, subnetname1, name1) + fmt.Sprintf(` data "ibm_is_virtual_endpoint_gateways" "test1" { - + depends_on = [ibm_is_virtual_endpoint_gateway.endpoint_gateway] + }`) +} + +// service endpoints + +func TestAccIBMISVirtualEndpointGatewaysDataSource_service_endpoints(t *testing.T) { + resName := "data.ibm_is_virtual_endpoint_gateways.test1" + vpcname1 := fmt.Sprintf("tfvpngw-vpc-%d", acctest.RandIntRange(10, 100)) + subnetname1 := fmt.Sprintf("tfvpngw-subnet-%d", acctest.RandIntRange(10, 100)) + name1 := fmt.Sprintf("tfvpngw-createname-%d", acctest.RandIntRange(10, 100)) + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMISVirtualEndpointGatewaysDataSourceServiceEndpointsConfig(vpcname1, subnetname1, name1), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet( + resName, "virtual_endpoint_gateways.0.name"), + resource.TestCheckResourceAttrSet( + resName, "virtual_endpoint_gateways.0.service_endpoints.#"), + ), + }, + }, + }) +} + +func testAccCheckIBMISVirtualEndpointGatewaysDataSourceServiceEndpointsConfig(vpcname1, subnetname1, name1 string) string { + // status filter defaults to empty + return testAccCheckisVirtualEndpointGatewayConfigServiceEndpoints(vpcname1, subnetname1, name1) + fmt.Sprintf(` + data "ibm_is_virtual_endpoint_gateways" "test1" { + depends_on = [ibm_is_virtual_endpoint_gateway.endpoint_gateway] }`) } diff --git a/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway.go b/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway.go index f9ae62bf5e..132b629e86 100644 --- a/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway.go +++ b/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway.go @@ -40,6 +40,7 @@ const ( isVirtualEndpointGatewayVpcID = "vpc" isVirtualEndpointGatewayTags = "tags" isVirtualEndpointGatewaySecurityGroups = "security_groups" + isVirtualEndpointGatewayServiceEndpoints = "service_endpoints" isVirtualEndpointGatewayAccessTags = "access_tags" ) @@ -102,6 +103,14 @@ func ResourceIBMISEndpointGateway() *schema.Resource { Computed: true, Description: "Endpoint gateway created date and time", }, + isVirtualEndpointGatewayServiceEndpoints: { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Description: "The fully qualified domain names for the target service. A fully qualified domain name for the target service", + }, isVirtualEndpointGatewayHealthState: { Type: schema.TypeString, Computed: true, @@ -482,6 +491,9 @@ func resourceIBMisVirtualEndpointGatewayRead(d *schema.ResourceData, meta interf d.Set(isVirtualEndpointGatewayResourceGroupID, endpointGateway.ResourceGroup.ID) d.Set(isVirtualEndpointGatewayTarget, flattenEndpointGatewayTarget(endpointGateway.Target.(*vpcv1.EndpointGatewayTarget))) + if len(endpointGateway.ServiceEndpoints) > 0 { + d.Set(isVirtualEndpointGatewayServiceEndpoints, endpointGateway.ServiceEndpoints) + } d.Set(isVirtualEndpointGatewayVpcID, endpointGateway.VPC.ID) if endpointGateway.SecurityGroups != nil { d.Set(isVirtualEndpointGatewaySecurityGroups, flattenDataSourceSecurityGroups(endpointGateway.SecurityGroups)) diff --git a/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway_test.go b/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway_test.go index 17c425dc3b..d306d8b4db 100644 --- a/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway_test.go +++ b/ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway_test.go @@ -272,8 +272,8 @@ func testAccCheckisVirtualEndpointGatewayConfigFullySpecified(vpcname1, subnetna resource "ibm_is_virtual_endpoint_gateway" "endpoint_gateway" { name = "%[5]s" target { - name = "ibm-dns-server2" - resource_type = "provider_infrastructure_service" + name = "ibm-dns-server2" + resource_type = "provider_infrastructure_service" } vpc = ibm_is_vpc.testacc_vpc.id ips { @@ -315,3 +315,54 @@ func testAccCheckisVirtualEndpointGatewayConfigBasicSecurityGroups(vpcname1, sub security_groups = [ibm_is_security_group.testacc_security_group.id] }`, vpcname1, subnetname1, acc.ISZoneName, acc.ISCIDR, sgname1, name1) } + +// for service endpoints +func testAccCheckisVirtualEndpointGatewayConfigServiceEndpoints(vpcname1, subnetname1, name1 string) string { + return fmt.Sprintf(` + data "ibm_resource_group" "test_acc" { + is_default=true + } + resource "ibm_is_vpc" "testacc_vpc" { + name = "%[1]s" + resource_group = data.ibm_resource_group.test_acc.id + } + resource "ibm_is_subnet" "testacc_subnet" { + name = "%[2]s" + vpc = ibm_is_vpc.testacc_vpc.id + zone = "%[3]s" + ipv4_cidr_block = "%[4]s" + resource_group = data.ibm_resource_group.test_acc.id + } + resource "ibm_is_virtual_endpoint_gateway" "endpoint_gateway" { + name = "%[5]s" + target { + name = "ibm-ntp-server" + resource_type = "provider_infrastructure_service" + } + vpc = ibm_is_vpc.testacc_vpc.id + resource_group = data.ibm_resource_group.test_acc.id + }`, vpcname1, subnetname1, acc.ISZoneName, acc.ISCIDR, name1) +} + +func TestAccIBMISVirtualEndpointGateway_ServiceEndpoints(t *testing.T) { + var endpointGateway string + vpcname1 := fmt.Sprintf("tfvpngw-vpc-%d", acctest.RandIntRange(10, 100)) + subnetname1 := fmt.Sprintf("tfvpngw-subnet-%d", acctest.RandIntRange(10, 100)) + name1 := fmt.Sprintf("tfvpngw-createname-%d", acctest.RandIntRange(10, 100)) + name := "ibm_is_virtual_endpoint_gateway.endpoint_gateway" + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckisVirtualEndpointGatewayConfigServiceEndpoints(vpcname1, subnetname1, name1), + Check: resource.ComposeTestCheckFunc( + testAccCheckisVirtualEndpointGatewayExists(name, &endpointGateway), + resource.TestCheckResourceAttr(name, "name", name1), + resource.TestCheckResourceAttrSet( + name, "service_endpoints.#"), + ), + }, + }, + }) +} diff --git a/website/docs/d/is_virtual_endpoint_gateway.html.markdown b/website/docs/d/is_virtual_endpoint_gateway.html.markdown index 94370780f3..89ebe8761f 100644 --- a/website/docs/d/is_virtual_endpoint_gateway.html.markdown +++ b/website/docs/d/is_virtual_endpoint_gateway.html.markdown @@ -56,5 +56,6 @@ In addition to the argument reference list, you can access the following attribu - `resource_type` - (String) The resource type of the subnet reserved IP. - `vpc` - (String) The VPC ID. - `security_groups` (List) - The security groups to use for this endpoint gateway. +- `service_endpoints`- (Array of Strings) The fully qualified domain names for the target service. A fully qualified domain name for the target service diff --git a/website/docs/d/is_virtual_endpoint_gateways.html.markdown b/website/docs/d/is_virtual_endpoint_gateways.html.markdown index e874e23053..f1b0e35814 100644 --- a/website/docs/d/is_virtual_endpoint_gateways.html.markdown +++ b/website/docs/d/is_virtual_endpoint_gateways.html.markdown @@ -62,3 +62,4 @@ In addition to the argument reference list, you can access the following attribu - `resource_type` - (String) The endpoint gateway target resource type. - `vpc` - (String) The VPC ID. - `security_groups` (List) - The security groups to use for this endpoint gateway. + - `service_endpoints`- (Array of Strings) The fully qualified domain names for the target service. A fully qualified domain name for the target service \ No newline at end of file diff --git a/website/docs/r/is_virtual_endpoint_gateway.html.markdown b/website/docs/r/is_virtual_endpoint_gateway.html.markdown index dc98c5d713..6ba9a98f9b 100644 --- a/website/docs/r/is_virtual_endpoint_gateway.html.markdown +++ b/website/docs/r/is_virtual_endpoint_gateway.html.markdown @@ -133,6 +133,7 @@ In addition to all argument reference list, you can access the following attribu - `lifecycle_state` - (String) The lifecycle state of the endpoint gateway. - `resource_type` - (String) The endpoint gateway resource type. +- `service_endpoints`- (Array of Strings) The fully qualified domain names for the target service. A fully qualified domain name for the target service ## Import The `ibm_is_virtual_endpoint_gateway` resource can be imported by using virtual endpoint gateway ID.