mirror of https://github.com/docker/docs.git
Add --amazonec2-private-address-only
Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
This commit is contained in:
parent
c247c7ee9b
commit
d0651d0273
|
@ -739,6 +739,7 @@ Options:
|
|||
- `--amazonec2-subnet-id`: AWS VPC subnet id
|
||||
- `--amazonec2-vpc-id`: **required** Your VPC ID to launch the instance in.
|
||||
- `--amazonec2-zone`: The AWS zone launch the instance in (i.e. one of a,b,c,d,e). Default: `a`
|
||||
- `--amazonec2-private-address-only`: Use the private IP address only
|
||||
|
||||
By default, the Amazon EC2 driver will use a daily image of Ubuntu 14.04 LTS.
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ type Driver struct {
|
|||
keyPath string
|
||||
RequestSpotInstance bool
|
||||
SpotPrice string
|
||||
PrivateIPOnly bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -164,6 +165,10 @@ func GetCreateFlags() []cli.Flag {
|
|||
Usage: "AWS spot instance bid price (in dollar)",
|
||||
Value: "0.50",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "amazonec2-private-address-only",
|
||||
Usage: "Only use a private IP address",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +226,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
|||
d.SwarmDiscovery = flags.String("swarm-discovery")
|
||||
d.SSHUser = flags.String("amazonec2-ssh-user")
|
||||
d.SSHPort = 22
|
||||
d.PrivateIPOnly = flags.Bool("amazonec2-private-address-only")
|
||||
|
||||
if d.AccessKey == "" {
|
||||
return fmt.Errorf("amazonec2 driver requires the --amazonec2-access-key option")
|
||||
|
@ -372,7 +378,7 @@ func (d *Driver) Create() error {
|
|||
return fmt.Errorf("Error get instance: %s", err)
|
||||
}
|
||||
} else {
|
||||
inst, err := d.getClient().RunInstance(d.AMI, d.InstanceType, d.Zone, 1, 1, d.SecurityGroupId, d.KeyName, d.SubnetId, bdm, d.IamInstanceProfile)
|
||||
inst, err := d.getClient().RunInstance(d.AMI, d.InstanceType, d.Zone, 1, 1, d.SecurityGroupId, d.KeyName, d.SubnetId, bdm, d.IamInstanceProfile, d.PrivateIPOnly)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error launching instance: %s", err)
|
||||
}
|
||||
|
@ -427,6 +433,10 @@ func (d *Driver) GetIP() (string, error) {
|
|||
return "", err
|
||||
}
|
||||
|
||||
if d.PrivateIPOnly {
|
||||
return inst.PrivateIpAddress, nil
|
||||
}
|
||||
|
||||
return inst.IpAddress, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ func getDefaultTestDriverFlags() *DriverOptionsMock {
|
|||
"amazonec2-ssh-user": "ubuntu",
|
||||
"amazonec2-request-spot-instance": false,
|
||||
"amazonec2-spot-price": "",
|
||||
"amazonec2-private-address-only": false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ func (e *EC2) awsApiCall(v url.Values) (*http.Response, error) {
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (e *EC2) RunInstance(amiId string, instanceType string, zone string, minCount int, maxCount int, securityGroup string, keyName string, subnetId string, bdm *BlockDeviceMapping, role string) (EC2Instance, error) {
|
||||
func (e *EC2) RunInstance(amiId string, instanceType string, zone string, minCount int, maxCount int, securityGroup string, keyName string, subnetId string, bdm *BlockDeviceMapping, role string, privateIPOnly bool) (EC2Instance, error) {
|
||||
instance := Instance{}
|
||||
v := url.Values{}
|
||||
v.Set("Action", "RunInstances")
|
||||
|
@ -186,7 +186,11 @@ func (e *EC2) RunInstance(amiId string, instanceType string, zone string, minCou
|
|||
v.Set("NetworkInterface.0.DeviceIndex", "0")
|
||||
v.Set("NetworkInterface.0.SecurityGroupId.0", securityGroup)
|
||||
v.Set("NetworkInterface.0.SubnetId", subnetId)
|
||||
if privateIPOnly {
|
||||
v.Set("NetworkInterface.0.AssociatePublicIpAddress", "0")
|
||||
} else {
|
||||
v.Set("NetworkInterface.0.AssociatePublicIpAddress", "1")
|
||||
}
|
||||
|
||||
if len(role) > 0 {
|
||||
v.Set("IamInstanceProfile.Name", role)
|
||||
|
|
Loading…
Reference in New Issue