/
connector_api_to_function.yaml
108 lines (97 loc) · 2.41 KB
/
connector_api_to_function.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
Resources:
MyServerlessApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
MyHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: Prod
MyApiGateway:
Type: AWS::ApiGateway::RestApi
Properties:
Description: A test API
Name: MyRestAPI
MyApiGatewayRootMethod:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
HttpMethod: POST
Integration:
Type: MOCK
ResourceId: !GetAtt MyApiGateway.RootResourceId
RestApiId: !Ref MyApiGateway
MyApiGatewayV2:
Type: AWS::ApiGatewayV2::Api
Properties:
Name: MyApi
ProtocolType: WEBSOCKET
MyServerlessFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs18.x
Handler: index.handler
InlineCode: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
MyRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Action: sts:AssumeRole
Principal:
Service: lambda.amazonaws.com
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
MyFunction:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt MyRole.Arn
Runtime: nodejs18.x
Handler: index.handler
Code:
ZipFile: |
const AWS = require('aws-sdk');
exports.handler = async (event) => {
console.log(JSON.stringify(event));
};
MyConnectorServerlessApiToLambda:
Type: AWS::Serverless::Connector
Properties:
Source:
Id: MyServerlessApi
Destination:
Id: MyFunction
Permissions:
- Write
MyConnectorApigwToLambda:
Type: AWS::Serverless::Connector
Properties:
Source:
Id: MyApiGateway
Destination:
Id: MyServerlessFunction
Permissions:
- Write
MyConnectorApiV2ToLambda:
Type: AWS::Serverless::Connector
Properties:
Source:
Id: MyApiGatewayV2
Destination:
Id: MyServerlessFunction
Permissions:
- Write
MyConnectorServerlessHttpApiToLambda:
Type: AWS::Serverless::Connector
Properties:
Source:
Id: MyHttpApi
Destination:
Id: MyFunction
Permissions:
- Write