mirror of https://github.com/docker/docs.git
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:
commit
11fd9648ac
|
@ -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")
|
||||
}
|
||||
|
||||
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() {
|
||||
u, err := url.Parse(d.SwarmHost)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue