Added aws shutdown_behavior to the changelog

This commit is contained in:
Chris Bednarski 2016-06-14 14:34:01 -07:00
parent f361e1d894
commit ab9621ab7d
2 changed files with 22 additions and 20 deletions

View File

@ -15,6 +15,7 @@ IMPROVEMENTS:
* builder/amazon: Added `disable_stop_instance` option to prevent automatic * builder/amazon: Added `disable_stop_instance` option to prevent automatic
shutdown when the build is complete [GH-3352] shutdown when the build is complete [GH-3352]
* builder/amazon: Added `skip_region_validation` option to allow newer or custom AWS regions [GH-3598] * builder/amazon: Added `skip_region_validation` option to allow newer or custom AWS regions [GH-3598]
* builder/amazon: Added `shutdown_behavior` option to support `stop` or `terminate` at the end of the build [GH-3556]
* builder/azure: Now pre-validates `capture_container_name` and * builder/azure: Now pre-validates `capture_container_name` and
`capture_name_prefix` [GH-3537] `capture_name_prefix` [GH-3537]
* builder/azure: Support for custom images [GH-3575] * builder/azure: Support for custom images [GH-3575]

View File

@ -4,35 +4,37 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"time"
"regexp" "regexp"
"time"
"github.com/mitchellh/packer/common/uuid" "github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/helper/communicator" "github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/template/interpolate" "github.com/mitchellh/packer/template/interpolate"
) )
var reShutdownBehavior = regexp.MustCompile("^(stop|terminate)$")
// RunConfig contains configuration for running an instance from a source // RunConfig contains configuration for running an instance from a source
// AMI and details on how to access that launched image. // AMI and details on how to access that launched image.
type RunConfig struct { type RunConfig struct {
AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address"` AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address"`
AvailabilityZone string `mapstructure:"availability_zone"` AvailabilityZone string `mapstructure:"availability_zone"`
EbsOptimized bool `mapstructure:"ebs_optimized"` EbsOptimized bool `mapstructure:"ebs_optimized"`
IamInstanceProfile string `mapstructure:"iam_instance_profile"` IamInstanceProfile string `mapstructure:"iam_instance_profile"`
InstanceType string `mapstructure:"instance_type"` InstanceType string `mapstructure:"instance_type"`
RunTags map[string]string `mapstructure:"run_tags"` RunTags map[string]string `mapstructure:"run_tags"`
SourceAmi string `mapstructure:"source_ami"` SourceAmi string `mapstructure:"source_ami"`
SpotPrice string `mapstructure:"spot_price"` SpotPrice string `mapstructure:"spot_price"`
SpotPriceAutoProduct string `mapstructure:"spot_price_auto_product"` SpotPriceAutoProduct string `mapstructure:"spot_price_auto_product"`
DisableStopInstance bool `mapstructure:"disable_stop_instance"` DisableStopInstance bool `mapstructure:"disable_stop_instance"`
SecurityGroupId string `mapstructure:"security_group_id"` SecurityGroupId string `mapstructure:"security_group_id"`
SecurityGroupIds []string `mapstructure:"security_group_ids"` SecurityGroupIds []string `mapstructure:"security_group_ids"`
SubnetId string `mapstructure:"subnet_id"` SubnetId string `mapstructure:"subnet_id"`
TemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"` TemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"`
UserData string `mapstructure:"user_data"` UserData string `mapstructure:"user_data"`
UserDataFile string `mapstructure:"user_data_file"` UserDataFile string `mapstructure:"user_data_file"`
WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout"` WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout"`
VpcId string `mapstructure:"vpc_id"` VpcId string `mapstructure:"vpc_id"`
InstanceInitiatedShutdownBehavior string `mapstructure:"shutdown_behaviour"` InstanceInitiatedShutdownBehavior string `mapstructure:"shutdown_behaviour"`
// Communicator settings // Communicator settings
@ -86,7 +88,6 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
} }
} }
var reShutdownBehavior = regexp.MustCompile("(stop|terminate)")
if c.InstanceInitiatedShutdownBehavior == "" { if c.InstanceInitiatedShutdownBehavior == "" {
c.InstanceInitiatedShutdownBehavior = "stop" c.InstanceInitiatedShutdownBehavior = "stop"
} else if !reShutdownBehavior.MatchString(c.InstanceInitiatedShutdownBehavior) { } else if !reShutdownBehavior.MatchString(c.InstanceInitiatedShutdownBehavior) {