forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_provider.go
30 lines (24 loc) · 870 Bytes
/
client_provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package aws
import (
"github.com/aws/aws-sdk-go/aws/session"
awscloudformation "github.com/aws/aws-sdk-go/service/cloudformation"
awsec2 "github.com/aws/aws-sdk-go/service/ec2"
"github.com/pivotal-cf-experimental/bosh-bootloader/aws/cloudformation"
"github.com/pivotal-cf-experimental/bosh-bootloader/aws/ec2"
)
type ClientProvider struct{}
func NewClientProvider() ClientProvider {
return ClientProvider{}
}
func (s ClientProvider) CloudFormationClient(config Config) (cloudformation.Client, error) {
if err := config.ValidateCredentials(); err != nil {
return nil, err
}
return awscloudformation.New(session.New(config.ClientConfig())), nil
}
func (s ClientProvider) EC2Client(config Config) (ec2.Client, error) {
if err := config.ValidateCredentials(); err != nil {
return nil, err
}
return awsec2.New(session.New(config.ClientConfig())), nil
}