Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
b78b119a
Commit
b78b119a
authored
May 28, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
amazon/*: fix merge issues with lib switch
parent
44b980e6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
23 deletions
+27
-23
builder/amazon/common/access_config.go
builder/amazon/common/access_config.go
+13
-11
builder/amazon/common/block_device.go
builder/amazon/common/block_device.go
+0
-2
builder/amazon/common/step_ami_region_copy.go
builder/amazon/common/step_ami_region_copy.go
+10
-8
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+2
-1
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+2
-1
No files found.
builder/amazon/common/access_config.go
View file @
b78b119a
...
...
@@ -8,6 +8,7 @@ import (
"unicode"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/credentials"
"github.com/mitchellh/packer/template/interpolate"
)
...
...
@@ -22,16 +23,16 @@ type AccessConfig struct {
// Config returns a valid aws.Config object for access to AWS services, or
// an error if the authentication and region couldn't be resolved
func
(
c
*
AccessConfig
)
Config
()
(
*
aws
.
Config
,
error
)
{
creds
Provider
:=
aws
.
DetectCreds
(
c
.
AccessKey
,
c
.
SecretKey
,
c
.
Token
)
creds
,
err
:=
credsProvider
.
Credentials
()
if
err
!=
nil
{
return
nil
,
err
}
c
.
AccessKey
=
creds
.
AccessKeyID
c
.
SecretKey
=
creds
.
SecretAccessKey
c
.
Token
=
creds
.
SessionToken
creds
:=
credentials
.
NewChainCredentials
([]
credentials
.
Provider
{
&
credentials
.
StaticProvider
{
Value
:
credentials
.
Value
{
AccessKeyID
:
c
.
AccessKey
,
SecretAccessKey
:
c
.
SecretKey
,
SessionToken
:
c
.
Token
,
}},
&
credentials
.
EnvProvider
{},
&
credentials
.
SharedCredentialsProvider
{
Filename
:
""
,
Profile
:
""
},
&
credentials
.
EC2RoleProvider
{},
})
region
,
err
:=
c
.
Region
()
if
err
!=
nil
{
...
...
@@ -40,7 +41,8 @@ func (c *AccessConfig) Config() (*aws.Config, error) {
return
&
aws
.
Config
{
Region
:
region
,
Credentials
:
credsProvider
,
Credentials
:
creds
,
MaxRetries
:
11
,
},
nil
}
...
...
builder/amazon/common/block_device.go
View file @
b78b119a
package
common
import
(
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/ec2"
"github.com/mitchellh/packer/template/interpolate"
...
...
builder/amazon/common/step_ami_region_copy.go
View file @
b78b119a
...
...
@@ -5,7 +5,6 @@ import (
"sync"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/ec2"
"github.com/mitchellh/multistep"
...
...
@@ -13,7 +12,8 @@ import (
)
type
StepAMIRegionCopy
struct
{
Regions
[]
string
AccessConfig
*
AccessConfig
Regions
[]
string
}
func
(
s
*
StepAMIRegionCopy
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
...
...
@@ -37,7 +37,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction {
go
func
(
region
string
)
{
defer
wg
.
Done
()
id
,
err
:=
amiRegionCopy
(
state
,
ec2conn
.
Config
.
Credentials
,
ami
,
region
,
ec2conn
.
Config
.
Region
)
id
,
err
:=
amiRegionCopy
(
state
,
s
.
AccessConfig
,
ami
,
region
,
ec2conn
.
Config
.
Region
)
lock
.
Lock
()
defer
lock
.
Unlock
()
...
...
@@ -69,15 +69,17 @@ func (s *StepAMIRegionCopy) Cleanup(state multistep.StateBag) {
// amiRegionCopy does a copy for the given AMI to the target region and
// returns the resulting ID or error.
func
amiRegionCopy
(
state
multistep
.
StateBag
,
auth
aws
.
CredentialsProvider
,
imageId
string
,
func
amiRegionCopy
(
state
multistep
.
StateBag
,
config
*
AccessConfig
,
imageId
string
,
target
string
,
source
string
)
(
string
,
error
)
{
// Connect to the region where the AMI will be copied to
config
:=
&
aws
.
Config
{
Credentials
:
auth
,
Region
:
target
,
awsConfig
,
err
:=
config
.
Config
()
if
err
!=
nil
{
return
""
,
err
}
regionconn
:=
ec2
.
New
(
config
)
awsConfig
.
Region
=
target
regionconn
:=
ec2
.
New
(
awsConfig
)
resp
,
err
:=
regionconn
.
CopyImage
(
&
ec2
.
CopyImageInput
{
SourceRegion
:
&
source
,
SourceImageID
:
&
imageId
,
...
...
builder/amazon/ebs/builder.go
View file @
b78b119a
...
...
@@ -121,7 +121,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
stepModifyInstance
{},
&
stepCreateAMI
{},
&
awscommon
.
StepAMIRegionCopy
{
Regions
:
b
.
config
.
AMIRegions
,
AccessConfig
:
&
b
.
config
.
AccessConfig
,
Regions
:
b
.
config
.
AMIRegions
,
},
&
awscommon
.
StepModifyAMIAttributes
{
Description
:
b
.
config
.
AMIDescription
,
...
...
builder/amazon/instance/builder.go
View file @
b78b119a
...
...
@@ -203,7 +203,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
&
StepRegisterAMI
{},
&
awscommon
.
StepAMIRegionCopy
{
Regions
:
b
.
config
.
AMIRegions
,
AccessConfig
:
&
b
.
config
.
AccessConfig
,
Regions
:
b
.
config
.
AMIRegions
,
},
&
awscommon
.
StepModifyAMIAttributes
{
Description
:
b
.
config
.
AMIDescription
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment