-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
85 lines (83 loc) · 2.69 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
A simple AWS Lambda implementing CRUD over NewsItems
Globals:
Api:
TracingEnabled: true
Cors:
AllowOrigin: "'*'"
AllowHeaders: "'Content-Type'"
MaxAge: "'300'"
BinaryMediaTypes: # see Binary responses section
- "*~1*" # converts to */* for any binary type
Function:
Timeout: 5
Layers: #
- !Sub arn:aws:lambda:${AWS::Region}:017000801446:layer:AWSLambdaPowertoolsPython:29
Resources:
NewsCRUDFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https:l//github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
Role: !GetAtt NewsCRUDFunctionIamRole.Arn
CodeUri: news_api/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
Events:
NewsList:
Type: Api
Properties:
Path: /news
Method: get
NewsAdd:
Type: Api
Properties:
Path: /newsitem
Method: post
VpcConfig:
SecurityGroupIds:
- sg-07e896e930f4faaf8
SubnetIds:
- subnet-0ea454e1c9763475e
- subnet-0db7b016948f4bab7
- subnet-0f46ac4997897811f
NewsCRUDFunctionIamRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- "secretsmanager:GetResourcePolicy"
- "secretsmanager:GetSecretValue"
- "secretsmanager:DescribeSecret"
- "secretsmanager:ListSecretVersionIds"
Resource: arn:aws:secretsmanager:eu-west-2:159421668328:secret:documentDB-d3KKGq
- "Effect": "Allow"
"Action": "secretsmanager:ListSecrets"
"Resource": "*"
Outputs:
NewsCRUDApi:
Description: "API Gateway endpoint URL for Prod stage for News CRUD function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
NewsCRUDFunction:
Description: "News CRUD Lambda Function ARN"
Value: !GetAtt NewsCRUDFunction.Arn
NewsCRUDFunctionIamRole:
Description: "Implicit IAM Role created for News CRUD function"
Value: !GetAtt NewsCRUDFunctionIamRole.Arn