Closed karthequian closed 7 years ago
Actually, I figured it out! If someone else runs into this issue, start here: https://godoc.org/github.com/mweagle/Sparta#example-Main--ApiGateway and then extend as shown below. The echo2APIGatewayLambdaFn function should return something else to test...
// Create the MyEchoAPI API Gateway, with stagename /test. The associated
// Stage reesource will cause the API to be deployed.
stage := sparta.NewStage("prod")
apiGateway := sparta.NewAPIGateway("gauntlt", stage)
// Create a lambda function
echoAPIGatewayLambdaFn := sparta.NewLambda(sparta.IAMRoleDefinition{}, echoAPIGatewayEvent, nil)
// Associate a URL path component with the Lambda function
apiGatewayResource, _ := apiGateway.NewResource("/echoHelloWorld", echoAPIGatewayLambdaFn)
// Associate 1 or more HTTP methods with the Resource.
apiGatewayResource.NewMethod("GET", http.StatusOK)
// Create a lambda function
echo2APIGatewayLambdaFn := sparta.NewLambda(sparta.IAMRoleDefinition{}, echo2APIGatewayEvent, nil)
// Associate a URL path component with the Lambda function
api2GatewayResource, _ := apiGateway.NewResource("/echo2HelloWorld", echo2APIGatewayLambdaFn)
// Associate 1 or more HTTP methods with the Resource.
api2GatewayResource.NewMethod("GET", http.StatusOK)
// After the stack is deployed, the
// echoAPIGatewayEvent lambda function will be available at:
// https://{RestApiID}.execute-api.{AWSRegion}.amazonaws.com/test
//
// The dynamically generated URL will be written to STDOUT as part of stack provisioning as in:
//
// Outputs: [{
// Description: "API Gateway URL",
// OutputKey: "URL",
// OutputValue: "https://zdjfwrcao7.execute-api.us-west-2.amazonaws.com/test"
// }]
// eg:
// curl -vs https://zdjfwrcao7.execute-api.us-west-2.amazonaws.com/test/echoHelloWorld
// Start
sparta.Main("HelloWorldLambdaService", "Description for Hello World Lambda", []*sparta.LambdaAWSInfo{echoAPIGatewayLambdaFn, echo2APIGatewayLambdaFn}, apiGateway, nil)
Thanks for the awesome framework! I was able to get the helloworld example to work great, and started to play with adding more routes to the example when I ran into an error at deployment time..
Code:
When I deploy this, I get a bunch of errors during stack provisioning...
Any hints would be appreciated! Thanks in advance!