|
|
|
|
@ -93,28 +93,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
}
|
|
|
|
|
ec2conn := ec2.New(session)
|
|
|
|
|
|
|
|
|
|
// TODO Translate this into VpcFilter/SubnetFilter and move the describe into apropriate step.
|
|
|
|
|
// If the subnet is specified but not the VpcId or AZ, try to determine them automatically
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If subnet => vpc, az
|
|
|
|
|
*/
|
|
|
|
|
if b.config.SubnetId != "" && (b.config.AvailabilityZone == "" || b.config.VpcId == "") {
|
|
|
|
|
log.Printf("[INFO] Finding AZ and VpcId for the given subnet '%s'", b.config.SubnetId)
|
|
|
|
|
resp, err := ec2conn.DescribeSubnets(&ec2.DescribeSubnetsInput{SubnetIds: []*string{&b.config.SubnetId}})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
if b.config.AvailabilityZone == "" {
|
|
|
|
|
b.config.AvailabilityZone = *resp.Subnets[0].AvailabilityZone
|
|
|
|
|
log.Printf("[INFO] AvailabilityZone found: '%s'", b.config.AvailabilityZone)
|
|
|
|
|
}
|
|
|
|
|
if b.config.VpcId == "" {
|
|
|
|
|
b.config.VpcId = *resp.Subnets[0].VpcId
|
|
|
|
|
log.Printf("[INFO] VpcId found: '%s'", b.config.VpcId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup the state bag and initial state for the steps
|
|
|
|
|
state := new(multistep.BasicStateBag)
|
|
|
|
|
state.Put("config", b.config)
|
|
|
|
|
@ -128,7 +106,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
if b.config.IsSpotInstance() {
|
|
|
|
|
instanceStep = &awscommon.StepRunSpotInstance{
|
|
|
|
|
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
|
|
|
|
AvailabilityZone: b.config.AvailabilityZone,
|
|
|
|
|
BlockDevices: b.config.BlockDevices,
|
|
|
|
|
Ctx: b.config.ctx,
|
|
|
|
|
Debug: b.config.PackerDebug,
|
|
|
|
|
@ -141,7 +118,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
SpotPrice: b.config.SpotPrice,
|
|
|
|
|
SpotPriceProduct: b.config.SpotPriceAutoProduct,
|
|
|
|
|
SpotTags: b.config.SpotTags,
|
|
|
|
|
SubnetId: b.config.SubnetId,
|
|
|
|
|
Tags: b.config.RunTags,
|
|
|
|
|
UserData: b.config.UserData,
|
|
|
|
|
UserDataFile: b.config.UserDataFile,
|
|
|
|
|
@ -150,7 +126,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
} else {
|
|
|
|
|
instanceStep = &awscommon.StepRunSourceInstance{
|
|
|
|
|
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
|
|
|
|
AvailabilityZone: b.config.AvailabilityZone,
|
|
|
|
|
BlockDevices: b.config.BlockDevices,
|
|
|
|
|
Ctx: b.config.ctx,
|
|
|
|
|
Debug: b.config.PackerDebug,
|
|
|
|
|
@ -162,7 +137,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
InstanceType: b.config.InstanceType,
|
|
|
|
|
IsRestricted: b.config.IsChinaCloud() || b.config.IsGovCloud(),
|
|
|
|
|
SourceAMI: b.config.SourceAmi,
|
|
|
|
|
SubnetId: b.config.SubnetId,
|
|
|
|
|
Tags: b.config.RunTags,
|
|
|
|
|
UserData: b.config.UserData,
|
|
|
|
|
UserDataFile: b.config.UserDataFile,
|
|
|
|
|
@ -183,11 +157,13 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
AmiFilters: b.config.SourceAmiFilter,
|
|
|
|
|
},
|
|
|
|
|
&awscommon.StepNetworkInfo{
|
|
|
|
|
VpcId: b.config.VpcId,
|
|
|
|
|
VpcFilter: b.config.VpcFilter,
|
|
|
|
|
SubnetId: b.config.SubnetId,
|
|
|
|
|
SubnetFilter: b.config.SubnetFilter,
|
|
|
|
|
AvailabilityZone: b.config.AvailabilityZone,
|
|
|
|
|
VpcId: b.config.VpcId,
|
|
|
|
|
VpcFilter: b.config.VpcFilter,
|
|
|
|
|
SecurityGroupIds: b.config.SecurityGroupIds,
|
|
|
|
|
SecurityGroupFilter: b.config.SecurityGroupFilter,
|
|
|
|
|
SubnetId: b.config.SubnetId,
|
|
|
|
|
SubnetFilter: b.config.SubnetFilter,
|
|
|
|
|
AvailabilityZone: b.config.AvailabilityZone,
|
|
|
|
|
},
|
|
|
|
|
&awscommon.StepKeyPair{
|
|
|
|
|
Debug: b.config.PackerDebug,
|
|
|
|
|
@ -198,11 +174,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|
|
|
|
PrivateKeyFile: b.config.RunConfig.Comm.SSHPrivateKey,
|
|
|
|
|
},
|
|
|
|
|
&awscommon.StepSecurityGroup{
|
|
|
|
|
// TODO remove
|
|
|
|
|
SecurityGroupIds: b.config.SecurityGroupIds,
|
|
|
|
|
CommConfig: &b.config.RunConfig.Comm,
|
|
|
|
|
// TODO remove
|
|
|
|
|
VpcId: b.config.VpcId,
|
|
|
|
|
SecurityGroupFilter: b.config.SecurityGroupFilter,
|
|
|
|
|
SecurityGroupIds: b.config.SecurityGroupIds,
|
|
|
|
|
CommConfig: &b.config.RunConfig.Comm,
|
|
|
|
|
TemporarySGSourceCidr: b.config.TemporarySGSourceCidr,
|
|
|
|
|
},
|
|
|
|
|
&awscommon.StepCleanupVolumes{
|
|
|
|
|
|