diff --git a/appspec/spec.go b/appspec/spec.go index ec6d7db8..ef732f5c 100644 --- a/appspec/spec.go +++ b/appspec/spec.go @@ -58,6 +58,15 @@ func NewWithService(sv *ecs.Service, tdArn string) (*AppSpec, error) { }, } } + if sv.CapacityProviderStrategy != nil { + for _, strategy := range sv.CapacityProviderStrategy { + resource.TargetService.Properties.CapacityProviderStrategy = append(resource.TargetService.Properties.CapacityProviderStrategy, &CapacityProviderStrategy{ + CapacityProvider: strategy.CapacityProvider, + Base: strategy.Base, + Weight: strategy.Weight, + }) + } + } spec.Resources = append(spec.Resources, resource) return spec, nil } @@ -72,10 +81,11 @@ type TargetService struct { } type Properties struct { - TaskDefinition *string `yaml:"TaskDefinition,omitempty"` - LoadBalancerInfo *LoadBalancerInfo `yaml:"LoadBalancerInfo,omitempty"` - PlatformVersion *string `yaml:"PlatformVersion,omitempty"` - NetworkConfiguration *NetworkConfiguration `yaml:"NetworkConfiguration,omitempty"` + TaskDefinition *string `yaml:"TaskDefinition,omitempty"` + LoadBalancerInfo *LoadBalancerInfo `yaml:"LoadBalancerInfo,omitempty"` + PlatformVersion *string `yaml:"PlatformVersion,omitempty"` + NetworkConfiguration *NetworkConfiguration `yaml:"NetworkConfiguration,omitempty"` + CapacityProviderStrategy []*CapacityProviderStrategy `yaml:"CapacityProviderStrategy,omitempty"` } type LoadBalancerInfo struct { @@ -93,6 +103,12 @@ type AwsVpcConfiguration struct { Subnets []*string `yaml:"Subnets,omitempty"` } +type CapacityProviderStrategy struct { + CapacityProvider *string `yaml:"CapacityProvider,omitempty""` + Base *int64 `yaml:"Base,omitempty"` + Weight *int64 `yaml:"Weight,omitempty"` +} + type Hook struct { BeforeInstall string `yaml:"BeforeInstall,omitempty"` AfterInstall string `yaml:"AfterInstall,omitempty"` diff --git a/appspec/spec_test.go b/appspec/spec_test.go index 5ea55146..8d77a6e9 100644 --- a/appspec/spec_test.go +++ b/appspec/spec_test.go @@ -34,6 +34,18 @@ var expected = &appspec.AppSpec{ AssignPublicIp: aws.String("ENABLED"), }, }, + CapacityProviderStrategy: []*appspec.CapacityProviderStrategy{ + { + CapacityProvider: aws.String("FARGATE_SPOT"), + Base: aws.Int64(1), + Weight: aws.Int64(2), + }, + { + CapacityProvider: aws.String("FARGATE"), + Base: aws.Int64(0), + Weight: aws.Int64(1), + }, + }, }, }, }, diff --git a/appspec/test.yml b/appspec/test.yml index 5e386074..fa724938 100644 --- a/appspec/test.yml +++ b/appspec/test.yml @@ -14,6 +14,13 @@ Resources: Subnets: ["subnet-1234abcd", "subnet-5678abcd"] SecurityGroups: ["sg-12345678"] AssignPublicIp: "ENABLED" + CapacityProviderStrategy: + - Base: 1 + CapacityProvider: "FARGATE_SPOT" + Weight: 2 + - Base: 0 + CapacityProvider: "FARGATE" + Weight: 1 Hooks: - BeforeInstall: "LambdaFunctionToValidateBeforeInstall" - AfterInstall: "LambdaFunctionToValidateAfterTraffic"