Hi. Is anyone able to point me in the direction of...
# typescript
m
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
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
Hi @miniature-arm-21874 were you able to figure it out?
m
yeah i put something together after a fair amount of struggling
sec i'll get it for you
a
ohh lovely, thanks
Waiting here
m
Copy code
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
Thanks a lot @miniature-arm-21874
m
no problem
a
@miniature-arm-21874 can you also list the import for pulumi.interpolate
m
import * as pulumi from '@pulumi/pulumi';
@alert-france-93241 did you get it working?
a
Yes Thanks @miniature-arm-21874, it's working well now.
m
👍