-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathtemplate.yaml
100 lines (92 loc) · 2.78 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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: aws-lambda-unit-test-example
Description: AWS Serverless - AWS Lambda Test Demonstration
Author: W. Thomas Romano & Kevin Hakanson
Labels: ['lambda', 'dynamodb', 's3', 'test', 'apigw']
Resources:
SampleBucket:
Type: AWS::S3::Bucket
UpdateReplacePolicy: Delete
Properties:
BucketName:
!Sub "${AWS::StackName}-${AWS::AccountId}"
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
VersioningConfiguration:
Status: Enabled
Metadata:
SamResourceId: SampleBucket
SampleTable:
Type: AWS::DynamoDB::Table
UpdateReplacePolicy: Delete
Properties:
AttributeDefinitions:
- AttributeName: PK
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: PK
KeyType: HASH
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
SSESpecification:
SSEEnabled: true
Metadata:
SamResourceId: SampleTable
SampleLambda:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./src/sample_lambda/
Handler: app.lambda_handler
Runtime: python3.9
MemorySize: 256
Architectures:
- arm64
Environment:
Variables:
DYNAMODB_TABLE_NAME:
Ref: SampleTable
S3_BUCKET_NAME:
Ref: SampleBucket
ReservedConcurrentExecutions: 1
Policies:
- S3WritePolicy:
BucketName: !Ref SampleBucket
- DynamoDBReadPolicy:
TableName: !Ref SampleTable
Events:
HttpPost:
Type: Api
Properties:
Path: '/SampleLambda/{docType}/{customerId}'
Method: post
Metadata:
SamResourceId: SampleLambda
Outputs:
oLambdaFunction:
Description: AWS Lambda Function
Value:
Ref: SampleLambda
oS3Bucket:
Description: Amazon S3 Bucket, destination for document files created by the AWS Lambda Function.
Value:
Ref: SampleBucket
oDDBTable:
Description: Amazon DynamoDB Table, manually add data to this table as needed.
Value:
Ref: SampleTable
oAPIEndpoint:
Description: API URL endpoint for triggering the sample document creation service.
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/SampleLambda/{docType}/{customerId}"