generated from isystk/lambda-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
111 lines (101 loc) · 2.93 KB
/
template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
stripe-subscription-api
SAM Template for stripe-subscription-api that has the DynamoDB table and Lambda
functions needed to demonstrate the Websocket protocol on API Gateway.
Parameters:
# パラメータ:アプリ名
AppName:
Type: String
Default: 'stripe_subscription_api'
Description: (Required) The name of the new DynamoDB to store connection identifiers for each connected clients. Minimum 3 characters
MinLength: 3
MaxLength: 50
AllowedPattern: ^[A-Za-z_]+$
ConstraintDescription: 'Required. Can be characters and underscore only. No numbers or special characters allowed.'
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 60
Resources:
# DynamoDBのテーブルを作成
PostsTable:
Type: AWS::DynamoDB::Table
Properties:
KeySchema:
- AttributeName: "pk"
KeyType: "HASH"
- AttributeName: "sk"
KeyType: "RANGE"
AttributeDefinitions:
- AttributeName: "pk"
AttributeType: "S"
- AttributeName: "sk"
AttributeType: "S"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
SSESpecification:
SSEEnabled: True
TableName: !Sub '${AppName}_posts'
# 処理関数
AppFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: backend/
Handler: lambda.handler
Runtime: nodejs16.x
Architectures:
- x86_64
Policies: AmazonDynamoDBFullAccess
Layers:
- !Ref AppLayer
Environment:
Variables:
STRIPE_SECRET: ""
SMTP_SERVER: ""
SMTP_PORT: ""
SMTP_SECURE: ""
SMTP_USER: ""
SMTP_PASS: ""
MAIL_FROM_ADDRESS: ""
ORIGIN_URL: ""
ADMIN_USER: ""
ADMIN_PASSWORD: ""
Events:
Api:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
Metadata:
BuildMethod: esbuild
BuildProperties:
Format: esm
Minify: false
Target: "es2020"
Sourcemap: true
EntryPoints:
- src/lambda.ts
# Layer(共通処理)
AppLayer:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Base Layer for Node.js
ContentUri: layers/app-layer/
RetentionPolicy: Retain
CompatibleRuntimes:
- nodejs16.x
Metadata:
BuildMethod: makefile
Outputs:
PostsTableArn:
Description: "Posts table ARN"
Value: !GetAtt PostsTable.Arn
AppFunctionArn:
Description: "App function ARN"
Value: !GetAtt AppFunction.Arn
ApiURI:
Description: "API Gateway endpoint URL for Prod stage for AppFunction"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"