sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.09k stars 126 forks source link

`Service` lacks flexibility #434

Open zvictor opened 1 month ago

zvictor commented 1 month ago

I am migrating from SST 2 and I noticed that Service seems much more flexible there.

Use case: Deploy a container with minimum costs - no ALB, no scaling, using Fargate Spot when possible. This is good for chatbots and other apps that do not need to be reachable directly by the public and can possibly sustain little downtime sometimes. Depending on the setup, an ALB can easily be more expensive than the actual service!

In SST 2:

const service = new Service(ctx.stack, id, {
      scaling: {
        maxContainers: 1, // some bots are not allowed to have more than 1 connection (e.g. whatsapp-web.js)
      },
      cdk: {
        applicationLoadBalancer: false,
        cloudfrontDistribution: false,
        fargateService: {
          enableExecuteCommand: true,
          assignPublicIp: true,
          maxHealthyPercent: 100, // some bots are not allowed to have more than 1 connection (e.g. whatsapp-web.js)
          minHealthyPercent: 0,
          desiredCount: 1,
          capacityProviderStrategies: [
            {
              capacityProvider: 'FARGATE_SPOT',
              weight: 100,
              base: 1,
            },
            {
              capacityProvider: 'FARGATE',
              weight: 1,
            },
          ],
          ...

So far, in ION, I got this (incomplete):

const service = cluster.addService(id, {
  transform: {
    loadBalancer: ???, // LB seems to be adjustable, but not disabled
    service: {
      capacityProviderStrategies: [
        {
          capacityProvider: 'FARGATE_SPOT',
          weight: 100,
          base: 1,
        },
        {
          capacityProvider: 'FARGATE',
          weight: 1,
        },
      ],
    },
  },
  ...

Any suggestions of workarounds? If none is possible, should I work on a PR for it?

zvictor commented 1 month ago

As a minor clarification, I would say that "no scaling" is not really a priority here. The most important missing feature is definitely the ability to deploy the service without load balancers.

Being able to tune things like maxContainers, maxHealthyPercent, and minHealthyPercent are just "nice to have".

zvictor commented 3 weeks ago

If anyone knows how to achieve this using Pulumi components as a workaround for now, please share ☺️

jayair commented 3 weeks ago

Yeah we'll get to these soon hopefully.