|
|
|
|
@ -43,6 +43,10 @@ func resourceAwsVpcEndpoint() *schema.Resource {
|
|
|
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
|
|
|
Set: schema.HashString,
|
|
|
|
|
},
|
|
|
|
|
"prefix_list_id": &schema.Schema{
|
|
|
|
|
Type: schema.TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -101,12 +105,36 @@ func resourceAwsVPCEndpointRead(d *schema.ResourceData, meta interface{}) error
|
|
|
|
|
|
|
|
|
|
vpce := output.VpcEndpoints[0]
|
|
|
|
|
|
|
|
|
|
// A VPC Endpoint is associated with exactly one prefix list name (also called Service Name).
|
|
|
|
|
// The prefix list ID can be used in security groups, so retrieve it to support that capability.
|
|
|
|
|
prefixListServiceName := *vpce.ServiceName
|
|
|
|
|
prefixListInput := &ec2.DescribePrefixListsInput{
|
|
|
|
|
Filters: []*ec2.Filter{
|
|
|
|
|
{Name: aws.String("prefix-list-name"), Values: []*string{aws.String(prefixListServiceName)}},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Printf("[DEBUG] Reading VPC Endpoint prefix list: %s", prefixListServiceName)
|
|
|
|
|
prefixListsOutput, err := conn.DescribePrefixLists(prefixListInput)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
_, ok := err.(awserr.Error)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("Error reading VPC Endpoint prefix list: %s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(prefixListsOutput.PrefixLists) != 1 {
|
|
|
|
|
return fmt.Errorf("There are multiple prefix lists associated with the service name '%s'. Unexpected", prefixListServiceName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d.Set("vpc_id", vpce.VpcId)
|
|
|
|
|
d.Set("policy", normalizeJson(*vpce.PolicyDocument))
|
|
|
|
|
d.Set("service_name", vpce.ServiceName)
|
|
|
|
|
if err := d.Set("route_table_ids", aws.StringValueSlice(vpce.RouteTableIds)); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
d.Set("prefix_list_id", prefixListsOutput.PrefixLists[0].PrefixListId)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|