-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
feature_toggle_api_open_api_version_override.yaml
166 lines (165 loc) · 5.34 KB
/
feature_toggle_api_open_api_version_override.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Transform:
- AWS::Serverless-2016-10-31
Resources:
ApiGatewayCognitoExecutionRole4F7CB5C8:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: apigateway.amazonaws.com
Version: '2012-10-17'
Policies:
- PolicyDocument:
Statement:
- Action: lambda:Invoke*
Effect: Allow
Resource:
Fn::GetAtt:
- LambdaFunction7804BD21
- Arn
Version: '2012-10-17'
PolicyName: apigInvokeLambda
LambdaFunctionServiceRoleD6E423C9:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: '2012-10-17'
ManagedPolicyArns:
- Fn::Join:
- ''
- - 'arn:'
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
LambdaFunctionServiceRoleDefaultPolicyF01A7EDC:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action: sns:Publish
Effect: Allow
Resource: '*'
Version: '2012-10-17'
PolicyName: LambdaFunctionServiceRoleDefaultPolicyF01A7EDC
Roles:
- Ref: LambdaFunctionServiceRoleD6E423C9
LambdaFunction7804BD21:
Type: AWS::Lambda::Function
Properties:
Code:
ZipFile: |
exports.handler = async (event, context, callback) => {
const auth = event.queryStringParameters.authorization
const policyDocument = {
Version: '2012-10-17',
Statement: [{
Action: 'execute-api:Invoke',
Effect: auth && auth.toLowerCase() === 'allow' ? 'Allow' : 'Deny',
Resource: event.methodArn
}]
}
return {
principalId: 'user',
context: {},
policyDocument
}
}
Role:
Fn::GetAtt:
- LambdaFunctionServiceRoleD6E423C9
- Arn
Handler: index.handler
Runtime: nodejs16.x
MyCognitoUserPool:
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: MyCognitoUserPool
ApiGatewayCognitoService15108F0B:
Type: AWS::Serverless::Api
Properties:
StageName: prod
Auth:
AddDefaultAuthorizerToCorsPreflight: false
Authorizers:
CognitoAuthorizer:
UserPoolArn:
Fn::GetAtt: MyCognitoUserPool.Arn
DefaultAuthorizer: CognitoAuthorizer
DefinitionBody:
openapi: 3.0.2
info:
title: RxtHofApprovalServiceLambdaCognito
version: '2018-05-10'
paths:
/reviews:
post:
operationId: CreateReview
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateReviewRequestContent'
required: true
responses:
'200':
description: CreateReview 200 response
headers:
Access-Control-Allow-Origin:
schema:
type: string
Access-Control-Expose-Headers:
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/CreateReviewResponseContent'
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri:
Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaFunction7804BD21.Arn}/invocations
credentials:
Fn::Sub: ${ApiGatewayCognitoExecutionRole4F7CB5C8.Arn}
responses:
default:
statusCode: '200'
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
method.response.header.Access-Control-Expose-Headers: "'Content-Length,Content-Type,X-Amzn-Errortype,X-Amzn-Requestid'"
components:
schemas:
CreateReviewRequestContent:
type: object
properties:
reviewId:
type: string
CreateReviewResponseContent:
type: object
properties:
reviewId:
type: string
securitySchemes:
aws.auth.sigv4:
type: apiKey
description: AWS Signature Version 4 authentication
name: Authorization
in: header
x-amazon-apigateway-authtype: awsSigv4
security:
- aws.auth.sigv4: []
x-amazon-apigateway-gateway-responses:
DEFAULT_5XX:
responseTemplates:
application/json: '{"message":$context.error.messageString}'
responseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
OpenApiVersion: '2.0'
TracingEnabled: true