-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
70 lines (64 loc) · 2 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
AWSTemplateFormatVersion: 2010-09-09
Description: >-
aws-lambda-sns-poc
Transform:
- AWS::Serverless-2016-10-31
# More info about Globals: /~https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
LoggingConfig:
LogFormat: JSON
# Resources declares the AWS resources that you want to include in the stack
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
Resources:
SnsTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: SnsTopicEmailAlert
DisplayName: SnsTopicEmailAlert
Subscription:
- Endpoint: sample@email.com
Protocol: email
# Each Lambda function is defined by properties:
# /~https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
# This is a Lambda function config associated with the source code: app.ts
LambdaToSnsFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-LambdaToSns
Handler: src/app.handler
Runtime: nodejs20.x
Architectures:
- arm64
MemorySize: 128
Timeout: 30
Description: A Lambda function that sends a message to an SNS topic.
Events:
Api:
Type: Api
Properties:
Path: /
Method: POST
Environment:
Variables:
SNS_TOPIC_ARN: !Ref SnsTopic
Connectors:
SnsTopicConnector:
Properties:
Destination:
Id: SnsTopic
Permissions:
- Write
Metadata: # Manage esbuild properties
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: "es2020"
EntryPoints:
- src/app.ts
External: # Define external dependencies
- "@aws-sdk/*"
Outputs:
WebEndpoint:
Description: API Gateway endpoint URL for Prod stage
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"