APIGW not being deployed for endpoints
Normal AWS provider outputs APIGW base URL and endpoint URLs. It's very helpful to have after doing a new deployment. Would be nice to have.
Actually I guess it doesn't make any APIGW resources at all...
service: foo
provider:
# CDK
name: aws-cdk
cdkModulePath: ./build/cdk
stackName: "${self:service}-${self:provider.stage}"
# node
runtime: nodejs12.x
# AWS
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
httpApi:
cors: true
payload: "2.0"
logs:
httpApi: true
tracing:
apiGateway: true
lambda: true
package:
exclude:
- "node_modules/**"
- "src/**"
- "cdk/**"
plugins:
- serverless-aws-cdk
- serverless-offline
- serverless-plugin-typescript
- serverless-pseudo-parameters
- serverless-dotenv-plugin
functions:
testJson:
handler: src/api/testTwilio.testJson
events:
- httpApi:
method: POST
path: /sms/testJson
No APIGateway resources are deployed
Hey @revmischa, thanks for raising this. One of the aims of this project is to reduce extra magic in the serverless.yml, so it doesn't include e.g. the events key that you might be used to from the AWS provider. Instead, the idea is that you can define it yourself just as easily with all the benefits of using CDK directly.
On your other point around printing outputs, since the plugin doesn't have knowledge of these things, it can't print outputs; instead, it's recommended that you use stack outputs which are printed out by CDK by default.
I've created a PR (#16) to update the README to address both of these and make it explicit, as well as to provide extra examples for those use cases
Oh, that's disappointing. I still have to define the events because I want to test my endpoints with serverless-offline, and use httpApi authorizers and whatnot.
Ah, that makes sense - I don't think I'll get a chance to dedicate much time to implementing that myself any time soon, but if it's required for interop with other plugins I'm more than happy to take a look at any PRs for it
I'm looking at trying to do this manually for now, I assume it'd go something like this:
import { api } from "serverless-aws-cdk"
import * as cdk from "@aws-cdk/core"
import { HttpApi, LambdaProxyIntegration, HttpMethod,PayloadFormatVersion } from "@aws-cdk/aws-apigatewayv2"
export class Api extends api.InfrastructureConstruct {
constructor(scope: cdk.Construct, id: string, props: api.InfrastructureProps) {
super(scope, id, props)
// there will probably be a nicer L2 way of doing this
const api = new HttpApi(this, "API", {
corsPreflight: { allowCredentials: true, allowOrigins: ["*"] },
createDefaultStage: true,
})
api.addRoutes({
path: "/test",
methods: [HttpMethod.GET],
integration: new LambdaProxyIntegration({
payloadFormatVersion: PayloadFormatVersion.VERSION_2_0,
handler: ????? // what goes here?
})
})
}
}
I'd need to connect my existing sls function by passing something that conforms to an IFunction
props.functions is a mapping from functions as keyed in your serverless.yml to Function objects - you should be able to find the objext you need in there. From the serverless.yml you posted above, it should be props.functions["testJson"]
Thanks!