client.go 657 B

123456789101112131415161718192021222324252627282930313233343536
  1. package amazon
  2. import (
  3. "github.com/aws/aws-sdk-go/aws"
  4. "github.com/aws/aws-sdk-go/aws/session"
  5. "github.com/docker/ecs-plugin/pkg/compose"
  6. )
  7. const (
  8. ProjectTag = "com.docker.compose.project"
  9. )
  10. func NewClient(profile string, cluster string, region string) (compose.API, error) {
  11. sess, err := session.NewSessionWithOptions(session.Options{
  12. Profile: profile,
  13. Config: aws.Config{
  14. Region: aws.String(region),
  15. },
  16. })
  17. if err != nil {
  18. return nil, err
  19. }
  20. return &client{
  21. Cluster: cluster,
  22. Region: region,
  23. api: NewAPI(sess),
  24. }, nil
  25. }
  26. type client struct {
  27. Cluster string
  28. Region string
  29. api API
  30. }
  31. var _ compose.API = &client{}