Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AWS::ECS::Service] - [BUG] - changing from LaunchType to CapacityProviderStrategy fails through Cloudformation #2214

Open
allixsenos opened this issue Dec 13, 2024 · 0 comments
Labels

Comments

@allixsenos
Copy link

Name of the resource

AWS::ECS::Service

Resource Name

No response

Issue Description

Going from LaunchType to CapacityProviderStrategy on an ECS Service that has a defined ServiceName fails through Cloudformation because it tries to recreate the Service.

The same action can be performed in-place through the AWS ECS web console without any issue.

Recreating the resource is unnecessary and makes it impossible to execute this change through Cloudformation short of doing an unnecessary rename operation.

Expected Behavior

Cloudformation should reconfigure the ECS Service in place and not try to recreate it.

Observed Behavior

Cloudformation tries to recreate the ECS Service which then fails because the name is statically defined.

Test Cases

  1. define an ECS Service with a fixed name using FARGATE Launch Type
  Service:
    Type: AWS::ECS::Service
    DependsOn: LoadBalancerRule
    Properties:
      ServiceName: "myservicename"
      Cluster: "default"
      LaunchType: FARGATE
      DeploymentConfiguration:
        MaximumPercent: 200
        MinimumHealthyPercent: 100
      HealthCheckGracePeriodSeconds: 40
      DesiredCount: 2
      EnableExecuteCommand: true
      NetworkConfiguration:
        AwsvpcConfiguration:
          SecurityGroups:
            - !ImportValue 'awesome-vpc:SecurityGroupVeryPermissive'
          Subnets:
            - !ImportValue 'awesome-vpc:SubnetPrivateOne'
            - !ImportValue 'awesome-vpc:SubnetPrivateTwo'
      TaskDefinition: !Ref TaskDefinition
      LoadBalancers:
        - ContainerName: haproxy
          ContainerPort: !Ref HaproxyListenPort
          TargetGroupArn: !Ref TargetGroup
      EnableECSManagedTags: true
      PropagateTags: SERVICE
  1. once deployed, remove LaunchType: FARGATE and add
      CapacityProviderStrategy:
        - CapacityProvider: FARGATE_SPOT
          Base: 0
          Weight: 1

Observed error:

Resource handler returned message: "Resource of type 'AWS::ECS::Service' with identifier 'myservice' already exists." (RequestToken: XYZ, HandlerErrorCode: AlreadyExists)

Executing the same change via ECS Console works fine.

Other Details

No response

@allixsenos allixsenos added the bug label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant