Merge pull request #4204 from rickard-von-essen/aws_spot_instance_if_non_vpc
Fix 'The AssociatePublicIpAddress parameter is only supported for VPC launches.'
This commit is contained in:
commit
2d193df7f6
|
@ -202,20 +202,26 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
|
||||||
InstanceType: &s.InstanceType,
|
InstanceType: &s.InstanceType,
|
||||||
UserData: &userData,
|
UserData: &userData,
|
||||||
IamInstanceProfile: &ec2.IamInstanceProfileSpecification{Name: &s.IamInstanceProfile},
|
IamInstanceProfile: &ec2.IamInstanceProfileSpecification{Name: &s.IamInstanceProfile},
|
||||||
NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{
|
Placement: &ec2.SpotPlacement{
|
||||||
{
|
AvailabilityZone: &availabilityZone,
|
||||||
|
},
|
||||||
|
BlockDeviceMappings: s.BlockDevices.BuildLaunchDevices(),
|
||||||
|
EbsOptimized: &s.EbsOptimized,
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.SubnetId != "" && s.AssociatePublicIpAddress {
|
||||||
|
runOpts.NetworkInterfaces = []*ec2.InstanceNetworkInterfaceSpecification{
|
||||||
|
&ec2.InstanceNetworkInterfaceSpecification{
|
||||||
DeviceIndex: aws.Int64(0),
|
DeviceIndex: aws.Int64(0),
|
||||||
AssociatePublicIpAddress: &s.AssociatePublicIpAddress,
|
AssociatePublicIpAddress: &s.AssociatePublicIpAddress,
|
||||||
SubnetId: &s.SubnetId,
|
SubnetId: &s.SubnetId,
|
||||||
Groups: securityGroupIds,
|
Groups: securityGroupIds,
|
||||||
DeleteOnTermination: aws.Bool(true),
|
DeleteOnTermination: aws.Bool(true),
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
Placement: &ec2.SpotPlacement{
|
} else {
|
||||||
AvailabilityZone: &availabilityZone,
|
runOpts.SubnetId = &s.SubnetId
|
||||||
},
|
runOpts.SecurityGroupIds = securityGroupIds
|
||||||
BlockDeviceMappings: s.BlockDevices.BuildLaunchDevices(),
|
|
||||||
EbsOptimized: &s.EbsOptimized,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyName != "" {
|
if keyName != "" {
|
||||||
|
|
Loading…
Reference in New Issue