Merge pull request #4896 from remijouannet/f-amazon_builder_custom_endpoint

add an option custom_endpoint_ec2 for amazon builder, add a condition…
This commit is contained in:
Matthew Hooker 2017-05-17 10:31:40 -07:00 committed by GitHub
commit 710010fbe0
7 changed files with 37 additions and 7 deletions

View File

@ -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 {

View File

@ -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())

View File

@ -278,6 +278,9 @@ each category, the available configuration keys are alphabetized.
`BuildRegion` variable is replaced with name of the region where this `BuildRegion` variable is replaced with name of the region where this
is built. is built.
- `custom_endpoint_ec2` (string) - this option is useful if you use
another cloud provider that provide a compatible API with aws EC2,
specify another endpoint like this "https://ec2.another.endpoint..com"
## Basic Example ## Basic Example

View File

@ -334,6 +334,10 @@ builder.
- `windows_password_timeout` (string) - The timeout for waiting for a Windows - `windows_password_timeout` (string) - The timeout for waiting for a Windows
password for Windows instances. Defaults to 20 minutes. Example value: `10m` password for Windows instances. Defaults to 20 minutes. Example value: `10m`
- `custom_endpoint_ec2` (string) - this option is useful if you use
another cloud provider that provide a compatible API with aws EC2,
specify another endpoint like this "https://ec2.another.endpoint..com"
## Basic Example ## Basic Example
Here is a basic example. You will need to provide access keys, and may need to Here is a basic example. You will need to provide access keys, and may need to

View File

@ -326,6 +326,10 @@ builder.
- `windows_password_timeout` (string) - The timeout for waiting for a Windows - `windows_password_timeout` (string) - The timeout for waiting for a Windows
password for Windows instances. Defaults to 20 minutes. Example value: `10m` password for Windows instances. Defaults to 20 minutes. Example value: `10m`
- `custom_endpoint_ec2` (string) - this option is useful if you use
another cloud provider that provide a compatible API with aws EC2,
specify another endpoint like this "https://ec2.another.endpoint..com"
## Basic Example ## Basic Example
```json ```json

View File

@ -226,6 +226,11 @@ builder.
- `windows_password_timeout` (string) - The timeout for waiting for a Windows - `windows_password_timeout` (string) - The timeout for waiting for a Windows
password for Windows instances. Defaults to 20 minutes. Example value: `10m` password for Windows instances. Defaults to 20 minutes. Example value: `10m`
- `custom_endpoint_ec2` (string) - this option is useful if you use
another cloud provider that provide a compatible API with aws EC2,
specify another endpoint like this "https://ec2.another.endpoint..com"
## Basic Example ## Basic Example
```json ```json

View File

@ -336,6 +336,10 @@ builder.
- `windows_password_timeout` (string) - The timeout for waiting for a Windows - `windows_password_timeout` (string) - The timeout for waiting for a Windows
password for Windows instances. Defaults to 20 minutes. Example value: `10m` password for Windows instances. Defaults to 20 minutes. Example value: `10m`
- `custom_endpoint_ec2` (string) - this option is useful if you use
another cloud provider that provide a compatible API with aws EC2,
specify another endpoint like this "https://ec2.another.endpoint..com"
## Basic Example ## Basic Example
Here is a basic example. It is completely valid except for the access keys: Here is a basic example. It is completely valid except for the access keys: