Merge pull request #1639 from feelobot/validate-ec2-vpc-id-matches-subnet-id

Use SDK to Validate VpcID with SubnetId
This commit is contained in:
Olivier Gambier 2015-10-22 09:52:18 -07:00
commit 11fd9648ac
1 changed files with 18 additions and 0 deletions

View File

@ -231,6 +231,24 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return fmt.Errorf("amazonec2 driver requires either the --amazonec2-subnet-id or --amazonec2-vpc-id option") return fmt.Errorf("amazonec2 driver requires either the --amazonec2-subnet-id or --amazonec2-vpc-id option")
} }
if d.SubnetId != "" && d.VpcId != "" {
filters := []amz.Filter{
{
Name: "subnet-id",
Value: d.SubnetId,
},
}
subnets, err := d.getClient().GetSubnets(filters)
if err != nil {
return err
}
if subnets[0].VpcId != d.VpcId {
return fmt.Errorf("SubnetId: %s does not belong to VpcId: %s", d.SubnetId, d.VpcId)
}
}
if d.isSwarmMaster() { if d.isSwarmMaster() {
u, err := url.Parse(d.SwarmHost) u, err := url.Parse(d.SwarmHost)
if err != nil { if err != nil {