aws spot instances: add block_duration_minutes option (#6638)
* Add block_duration_minutes option * int64 cannot be nil * Update doc * Fix formating
This commit is contained in:
parent
87bf7e780c
commit
26aab49aaf
|
@ -34,6 +34,7 @@ func (d *AmiFilterOptions) NoOwner() bool {
|
|||
type RunConfig struct {
|
||||
AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address"`
|
||||
AvailabilityZone string `mapstructure:"availability_zone"`
|
||||
BlockDurationMinutes int64 `mapstructure:"block_duration_minutes"`
|
||||
DisableStopInstance bool `mapstructure:"disable_stop_instance"`
|
||||
EbsOptimized bool `mapstructure:"ebs_optimized"`
|
||||
EnableT2Unlimited bool `mapstructure:"enable_t2_unlimited"`
|
||||
|
@ -111,6 +112,11 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
errs = append(errs, fmt.Errorf("An instance_type must be specified"))
|
||||
}
|
||||
|
||||
if c.BlockDurationMinutes%60 != 0 {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
"block_duration_minutes must be multiple of 60"))
|
||||
}
|
||||
|
||||
if c.SpotPrice == "auto" {
|
||||
if c.SpotPriceAutoProduct == "" {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
|
|
|
@ -24,6 +24,7 @@ type StepRunSpotInstance struct {
|
|||
AssociatePublicIpAddress bool
|
||||
AvailabilityZone string
|
||||
BlockDevices BlockDevices
|
||||
BlockDurationMinutes int64
|
||||
Debug bool
|
||||
Comm *communicator.Config
|
||||
EbsOptimized bool
|
||||
|
@ -187,8 +188,9 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||
}
|
||||
|
||||
runSpotResp, err := ec2conn.RequestSpotInstances(&ec2.RequestSpotInstancesInput{
|
||||
SpotPrice: &spotPrice,
|
||||
LaunchSpecification: runOpts,
|
||||
BlockDurationMinutes: &s.BlockDurationMinutes,
|
||||
LaunchSpecification: runOpts,
|
||||
SpotPrice: &spotPrice,
|
||||
})
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error launching source spot instance: %s", err)
|
||||
|
|
|
@ -126,6 +126,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
||||
AvailabilityZone: b.config.AvailabilityZone,
|
||||
BlockDevices: b.config.BlockDevices,
|
||||
BlockDurationMinutes: b.config.BlockDurationMinutes,
|
||||
Ctx: b.config.ctx,
|
||||
Debug: b.config.PackerDebug,
|
||||
EbsOptimized: b.config.EbsOptimized,
|
||||
|
|
|
@ -140,6 +140,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
||||
AvailabilityZone: b.config.AvailabilityZone,
|
||||
BlockDevices: b.config.BlockDevices,
|
||||
BlockDurationMinutes: b.config.BlockDurationMinutes,
|
||||
Ctx: b.config.ctx,
|
||||
Debug: b.config.PackerDebug,
|
||||
EbsOptimized: b.config.EbsOptimized,
|
||||
|
|
|
@ -124,6 +124,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
||||
AvailabilityZone: b.config.AvailabilityZone,
|
||||
BlockDevices: b.config.launchBlockDevices,
|
||||
BlockDurationMinutes: b.config.BlockDurationMinutes,
|
||||
Ctx: b.config.ctx,
|
||||
Debug: b.config.PackerDebug,
|
||||
EbsOptimized: b.config.EbsOptimized,
|
||||
|
|
|
@ -210,6 +210,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
||||
AvailabilityZone: b.config.AvailabilityZone,
|
||||
BlockDevices: b.config.BlockDevices,
|
||||
BlockDurationMinutes: b.config.BlockDurationMinutes,
|
||||
Ctx: b.config.ctx,
|
||||
Debug: b.config.PackerDebug,
|
||||
EbsOptimized: b.config.EbsOptimized,
|
||||
|
|
|
@ -142,6 +142,11 @@ builder.
|
|||
- `availability_zone` (string) - Destination availability zone to launch
|
||||
instance in. Leave this empty to allow Amazon to auto-assign.
|
||||
|
||||
- `block_duration_minutes` (int64) - Requires `spot_price` to
|
||||
be set. The required duration for the Spot Instances (also known as Spot blocks).
|
||||
This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360).
|
||||
You can't specify an Availability Zone group or a launch group if you specify a duration.
|
||||
|
||||
- `custom_endpoint_ec2` (string) - This option is useful if you use a cloud
|
||||
provider whose API is compatible with aws EC2. Specify another endpoint
|
||||
like this `https://ec2.custom.endpoint.com`.
|
||||
|
|
|
@ -135,6 +135,11 @@ builder.
|
|||
- `availability_zone` (string) - Destination availability zone to launch
|
||||
instance in. Leave this empty to allow Amazon to auto-assign.
|
||||
|
||||
- `block_duration_minutes` (int64) - Requires `spot_price` to
|
||||
be set. The required duration for the Spot Instances (also known as Spot blocks).
|
||||
This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360).
|
||||
You can't specify an Availability Zone group or a launch group if you specify a duration.
|
||||
|
||||
- `custom_endpoint_ec2` (string) - This option is useful if you use a cloud
|
||||
provider whose API is compatible with aws EC2. Specify another endpoint
|
||||
like this `https://ec2.custom.endpoint.com`.
|
||||
|
|
|
@ -107,6 +107,11 @@ builder.
|
|||
- `availability_zone` (string) - Destination availability zone to launch
|
||||
instance in. Leave this empty to allow Amazon to auto-assign.
|
||||
|
||||
- `block_duration_minutes` (int64) - Requires `spot_price` to
|
||||
be set. The required duration for the Spot Instances (also known as Spot blocks).
|
||||
This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360).
|
||||
You can't specify an Availability Zone group or a launch group if you specify a duration.
|
||||
|
||||
- `custom_endpoint_ec2` (string) - This option is useful if you use a cloud
|
||||
provider whose API is compatible with aws EC2. Specify another endpoint
|
||||
like this `https://ec2.custom.endpoint.com`.
|
||||
|
|
|
@ -164,6 +164,11 @@ builder.
|
|||
- `availability_zone` (string) - Destination availability zone to launch
|
||||
instance in. Leave this empty to allow Amazon to auto-assign.
|
||||
|
||||
- `block_duration_minutes` (int64) - Requires `spot_price` to
|
||||
be set. The required duration for the Spot Instances (also known as Spot blocks).
|
||||
This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360).
|
||||
You can't specify an Availability Zone group or a launch group if you specify a duration.
|
||||
|
||||
- `bundle_destination` (string) - The directory on the running instance where
|
||||
the bundled AMI will be saved prior to uploading. By default this is `/tmp`.
|
||||
This directory must exist and be writable.
|
||||
|
|
Loading…
Reference in New Issue