Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions provision/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ type EC2Provisioner struct {
ec2Provisioner *ec2.EC2
}

// NewEC2Provisioner creates an EC2Provisioner and initialises an EC2 client
// NewEC2Provisioner creates an EC2Provisioner and initialises an EC2 client,
// when accessKey and secretKey are "" default credential chain is used
func NewEC2Provisioner(region, accessKey, secretKey string) (*EC2Provisioner, error) {
sess, err := session.NewSession(&aws.Config{
Region: aws.String(region),
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""),
})
awsConfig := &aws.Config{Region: aws.String(region)}

if accessKey != "" && secretKey != "" {
awsConfig.Credentials = credentials.NewStaticCredentials(accessKey, secretKey, "")
}

sess, err := session.NewSession(awsConfig)

svc := ec2.New(sess)
return &EC2Provisioner{ec2Provisioner: svc}, err
}
Expand Down