https://pulumi.com logo
Title
m

miniature-arm-21874

08/24/2019, 10:54 PM
Hi. Is anyone able to point me in the direction of an example/documentation whereby autoscaling is attached to a fargate service? I've been unable to find anything
m

miniature-arm-21874

08/26/2019, 12:25 PM
That's scaling the underlying cluster, not the service(s) on top. I need App auto scaling. I've found various pieces but not managed to get it all working yet. Trying to work backwards from cloudformation templates but only had moderate success
a

alert-france-93241

10/30/2019, 3:36 PM
Hi @miniature-arm-21874 were you able to figure it out?
m

miniature-arm-21874

10/30/2019, 3:38 PM
yeah i put something together after a fair amount of struggling
sec i'll get it for you
a

alert-france-93241

10/30/2019, 3:39 PM
ohh lovely, thanks
Waiting here
m

miniature-arm-21874

10/30/2019, 3:40 PM
const cluster = new awsx.ecs.Cluster('cluster', { vpc }, { provider });
const nginx = new awsx.ecs.FargateService(
  'nginx',
  {...},
  { provider }
);

const ecsTarget = new aws.appautoscaling.Target(
  'ecs-target',
  {
    maxCapacity: 4,
    minCapacity: 1,
    resourceId: pulumi.interpolate`service/${cluster.cluster.name}/${nginx.service.name}`,
    scalableDimension: 'ecs:service:DesiredCount',
    serviceNamespace: 'ecs',
  },
  { provider }
);

const ecsPolicy = new aws.appautoscaling.Policy(
  'ecsPolicy',
  {
    policyType: 'TargetTrackingScaling',
    resourceId: ecsTarget.resourceId,
    scalableDimension: ecsTarget.scalableDimension,
    serviceNamespace: ecsTarget.serviceNamespace,
    targetTrackingScalingPolicyConfiguration: {
      predefinedMetricSpecification: {
        predefinedMetricType: 'ECSServiceAverageCPUUtilization',
      },
      targetValue: 70,
    },
  },
  { provider }
);
a

alert-france-93241

10/30/2019, 3:40 PM
Thanks a lot @miniature-arm-21874
m

miniature-arm-21874

10/30/2019, 3:40 PM
no problem
a

alert-france-93241

10/30/2019, 3:47 PM
@miniature-arm-21874 can you also list the import for pulumi.interpolate
m

miniature-arm-21874

10/30/2019, 3:47 PM
import * as pulumi from '@pulumi/pulumi';
@alert-france-93241 did you get it working?
a

alert-france-93241

11/01/2019, 10:43 AM
Yes Thanks @miniature-arm-21874, it's working well now.
m

miniature-arm-21874

11/01/2019, 10:43 AM
👍