Hey guys I have this in my current codebase, and I...
# sst
g
Hey guys I have this in my current codebase, and I would like to use SST to achieve this, I would like to add custom domains later on and don't want to add it manually as the is already supported in SST. The help would be appreciated. Please message me if you need more context on this.
Copy code
import { App, Stack } from '@serverless-stack/resources';
import {
  HttpApi,
} from '@aws-cdk/aws-apigatewayv2';
import { HttpAlbIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
import { Server } from './Server';

export class Api extends Stack {
  constructor(app: App, props: Props) {
    super(app, 'api');
    const { server } = props;
    const { fargate } = server;

    const integration = new HttpAlbIntegration({
      listener: fargate.listener,
    });
    new HttpApi(this, 'http-api', {
      defaultIntegration: integration,
    });
  }
}

interface Props {
  server: Server;
}
f
Hey @geekmidas, I can add ALB support for Api today. And you will be able to do this:
Copy code
new sst.Api(this, 'http-api', {
  customDomain: "<http://api.domain.com|api.domain.com>",
  defaultRoute: {
    albProps: {
      listener: fargate.listener,
    }
  },
});
Would that work for you?
g
Should we not add an integration functionality instead? Because that would support different types of API Gateway integrations? @Frank
f
Yeah, we will support all integrations over time like this:
Copy code
new sst.Api(this, 'MyApi', {
  routes: {
    "GET /": "src/lambda.main",
    "GET /2nd": {
      albProps: { ... },
    },
    "GET /3rd": {
      sqsProps: { ... },
    },
  },
});
Just cleaner, so ppl don’t have to
Copy code
import { HttpAlbIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
g
@Frank I see, we would have to make sure not more than one integration is used for a route. I am not sure if this
Copy code
"GET /2nd": {
      integrationType: SOME_ENUM
      integration: albProps | sqsProps |...
    },
would work better, what do you think?
f
I think we can figure out the integration type from whether it’s
albProps
or
sqsProps
, etc. But you are right, we should throw an error if ppl are trying to set more than 1 integration.
@geekmidas Just added ALB integration in v0.35.0. See an example here - https://docs.serverless-stack.com/constructs/Api#configuring-alb-routes
g
@Frank Thanks, I will check it out.