I want to connect my newly created `DockerImageFun...
# sst
a
I want to connect my newly created
DockerImageFunction
to an existing API GW v2 created with
Api
construct. Can I use the existing
addRoutes
method from
Api
or I have to level down to the CDK gw-integration construct? I did the integration this way:
Copy code
myApi.httpApi.addRoutes({
      path: '/books',
      methods: [HttpMethod.GET],
      integration: new LambdaProxyIntegration({
        handler: lambda,
      }),
    });
But maybe there is a cleaner way?
g
Hi Adrian, I was implementing this last week and ended up using CDK to add the route.
Copy code
const processFunc = new lambda.DockerImageFunction(this, "ProcessGifUrl", {
      code: lambda.DockerImageCode.fromImageAsset("./", { file :"infrastructure/Dockerfile" }),
      timeout: Duration.seconds(30),
      memorySize: 1024,
      environment: {
        S3_ASSETS_BUCKET: bucket.s3Bucket.bucketName
      }
    });
    const integration = new LambdaIntegration(processFunc);
    const resource = api.restApi.root.addResource("process-gif", {
      defaultMethodOptions: {
        apiKeyRequired: true,
        authorizationType:  AuthorizationType.NONE,
      }
    });

    resource.addMethod("POST", integration)
@Frank created an issue for allowing all lambda function definitions to work with SST: https://github.com/serverless-stack/serverless-stack/issues/1078
a
Nice, that makes sense, thanks for sharing.
f
Thanks @George Evans!
Looks like time to bump up the priority on this.