-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda-with-api-gateway.yaml
More file actions
116 lines (104 loc) · 2.87 KB
/
lambda-with-api-gateway.yaml
File metadata and controls
116 lines (104 loc) · 2.87 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
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
109
110
111
112
113
114
115
116
---
AWSTemplateFormatVersion: '2010-09-09'
Description: HttpMaid AWS Lambda integration.
Parameters:
StackIdentifier:
Type: String
Description: Unique string to identify the stack
Resources:
############
## Lambda ##
############
FunctionRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub "${StackIdentifier}-FunctionRole"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
- PolicyName: !Sub "${StackIdentifier}-FunctionRolePolicy"
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- sts:AssumeRole
Resource: '*'
Effect: Allow
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Function:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "${StackIdentifier}-Deployment"
Code: "./target/demo-1.0-SNAPSHOT.jar"
Tags:
- Key: StackIdentifier
Value: !Ref StackIdentifier
MemorySize: 192
Handler: de.quantummaid.demo.infrastructure.Lambda::handleRequest
Role: !GetAtt FunctionRole.Arn
Timeout: 20
Runtime: java11
FunctionResourcePermission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:invokeFunction
Principal: apigateway.amazonaws.com
FunctionName: !Ref Function
################
## ApiGateway ##
################
HttpMaidApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: "HttpMaid Integration"
FailOnWarnings: true
ApiResource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref HttpMaidApi
ParentId: !GetAtt HttpMaidApi.RootResourceId
PathPart: "{path+}"
AnyMethod:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
HttpMethod: ANY
RestApiId: !Ref HttpMaidApi
ResourceId: !Ref ApiResource
ApiKeyRequired: false
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
PassthroughBehavior: WHEN_NO_MATCH
Uri:
Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${Function}/invocations"
ApiStage:
Type: AWS::ApiGateway::Stage
Properties:
DeploymentId: !Ref ApiDeployment
RestApiId: !Ref HttpMaidApi
StageName: !Ref StackIdentifier
ApiDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn: AnyMethod
Properties:
RestApiId: !Ref HttpMaidApi
Outputs:
Endpoint:
Value:
Fn::Join:
- ''
- - https://
- Ref: HttpMaidApi
- .execute-api.
- Ref: AWS::Region
- .amazonaws.com/
- Ref: ApiStage