Skip to content

Commit

Permalink
provider/aws Return service CIDR blocks from aws_vpc_endpoint resourc…
Browse files Browse the repository at this point in the history
…e. (#10254)
  • Loading branch information
ewbankkit authored and stack72 committed Nov 21, 2016
1 parent 6245899 commit dc91cf0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builtin/providers/aws/resource_aws_vpc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func resourceAwsVpcEndpoint() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"cidr_blocks": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}
Expand Down Expand Up @@ -155,7 +160,9 @@ func resourceAwsVPCEndpointRead(d *schema.ResourceData, meta interface{}) error
if err := d.Set("route_table_ids", aws.StringValueSlice(vpce.RouteTableIds)); err != nil {
return err
}
d.Set("prefix_list_id", prefixListsOutput.PrefixLists[0].PrefixListId)
pl := prefixListsOutput.PrefixLists[0]
d.Set("prefix_list_id", pl.PrefixListId)
d.Set("cidr_blocks", aws.StringValueSlice(pl.Cidrs))

return nil
}
Expand Down
13 changes: 13 additions & 0 deletions builtin/providers/aws/resource_aws_vpc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -189,6 +190,18 @@ func testAccCheckVpcEndpointPrefixListAvailable(n string) resource.TestCheckFunc
return fmt.Errorf("Prefix list ID does not appear to be a valid value: '%s'", prefixListID)
}

var (
cidrBlockSize int
err error
)

if cidrBlockSize, err = strconv.Atoi(rs.Primary.Attributes["cidr_blocks.#"]); err != nil {
return err
}
if cidrBlockSize < 1 {
return fmt.Errorf("cidr_blocks seem suspiciously low: %d", cidrBlockSize)
}

return nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The following attributes are exported:

* `id` - The ID of the VPC endpoint.
* `prefix_list_id` - The prefix list ID of the exposed service.
* `cidr_blocks` - The list of CIDR blocks for the exposed service.


## Import
Expand Down

0 comments on commit dc91cf0

Please sign in to comment.