This commit is contained in:
parent
30ba7307b6
commit
31bf1f342c
|
@ -11,20 +11,21 @@ import (
|
||||||
// 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 {
|
||||||
SourceAmi string `mapstructure:"source_ami"`
|
SourceAmi string `mapstructure:"source_ami"`
|
||||||
IamInstanceProfile string `mapstructure:"iam_instance_profile"`
|
IamInstanceProfile string `mapstructure:"iam_instance_profile"`
|
||||||
InstanceType string `mapstructure:"instance_type"`
|
InstanceType string `mapstructure:"instance_type"`
|
||||||
UserData string `mapstructure:"user_data"`
|
UserData string `mapstructure:"user_data"`
|
||||||
UserDataFile string `mapstructure:"user_data_file"`
|
UserDataFile string `mapstructure:"user_data_file"`
|
||||||
RawSSHTimeout string `mapstructure:"ssh_timeout"`
|
RawSSHTimeout string `mapstructure:"ssh_timeout"`
|
||||||
SSHUsername string `mapstructure:"ssh_username"`
|
SSHUsername string `mapstructure:"ssh_username"`
|
||||||
SSHPort int `mapstructure:"ssh_port"`
|
SSHPort int `mapstructure:"ssh_port"`
|
||||||
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"`
|
AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address"`
|
||||||
VpcId string `mapstructure:"vpc_id"`
|
TemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"`
|
||||||
AvailabilityZone string `mapstructure:"availability_zone"`
|
VpcId string `mapstructure:"vpc_id"`
|
||||||
|
AvailabilityZone string `mapstructure:"availability_zone"`
|
||||||
|
|
||||||
// Unexported fields that are calculated from others
|
// Unexported fields that are calculated from others
|
||||||
sshTimeout time.Duration
|
sshTimeout time.Duration
|
||||||
|
@ -85,15 +86,16 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
|
||||||
}
|
}
|
||||||
|
|
||||||
templates := map[string]*string{
|
templates := map[string]*string{
|
||||||
"iam_instance_profile": &c.IamInstanceProfile,
|
"iam_instance_profile": &cc.IamInstanceProfile,
|
||||||
"instance_type": &c.InstanceType,
|
"instance_type": &cc.InstanceType,
|
||||||
"ssh_timeout": &c.RawSSHTimeout,
|
"ssh_timeout": &cc.RawSSHTimeout,
|
||||||
"ssh_username": &c.SSHUsername,
|
"ssh_username": &cc.SSHUsername,
|
||||||
"source_ami": &c.SourceAmi,
|
"source_ami": &cc.SourceAmi,
|
||||||
"subnet_id": &c.SubnetId,
|
"subnet_id": &cc.SubnetId,
|
||||||
"temporary_key_pair_name": &c.TemporaryKeyPairName,
|
"associate_public_ip_address": &cc.AssociatePublicIpAddress,
|
||||||
"vpc_id": &c.VpcId,
|
"temporary_key_pair_name": &cc.TemporaryKeyPairName,
|
||||||
"availability_zone": &c.AvailabilityZone,
|
"vpc_id": &cc.VpcId,
|
||||||
|
"availability_zone": &cc.AvailabilityZone,
|
||||||
}
|
}
|
||||||
|
|
||||||
for n, ptr := range templates {
|
for n, ptr := range templates {
|
||||||
|
|
|
@ -10,16 +10,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type StepRunSourceInstance struct {
|
type StepRunSourceInstance struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
ExpectedRootDevice string
|
ExpectedRootDevice string
|
||||||
InstanceType string
|
InstanceType string
|
||||||
UserData string
|
UserData string
|
||||||
UserDataFile string
|
UserDataFile string
|
||||||
SourceAMI string
|
SourceAMI string
|
||||||
IamInstanceProfile string
|
IamInstanceProfile string
|
||||||
SubnetId string
|
SubnetId string
|
||||||
AvailabilityZone string
|
AssociatePublicIpAddress bool
|
||||||
BlockDevices BlockDevices
|
AvailabilityZone string
|
||||||
|
BlockDevices BlockDevices
|
||||||
|
|
||||||
instance *ec2.Instance
|
instance *ec2.Instance
|
||||||
}
|
}
|
||||||
|
@ -47,17 +48,18 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
|
||||||
}
|
}
|
||||||
|
|
||||||
runOpts := &ec2.RunInstances{
|
runOpts := &ec2.RunInstances{
|
||||||
KeyName: keyName,
|
KeyName: keyName,
|
||||||
ImageId: s.SourceAMI,
|
ImageId: s.SourceAMI,
|
||||||
InstanceType: s.InstanceType,
|
InstanceType: s.InstanceType,
|
||||||
UserData: []byte(userData),
|
UserData: []byte(userData),
|
||||||
MinCount: 0,
|
MinCount: 0,
|
||||||
MaxCount: 0,
|
MaxCount: 0,
|
||||||
SecurityGroups: securityGroups,
|
SecurityGroups: securityGroups,
|
||||||
IamInstanceProfile: s.IamInstanceProfile,
|
IamInstanceProfile: s.IamInstanceProfile,
|
||||||
SubnetId: s.SubnetId,
|
SubnetId: s.SubnetId,
|
||||||
BlockDevices: s.BlockDevices.BuildLaunchDevices(),
|
AssociatePublicIpAddress: s.AssociatePublicIpAddress,
|
||||||
AvailZone: s.AvailabilityZone,
|
BlockDevices: s.BlockDevices.BuildLaunchDevices(),
|
||||||
|
AvailZone: s.AvailabilityZone,
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.Say("Launching a source AWS instance...")
|
ui.Say("Launching a source AWS instance...")
|
||||||
|
|
|
@ -93,16 +93,17 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
VpcId: b.config.VpcId,
|
VpcId: b.config.VpcId,
|
||||||
},
|
},
|
||||||
&awscommon.StepRunSourceInstance{
|
&awscommon.StepRunSourceInstance{
|
||||||
Debug: b.config.PackerDebug,
|
Debug: b.config.PackerDebug,
|
||||||
ExpectedRootDevice: "ebs",
|
ExpectedRootDevice: "ebs",
|
||||||
InstanceType: b.config.InstanceType,
|
InstanceType: b.config.InstanceType,
|
||||||
UserData: b.config.UserData,
|
UserData: b.config.UserData,
|
||||||
UserDataFile: b.config.UserDataFile,
|
UserDataFile: b.config.UserDataFile,
|
||||||
SourceAMI: b.config.SourceAmi,
|
SourceAMI: b.config.SourceAmi,
|
||||||
IamInstanceProfile: b.config.IamInstanceProfile,
|
IamInstanceProfile: b.config.IamInstanceProfile,
|
||||||
SubnetId: b.config.SubnetId,
|
SubnetId: b.config.SubnetId,
|
||||||
AvailabilityZone: b.config.AvailabilityZone,
|
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
||||||
BlockDevices: b.config.BlockDevices,
|
AvailabilityZone: b.config.AvailabilityZone,
|
||||||
|
BlockDevices: b.config.BlockDevices,
|
||||||
},
|
},
|
||||||
&common.StepConnectSSH{
|
&common.StepConnectSSH{
|
||||||
SSHAddress: awscommon.SSHAddress(ec2conn, b.config.SSHPort),
|
SSHAddress: awscommon.SSHAddress(ec2conn, b.config.SSHPort),
|
||||||
|
|
|
@ -196,16 +196,17 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
VpcId: b.config.VpcId,
|
VpcId: b.config.VpcId,
|
||||||
},
|
},
|
||||||
&awscommon.StepRunSourceInstance{
|
&awscommon.StepRunSourceInstance{
|
||||||
Debug: b.config.PackerDebug,
|
Debug: b.config.PackerDebug,
|
||||||
ExpectedRootDevice: "instance-store",
|
ExpectedRootDevice: "instance-store",
|
||||||
InstanceType: b.config.InstanceType,
|
InstanceType: b.config.InstanceType,
|
||||||
IamInstanceProfile: b.config.IamInstanceProfile,
|
IamInstanceProfile: b.config.IamInstanceProfile,
|
||||||
UserData: b.config.UserData,
|
UserData: b.config.UserData,
|
||||||
UserDataFile: b.config.UserDataFile,
|
UserDataFile: b.config.UserDataFile,
|
||||||
SourceAMI: b.config.SourceAmi,
|
SourceAMI: b.config.SourceAmi,
|
||||||
SubnetId: b.config.SubnetId,
|
SubnetId: b.config.SubnetId,
|
||||||
AvailabilityZone: b.config.AvailabilityZone,
|
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
|
||||||
BlockDevices: b.config.BlockDevices,
|
AvailabilityZone: b.config.AvailabilityZone,
|
||||||
|
BlockDevices: b.config.BlockDevices,
|
||||||
},
|
},
|
||||||
&common.StepConnectSSH{
|
&common.StepConnectSSH{
|
||||||
SSHAddress: awscommon.SSHAddress(ec2conn, b.config.SSHPort),
|
SSHAddress: awscommon.SSHAddress(ec2conn, b.config.SSHPort),
|
||||||
|
|
Loading…
Reference in New Issue