Skip to content

Commit

Permalink
Merge pull request #15 from gruntwork-io/subnet-type
Browse files Browse the repository at this point in the history
Use custom Subnet struct instead of ec2.Subnet
  • Loading branch information
josh-padnick committed Apr 2, 2016
2 parents bc28ab8 + 6f50f9f commit cf34992
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions aws/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ import (
var VpcIdFilterName = "vpc-id"

type Vpc struct {
Id string // The ID of the VPC
Name string // The name of the VPC
Subnets []ec2.Subnet // A list of subnets in the VPC
Id string // The ID of the VPC
Name string // The name of the VPC
Subnets []Subnet // A list of subnets in the VPC
}

type Subnet struct {
Id string // The ID of the Subnet
AvailabilityZone string // The Availability Zone the subnet is in
}

var IS_DEFAULT_FILTER_NAME = "isDefault"
Expand Down Expand Up @@ -57,8 +62,8 @@ func FindVpcName(vpc *ec2.Vpc) string {
return ""
}

func GetSubnetsForVpc(vpcId string, awsRegion string) ([]ec2.Subnet, error) {
subnets := []ec2.Subnet{}
func GetSubnetsForVpc(vpcId string, awsRegion string) ([]Subnet, error) {
subnets := []Subnet{}

svc := ec2.New(session.New(), aws.NewConfig().WithRegion(awsRegion))

Expand All @@ -68,8 +73,9 @@ func GetSubnetsForVpc(vpcId string, awsRegion string) ([]ec2.Subnet, error) {
return subnets, err
}

for _, subnet := range subnetOutput.Subnets {
subnets = append(subnets, *subnet)
for _, ec2Subnet := range subnetOutput.Subnets {
subnet := Subnet{Id: *ec2Subnet.SubnetId, AvailabilityZone: *ec2Subnet.AvailabilityZone}
subnets = append(subnets, subnet)
}
return subnets, nil
}

0 comments on commit cf34992

Please sign in to comment.