Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service details not yet available in GovCloud. #3514

Merged
merged 2 commits into from
Mar 5, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify backwards compatibility for vpc endpoint service.
h/t @bflad
jmcarp committed Mar 3, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit e683b84db9755366cdefc18cff84c6f23861b984
24 changes: 9 additions & 15 deletions aws/data_source_aws_vpc_endpoint_service.go
Original file line number Diff line number Diff line change
@@ -65,7 +65,6 @@ func dataSourceAwsVpcEndpointService() *schema.Resource {

func dataSourceAwsVpcEndpointServiceRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn
isGovCloud := meta.(*AWSClient).IsGovCloud()

var serviceName string
if v, ok := d.GetOk("service_name"); ok {
@@ -87,27 +86,22 @@ func dataSourceAwsVpcEndpointServiceRead(d *schema.ResourceData, meta interface{
return fmt.Errorf("Error fetching VPC Endpoint Services: %s", err)
}

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

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 isGovCloud && resp.ServiceDetails == nil {
if resp == nil || len(resp.ServiceNames) == 0 {
return fmt.Errorf("no matching VPC Endpoint Service found")
}
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")
}
if len(resp.ServiceDetails) == 0 {
d.SetId(strconv.Itoa(hashcode.String(*resp.ServiceNames[0])))
d.Set("service_name", resp.ServiceNames[0])
return nil
}

if resp == nil || len(resp.ServiceDetails) == 0 {
return fmt.Errorf("no matching VPC Endpoint Service found")
}
if len(resp.ServiceDetails) > 1 {
return fmt.Errorf("multiple VPC Endpoint Services matched; use additional constraints to reduce matches to a single VPC Endpoint Service")
}

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