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

Autoscaling for Fargate services does not support new ECS ARN format #1849

Closed
pgarbe opened this issue Feb 24, 2019 · 6 comments · Fixed by #2176 · May be fixed by MechanicalRock/account-reaper#6
Closed

Autoscaling for Fargate services does not support new ECS ARN format #1849

pgarbe opened this issue Feb 24, 2019 · 6 comments · Fixed by #2176 · May be fixed by MechanicalRock/account-reaper#6
Assignees
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation @aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug.

Comments

@pgarbe
Copy link
Contributor

pgarbe commented Feb 24, 2019

Auto scaling of a Fargate service fails, if the new ECS ARN format has already been activated.

The following snippet creates an auto scaling Fargate service:

export class AwsSummitDemoStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const vpc = new ec2.VpcNetwork(this, 'MyVpc', { maxAZs: 3 });

    const cluster = new ecs.Cluster(this, 'MyCluster', {
      vpc: vpc
    });

    const demo = new ecs.LoadBalancedFargateService(this, 'MyFargateService', {
      cluster: cluster, 
      image: ecs.ContainerImage.fromDockerHub('amazon/amazon-ecs-sample'),
    });

    const scaling = demo.service.autoScaleTaskCount({ maxCapacity: 10 });
    scaling.scaleOnCpuUtilization('CpuScaling', {
      targetUtilizationPercent: 50
    });
  }
}

When the account (or user) already opted in to the new ECS ARN format, the Fargate service can be created, but autoscaling fails, as it generates the wrong service name:

MyFargateService/Service/TaskCount/Target (MyFargateServiceTaskCountTargetFD19DCA5) ECS service doesn't exist: service/AwsSummitDemoStack-MyCluster4C1BA579-UUFVS0WJMFMG/AwsSummitDemoStack-MyCluster4C1BA579-UUFVS0WJMFMG (Service: AWSApplicationAutoScaling; Status Code: 400; Error Code: ValidationException; Request ID: ...)
@RomainMuller RomainMuller added bug This issue is a bug. @aws-cdk/aws-ecs Related to Amazon Elastic Container labels Feb 25, 2019
@matthewtapper
Copy link

Hi, we turned on the new ECS ARN format today and it has broken a number of our stacks. It would be great to see this fixed.

@SoManyHs
Copy link
Contributor

Hi @pgarbe,

Apologies about the delay in getting back to you. Was the error generated when you ran cdk deploy? I assume you opted into the new ECS ARN format as root user?

@matthewtapper
Copy link

Hi @SoManyHs, after a bit of investigation this is actually a CloudFormation bug https://forums.aws.amazon.com/thread.jspa?threadID=294793 I’m not sure there is a work around that will work for both formats? Given the CloudFormation issue has been open for a while some extra voices may encourage a faster fix.

@SoManyHs SoManyHs added the @aws-cdk/aws-cloudformation Related to AWS CloudFormation label Mar 30, 2019
@SoManyHs
Copy link
Contributor

@matthewtapper Thanks for that info. I am still curious about the steps you took. I was unable to reproduce this bug using the stack in our integ test, so curious what I'm missing.

@matthewtapper
Copy link

matthewtapper commented Mar 30, 2019

@SoManyHs we enabled the new ECS ARN format in order to add some cost allocation tags to ecs. This was done as follows:

aws ecs put-account-setting-default --name serviceLongArnFormat --value enabled
aws ecs put-account-setting-default --name taskLongArnFormat --value enabled
aws ecs put-account-setting-default --name containerInstanceLongArnFormat --value enabled

With the above setting enabled valid CloudFormation is generated by cdk however the below portion of the stack fails as the Fn::GetAtt returns a cluster name as apposed to the service name

Fn::Join:
          - ""
          - - service/notifications-cluster/
            - Fn::GetAtt:
                - notificationsservicewebService8520C0F2
                - Name

@PaulMaddox
Copy link
Contributor

+1. I've also seen this consistently since enabling the new ARN format. I'm pretty sure that integ test will start failing as soon as the new format is enabled on the CDK integ account.

SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue Apr 4, 2019
Due to a bug in Cloudformation, Fn::GetAtt for service name on an ECS
service was returning the cluster name instead of the service name. This
was causing the ResourceId on AWS::ApplicationAutoScaling::ScalableTarget to be set incorrectly.

Fixes aws#1849.
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue Apr 4, 2019
Due to a bug in Cloudformation, Fn::GetAtt for service name on an ECS
service was returning the cluster name instead of the service name. This
was causing the ResourceId on AWS::ApplicationAutoScaling::ScalableTarget to be set incorrectly.

Fixes aws#1849.
SoManyHs added a commit to SoManyHs/aws-cdk that referenced this issue Apr 4, 2019
Due to a bug in Cloudformation, Fn::GetAtt for service name on an ECS
service was returning the cluster name instead of the service name. This
was causing the ResourceId on
AWS::ApplicationAutoScaling::ScalableTarget to be set incorrectly.

This change forces the customer to specify whether they have opted into
the long ARN format for services (which can be achieved through the following command:
`aws ecs put-account-setting-default --name serviceLongArnFormat --value
enabled`). The CDK cannot currently detect if the customer has the these
settings enabled so there could be a potential conflict on deployment.

Fixes aws#1849.
rix0rrr pushed a commit that referenced this issue Apr 5, 2019
Due to a bug in Cloudformation, Fn::GetAtt for service name on an ECS
service was returning the cluster name instead of the service name. This
was causing the ResourceId on
AWS::ApplicationAutoScaling::ScalableTarget to be set incorrectly.

This change forces the customer to specify whether they have opted into
the long ARN format for services (which can be achieved through the following command:
`aws ecs put-account-setting-default --name serviceLongArnFormat --value
enabled`). The CDK cannot currently detect if the customer has the these
settings enabled so there could be a potential conflict on deployment.

Fixes #1849.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation @aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug.
Projects
None yet
5 participants