1
0

More than 3 years have passed since last update.

SAMで作成されるApiGatewayをエッジ最適化以外で作成したいとき

Last updated at Posted at 2020-02-07

SAMだとApiGatewayのリソースを書かなくても暗黙的につくられますが、既定ではエッジ最適化でつくられているので、リージョンとかプライベートでつくりたい。
今回はリージョンで指定します。

AWS::Serverless::Api のリソースを記述して、 EndpointConfigurationREGIONAL を指定します。
AWS::Serverless::Function のEventsに Type: Api を作成しますが、その際に RestApiId を指定して、先ほど作成したAWS::Serverless::Api リソースを参照するように指定します。

template.yaml
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      EndpointConfiguration: REGIONAL
  FooFunction:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        Foo:
          Type: Api
          Properties:
            Path: /foo
            Method: post
            RestApiId: !Ref ApiGatewayApi

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0