backend.go 588 B

123456789101112131415161718192021222324252627282930
  1. package backend
  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/amazon/sdk"
  6. )
  7. func NewBackend(profile string, region string) (*Backend, error) {
  8. sess, err := session.NewSessionWithOptions(session.Options{
  9. Profile: profile,
  10. SharedConfigState: session.SharedConfigEnable,
  11. Config: aws.Config{
  12. Region: aws.String(region),
  13. },
  14. })
  15. if err != nil {
  16. return nil, err
  17. }
  18. return &Backend{
  19. Region: region,
  20. api: sdk.NewAPI(sess),
  21. }, nil
  22. }
  23. type Backend struct {
  24. Region string
  25. api sdk.API
  26. }