aws.go 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. Copyright 2020 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package ecs
  14. import (
  15. "context"
  16. "github.com/aws/aws-sdk-go/service/cloudformation"
  17. "github.com/aws/aws-sdk-go/service/ecs"
  18. "github.com/docker/compose-cli/api/compose"
  19. "github.com/docker/compose-cli/api/secrets"
  20. )
  21. const (
  22. awsTypeCapacityProvider = "AWS::ECS::CapacityProvider"
  23. awsTypeAutoscalingGroup = "AWS::AutoScaling::AutoScalingGroup"
  24. )
  25. //go:generate mockgen -destination=./aws_mock.go -self_package "github.com/docker/compose-cli/ecs" -package=ecs . API
  26. // API hides aws-go-sdk into a simpler, focussed API subset
  27. type API interface {
  28. CheckRequirements(ctx context.Context, region string) error
  29. ResolveCluster(ctx context.Context, nameOrArn string) (awsResource, error)
  30. CreateCluster(ctx context.Context, name string) (string, error)
  31. CheckVPC(ctx context.Context, vpcID string) error
  32. GetDefaultVPC(ctx context.Context) (string, error)
  33. GetSubNets(ctx context.Context, vpcID string) ([]awsResource, error)
  34. IsPublicSubnet(ctx context.Context, subNetID string) (bool, error)
  35. GetRoleArn(ctx context.Context, name string) (string, error)
  36. StackExists(ctx context.Context, name string) (bool, error)
  37. CreateStack(ctx context.Context, name string, region string, template []byte) error
  38. CreateChangeSet(ctx context.Context, name string, region string, template []byte) (string, error)
  39. UpdateStack(ctx context.Context, changeset string) error
  40. WaitStackComplete(ctx context.Context, name string, operation int) error
  41. GetStackID(ctx context.Context, name string) (string, error)
  42. ListStacks(ctx context.Context) ([]compose.Stack, error)
  43. GetStackClusterID(ctx context.Context, stack string) (string, error)
  44. GetServiceTaskDefinition(ctx context.Context, cluster string, serviceArns []string) (map[string]string, error)
  45. ListStackServices(ctx context.Context, stack string) ([]string, error)
  46. GetServiceTasks(ctx context.Context, cluster string, service string, stopped bool) ([]*ecs.Task, error)
  47. GetTaskStoppedReason(ctx context.Context, cluster string, taskArn string) (string, error)
  48. DescribeStackEvents(ctx context.Context, stackID string) ([]*cloudformation.StackEvent, error)
  49. ListStackParameters(ctx context.Context, name string) (map[string]string, error)
  50. ListStackResources(ctx context.Context, name string) (stackResources, error)
  51. DeleteStack(ctx context.Context, name string) error
  52. CreateSecret(ctx context.Context, secret secrets.Secret) (string, error)
  53. InspectSecret(ctx context.Context, id string) (secrets.Secret, error)
  54. ListSecrets(ctx context.Context) ([]secrets.Secret, error)
  55. DeleteSecret(ctx context.Context, id string, recover bool) error
  56. GetLogs(ctx context.Context, name string, consumer func(container string, service string, message string), follow bool) error
  57. DescribeService(ctx context.Context, cluster string, arn string) (compose.ServiceStatus, error)
  58. DescribeServiceTasks(ctx context.Context, cluster string, project string, service string) ([]compose.ContainerSummary, error)
  59. getURLWithPortMapping(ctx context.Context, targetGroupArns []string) ([]compose.PortPublisher, error)
  60. ListTasks(ctx context.Context, cluster string, family string) ([]string, error)
  61. GetPublicIPs(ctx context.Context, interfaces ...string) (map[string]string, error)
  62. ResolveLoadBalancer(ctx context.Context, nameOrArn string) (awsResource, string, string, []awsResource, error)
  63. GetLoadBalancerURL(ctx context.Context, arn string) (string, error)
  64. GetParameter(ctx context.Context, name string) (string, error)
  65. SecurityGroupExists(ctx context.Context, sg string) (bool, error)
  66. DeleteCapacityProvider(ctx context.Context, arn string) error
  67. DeleteAutoscalingGroup(ctx context.Context, arn string) error
  68. ResolveFileSystem(ctx context.Context, id string) (awsResource, error)
  69. ListFileSystems(ctx context.Context, tags map[string]string) ([]awsResource, error)
  70. CreateFileSystem(ctx context.Context, tags map[string]string, options VolumeCreateOptions) (awsResource, error)
  71. DeleteFileSystem(ctx context.Context, id string) error
  72. }