Create an API Gateway Proxy Resource using SAM

限于喜欢 提交于 2019-12-04 16:03:15

After a lot of playing around, I believe I found the answer in an example here. The diff relative to the Hello World example that SAM sets up for you out of the box is:

diff --git a/sam-app/template.yaml b/sam-app/template.yaml
index 02cd901..f349dcc 100644
--- a/sam-app/template.yaml
+++ b/sam-app/template.yaml
@@ -17,11 +17,11 @@ Resources:
         Variables:
           PARAM1: VALUE
       Events:
-        HelloWorld:
+        ProxyApiGreedy:
           Type: Api
           Properties:
-            Path: /hello
-            Method: get
+            Path: /{proxy+}
+            Method: ANY
 Outputs:
   HelloWorldApi:
     Description: API Gateway endpoint URL for Prod stage for Hello World function

In other words, like this:

Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      ...
      Events:
        ProxyApiGreedy:
          Type: Api
          Properties:
            Path: /{proxy+}
            Method: ANY
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!