目次

AWS::Serverless 変換を利用する場合

template.yml

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Test serverless application.

Resources:

  SampleApi:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: SampleFunction
      Description: "Sample"
      Handler: index.handler
      Runtime: python3.6
      Events:
        ListApi:
          Type: Api 
          Properties:
            Path: /
            Method: get 
        GetApi:
          Type: Api 
          Properties:
            Path: /{id}
            Method: get 

Outputs:
  SampleApiUri:
    # 作成したAPIのURIをエクスポートしておく
    # ※AWS::Serverless変換を使用した場合、ステージは Stage,Prod の2つが作成される
    Description: "API Gateway endpoint URL for Prod stage"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
    Export:
      Name: SampleApiUri

※実際の運用ではカスタムドメインを使用してベースパスマッピングを設定する事になるが、ここでは割愛する。

AWS::Serverless 変換を利用しない場合

TODO:

トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS