-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
80 lines (77 loc) · 2.29 KB
/
template.yaml
File metadata and controls
80 lines (77 loc) · 2.29 KB
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
Transform: AWS::Serverless-2016-10-31
Description: |
API Gateway that exposes a path to a Lambda function that connects to PostgreSQL on Aurora DSQL
Resources:
DSQLFunction:
Type: AWS::Serverless::Function
Properties:
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: DSQLFunction
CodeUri: src/Function
Handler: handler.handler
Runtime: python3.13
MemorySize: 128
Timeout: 5
Tracing: Active
Policies:
- Statement:
- Effect: Allow
Action:
- dsql:DbConnectAdmin
Resource:
- !Sub arn:${AWS::Partition}:dsql:${AWS::Region}:${AWS::AccountId}:cluster/${DSQL}
Architectures:
- arm64 #Lambda functions will run on Arm-based AWS Graviton processors.
Environment:
Variables:
REGION: !Sub ${AWS::Region}
cluster_endpoint: !Sub ${DSQL}.dsql.${AWS::Region}.on.aws
LoggingConfig:
LogGroup: !Sub /aws/lambda/${AWS::StackName}
LogFormat: JSON
Tags:
project: apigw-lambda-dsql
Events:
UsersApiGETusers:
Type: Api
Properties:
Path: /users
Method: GET
RestApiId: !Ref UsersApi
DSQLFunctionLogGroup:
Type: AWS::Logs::LogGroup
DeletionPolicy: Retain
Properties:
LogGroupName: !Sub /aws/lambda/${DSQLFunction}
UsersApi:
Type: AWS::Serverless::Api
Properties:
Name: !Sub
- ${ResourceName} From Stack ${AWS::StackName}
- ResourceName: UsersApi
StageName: Prod
DefinitionBody:
openapi: '3.0'
info: {}
paths:
/users:
get:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DSQLFunction.Arn}/invocations
responses: {}
EndpointConfiguration: REGIONAL
TracingEnabled: true
Cors:
MaxAge: 5
Tags:
project: apigw-lambda-dsql
DSQL:
Type: AWS::DSQL::Cluster
Properties:
DeletionProtectionEnabled: false
Tags:
- Key: project
Value: "apigw-lambda-dsql"