Skip to content

Commit

Permalink
Merge pull request #3514 from jmcarp/govcloud-vpc-endpoint-service
Browse files Browse the repository at this point in the history
Service details not yet available in GovCloud.
  • Loading branch information
bflad authored Mar 5, 2018
2 parents 17b7168 + e683b84 commit 835c0b1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions aws/data_source_aws_vpc_endpoint_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ func dataSourceAwsVpcEndpointServiceRead(d *schema.ResourceData, meta interface{
if err != nil {
return fmt.Errorf("Error fetching VPC Endpoint Services: %s", err)
}
if resp == nil || len(resp.ServiceDetails) == 0 {

if resp == nil || len(resp.ServiceNames) == 0 {
return fmt.Errorf("no matching VPC Endpoint Service found")
}
if len(resp.ServiceDetails) > 1 {

if len(resp.ServiceNames) > 1 {
return fmt.Errorf("multiple VPC Endpoint Services matched; use additional constraints to reduce matches to a single VPC Endpoint Service")
}

// Note: AWS Commercial now returns a response with `ServiceNames` and
// `ServiceDetails`, but GovCloud responses only include `ServiceNames`
if len(resp.ServiceDetails) == 0 {
d.SetId(strconv.Itoa(hashcode.String(*resp.ServiceNames[0])))
d.Set("service_name", resp.ServiceNames[0])
return nil
}

sd := resp.ServiceDetails[0]
serviceName = aws.StringValue(sd.ServiceName)
d.SetId(strconv.Itoa(hashcode.String(serviceName)))
Expand Down

0 comments on commit 835c0b1

Please sign in to comment.