diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index ed280ec6d..6351a1731 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -13,6 +13,7 @@ type RunConfig struct { SourceAmi string `mapstructure:"source_ami"` IamInstanceProfile string `mapstructure:"iam_instance_profile"` InstanceType string `mapstructure:"instance_type"` + UserData string `mapstructure:"user_data"` RawSSHTimeout string `mapstructure:"ssh_timeout"` SSHUsername string `mapstructure:"ssh_username"` SSHPort int `mapstructure:"ssh_port"` diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index 58f6f0f07..6d0ee83d8 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -11,6 +11,7 @@ import ( type StepRunSourceInstance struct { ExpectedRootDevice string InstanceType string + UserData string SourceAMI string IamInstanceProfile string SubnetId string @@ -28,6 +29,7 @@ func (s *StepRunSourceInstance) Run(state map[string]interface{}) multistep.Step KeyName: keyName, ImageId: s.SourceAMI, InstanceType: s.InstanceType, + UserData: []byte(s.UserData), MinCount: 0, MaxCount: 0, SecurityGroups: []ec2.SecurityGroup{ec2.SecurityGroup{Id: securityGroupId}}, diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 65189cb14..40c341a20 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -114,6 +114,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &awscommon.StepRunSourceInstance{ ExpectedRootDevice: "ebs", InstanceType: b.config.InstanceType, + UserData: b.config.UserData, SourceAMI: b.config.SourceAmi, IamInstanceProfile: b.config.IamInstanceProfile, SubnetId: b.config.SubnetId, diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 50cc0833e..f1057108c 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -193,6 +193,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &awscommon.StepRunSourceInstance{ ExpectedRootDevice: "instance-store", InstanceType: b.config.InstanceType, + UserData: b.config.UserData, SourceAMI: b.config.SourceAmi, SubnetId: b.config.SubnetId, },