add an option custom_endpoint_ec2 for amazon builder, add a condition if vpc_id is empty don't add the parameter to the aws call
This commit is contained in:
parent
94360f4b39
commit
45143bb6f4
|
@ -17,12 +17,13 @@ import (
|
||||||
|
|
||||||
// AccessConfig is for common configuration related to AWS access
|
// AccessConfig is for common configuration related to AWS access
|
||||||
type AccessConfig struct {
|
type AccessConfig struct {
|
||||||
AccessKey string `mapstructure:"access_key"`
|
AccessKey string `mapstructure:"access_key"`
|
||||||
SecretKey string `mapstructure:"secret_key"`
|
SecretKey string `mapstructure:"secret_key"`
|
||||||
RawRegion string `mapstructure:"region"`
|
RawRegion string `mapstructure:"region"`
|
||||||
SkipValidation bool `mapstructure:"skip_region_validation"`
|
SkipValidation bool `mapstructure:"skip_region_validation"`
|
||||||
Token string `mapstructure:"token"`
|
Token string `mapstructure:"token"`
|
||||||
ProfileName string `mapstructure:"profile"`
|
ProfileName string `mapstructure:"profile"`
|
||||||
|
CustomEndpointEc2 string `mapstructure:"custom_endpoint_ec2"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config returns a valid aws.Config object for access to AWS services, or
|
// Config returns a valid aws.Config object for access to AWS services, or
|
||||||
|
@ -35,6 +36,11 @@ func (c *AccessConfig) Config() (*aws.Config, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
config := aws.NewConfig().WithRegion(region).WithMaxRetries(11)
|
config := aws.NewConfig().WithRegion(region).WithMaxRetries(11)
|
||||||
|
|
||||||
|
if c.CustomEndpointEc2 != "" {
|
||||||
|
config.Endpoint = &c.CustomEndpointEc2
|
||||||
|
}
|
||||||
|
|
||||||
if c.ProfileName != "" {
|
if c.ProfileName != "" {
|
||||||
profile, err := NewFromProfile(c.ProfileName)
|
profile, err := NewFromProfile(c.ProfileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -55,8 +55,12 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
group := &ec2.CreateSecurityGroupInput{
|
group := &ec2.CreateSecurityGroupInput{
|
||||||
GroupName: &groupName,
|
GroupName: &groupName,
|
||||||
Description: aws.String("Temporary group for Packer"),
|
Description: aws.String("Temporary group for Packer"),
|
||||||
VpcId: &s.VpcId,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.VpcId != "" {
|
||||||
|
group.VpcId = &s.VpcId
|
||||||
|
}
|
||||||
|
|
||||||
groupResp, err := ec2conn.CreateSecurityGroup(group)
|
groupResp, err := ec2conn.CreateSecurityGroup(group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
|
|
Loading…
Reference in New Issue