タイトル : テンプレートを確認(python分) AWSサーバーレス2025
更新日 : 2025-01-19
カテゴリ : プログラミング
テンプレートを確認しましょう
HelloWorldを使うけど、他のテンプレートも確認してみましょう。
テンプレートの書き方を見るので言語は関係ないと言えば関係ないけど、全部Pythonが入っている訳ではないですね。
Choose an AWS Quick Start application template
1 - Hello World Example
2 - Data processing
3 - Hello World Example with Powertools for AWS Lambda
4 - Multi-step workflow
5 - Scheduled task
6 - Standalone function
7 - Serverless API
8 - Infrastructure event management
9 - Lambda Response Streaming
10 - GraphQLApi Hello World Example
11 - Full Stack
12 - Lambda EFS example
13 - Serverless Connector Hello World Example
14 - Multi-step workflow with Connectors
15 - DynamoDB Example
16 - Machine Learning
その方が、ポリシーの書き方とか、参考になるかも。
Resources:
Table:
Type: AWS::Serverless::SimpleTable # More info about SimpleTable Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-simpletable.html
Properties:
PrimaryKey:
Name: id
Type: String
PutFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Metadata:
BuildMethod: rust-cargolambda # More info about Cargo Lambda: https://github.com/cargo-lambda/cargo-lambda
Properties:
CodeUri: ./rust_app # Points to dir of Cargo.toml
Handler: bootstrap # Do not change, as this is the default executable name produced by Cargo Lambda
Runtime: provided.al2
Architectures:
- x86_64
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /{id}
Method: put
Environment:
Variables:
TABLE_NAME: !Ref Table
Policies: ★ポリシーの書き方?
- DynamoDBWritePolicy: # More info about SAM policy templates: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html
TableName: !Ref Table
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
PutApi:
Description: "API Gateway endpoint URL for Prod stage for Put function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/Prod/"
PutFunction:
Description: "Put Lambda Function ARN"
Value: !GetAtt PutFunction.Arn
PutTable:
Description: "DynamoDB table name"
Value: !GetAtt Table.Arn
Resources:
StreamingFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: index.handler
Runtime: nodejs22.x
Architectures:
- x86_64
Timeout: 10
FunctionUrlConfig:
AuthType: AWS_IAM
InvokeMode: RESPONSE_STREAM ★ストリーミングの時?