I am new to AWS SAM, and I am trying to modify the Hello World example template to use an open api swagger file to define an API with lambda function integrations. When I run "sam build" and "sam deploy --guided" everything goes through. However, when I check the api-gateway I see that the route /helloGet has no integration attached to it (should be a lambda function). Can't seem to figure out what the problem is. Here are my sam template.yaml and openapi swagger.yaml.
#template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Sample SAM Template
Globals:
Function:
Timeout: 3
Resources:
MyHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
DefinitionUri: ./swagger.yaml
Domain:
DomainName: apitest.mydomain.com
CertificateArn: arn:aws:acm:*******:*********:certificate/*****-****-***-****-**********
EndpointConfiguration: REGIONAL
Route53:
HostedZoneId: ********************
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.9
Architectures: ['x86_64']
Events:
HelloWorldEvent1:
Type: HttpApi
Properties:
Path: /helloGet
Method: get
ApiId:
Ref: MyHttpApi
And my other file:
#swagger.yaml
openapi: "3.0.1"
info:
title: "Test SAM API"
version: "1.0.0"
paths:
/helloGet:
get:
responses:
default:
description: "Default response for GET /helloGet"
x-amazon-apigateway-integration:
payloadFormatVersion: "2.0"
type: "aws_proxy"
httpMethod: "GET"
uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HelloWorldFunction.Arn}/invocations"
connectionType: "INTERNET"
x-amazon-apigateway-cors:
allowMethods:
- "*"
allowHeaders:
- "*"
exposeHeaders:
- "*"
maxAge: 0
allowCredentials: false
allowOrigins:
- "https://1.0.0.127:4443"
x-amazon-apigateway-importexport-version: "1.0"
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration.html
So to make it work I changed httpMethod: "GET" to httpMethod: "POST".