Skip to content

Commit e7c4117

Browse files
authored
chore: merge release/v1.13.2 into master
2 parents 9812d1d + 1dd787f commit e7c4117

30 files changed

+448
-440
lines changed

samtranslator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.13.1'
1+
__version__ = '1.13.2'

samtranslator/model/api/api_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def _construct_stage(self, deployment, swagger):
193193
stage.TracingEnabled = self.tracing_enabled
194194

195195
if swagger is not None:
196-
deployment.make_auto_deployable(stage, swagger)
196+
deployment.make_auto_deployable(stage, self.open_api_version, swagger)
197197

198198
return stage
199199

samtranslator/model/apigateway.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class ApiGatewayAccount(Resource):
6161

6262

6363
class ApiGatewayDeployment(Resource):
64+
_X_HASH_DELIMITER = "||"
65+
6466
resource_type = 'AWS::ApiGateway::Deployment'
6567
property_types = {
6668
'Description': PropertyType(False, is_str()),
@@ -73,9 +75,10 @@ class ApiGatewayDeployment(Resource):
7375
"deployment_id": lambda self: ref(self.logical_id),
7476
}
7577

76-
def make_auto_deployable(self, stage, swagger=None):
78+
def make_auto_deployable(self, stage, openapi_version=None, swagger=None):
7779
"""
78-
Sets up the resource such that it will triggers a re-deployment when Swagger changes
80+
Sets up the resource such that it will trigger a re-deployment when Swagger changes
81+
or the openapi version changes.
7982
8083
:param swagger: Dictionary containing the Swagger definition of the API
8184
"""
@@ -88,10 +91,15 @@ def make_auto_deployable(self, stage, swagger=None):
8891
# to prevent redeployment when API has not changed
8992

9093
# NOTE: `str(swagger)` is for backwards compatibility. Changing it to a JSON or something will break compat
91-
generator = logical_id_generator.LogicalIdGenerator(self.logical_id, str(swagger))
94+
hash_input = [str(swagger)]
95+
if openapi_version:
96+
hash_input.append(str(openapi_version))
97+
98+
data = self._X_HASH_DELIMITER.join(hash_input)
99+
generator = logical_id_generator.LogicalIdGenerator(self.logical_id, data)
92100
self.logical_id = generator.gen()
93-
hash = generator.get_hash(length=40) # Get the full hash
94-
self.Description = "RestApi deployment id: {}".format(hash)
101+
digest = generator.get_hash(length=40) # Get the full hash
102+
self.Description = "RestApi deployment id: {}".format(digest)
95103
stage.update_deployment_ref(self.logical_id)
96104

97105

tests/translator/output/api_request_model_openapi_3.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
}
2222
}
2323
},
24+
"HtmlApiDeploymentefb667b26e": {
25+
"Type": "AWS::ApiGateway::Deployment",
26+
"Properties": {
27+
"RestApiId": {
28+
"Ref": "HtmlApi"
29+
},
30+
"Description": "RestApi deployment id: efb667b26e8a0b0f733f5dfc27d039c1a2867db0"
31+
}
32+
},
2433
"HtmlFunctionRole": {
2534
"Type": "AWS::IAM::Role",
2635
"Properties": {
@@ -49,7 +58,7 @@
4958
"Type": "AWS::ApiGateway::Stage",
5059
"Properties": {
5160
"DeploymentId": {
52-
"Ref": "HtmlApiDeployment47f78fe7d9"
61+
"Ref": "HtmlApiDeploymentefb667b26e"
5362
},
5463
"RestApiId": {
5564
"Ref": "HtmlApi"
@@ -164,15 +173,6 @@
164173
}
165174
}
166175
},
167-
"HtmlApiDeployment47f78fe7d9": {
168-
"Type": "AWS::ApiGateway::Deployment",
169-
"Properties": {
170-
"RestApiId": {
171-
"Ref": "HtmlApi"
172-
},
173-
"Description": "RestApi deployment id: 47f78fe7d91eb5d2070674ad77943842c49dab89"
174-
}
175-
},
176176
"HtmlFunctionGetHtmlPermissionTest": {
177177
"Type": "AWS::Lambda::Permission",
178178
"Properties": {

tests/translator/output/api_with_auth_all_maximum_openapi_3.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@
104104
}
105105
}
106106
},
107+
"MyApiDeployment7d5eb3f14f": {
108+
"Type": "AWS::ApiGateway::Deployment",
109+
"Properties": {
110+
"RestApiId": {
111+
"Ref": "MyApi"
112+
},
113+
"Description": "RestApi deployment id: 7d5eb3f14f891b4276d48b764348b944dcaf2918"
114+
}
115+
},
107116
"MyFunctionWithCognitoMultipleUserPoolsAuthorizerPermissionProd": {
108117
"Type": "AWS::Lambda::Permission",
109118
"Properties": {
@@ -453,20 +462,11 @@
453462
}
454463
}
455464
},
456-
"MyApiDeployment18e0cddfbf": {
457-
"Type": "AWS::ApiGateway::Deployment",
458-
"Properties": {
459-
"RestApiId": {
460-
"Ref": "MyApi"
461-
},
462-
"Description": "RestApi deployment id: 18e0cddfbf74ca986461d5a484b9eedd934a6423"
463-
}
464-
},
465465
"MyApiProdStage": {
466466
"Type": "AWS::ApiGateway::Stage",
467467
"Properties": {
468468
"DeploymentId": {
469-
"Ref": "MyApiDeployment18e0cddfbf"
469+
"Ref": "MyApiDeployment7d5eb3f14f"
470470
},
471471
"RestApiId": {
472472
"Ref": "MyApi"

tests/translator/output/api_with_auth_all_minimum_openapi.json

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"Type": "AWS::ApiGateway::Stage",
5959
"Properties": {
6060
"DeploymentId": {
61-
"Ref": "MyApiWithLambdaRequestAuthDeployment54a6335ed7"
61+
"Ref": "MyApiWithLambdaRequestAuthDeployment14ab3ddf12"
6262
},
6363
"RestApiId": {
6464
"Ref": "MyApiWithLambdaRequestAuth"
@@ -131,13 +131,25 @@
131131
}
132132
}
133133
},
134-
"MyApiWithLambdaTokenAuthDeployment2ac4484273": {
135-
"Type": "AWS::ApiGateway::Deployment",
134+
"MyFnCognitoPermissionTest": {
135+
"Type": "AWS::Lambda::Permission",
136136
"Properties": {
137-
"RestApiId": {
138-
"Ref": "MyApiWithLambdaTokenAuth"
137+
"Action": "lambda:invokeFunction",
138+
"Principal": "apigateway.amazonaws.com",
139+
"FunctionName": {
140+
"Ref": "MyFn"
139141
},
140-
"Description": "RestApi deployment id: 2ac4484273f55c601b17c8491ffad73a979b2aeb"
142+
"SourceArn": {
143+
"Fn::Sub": [
144+
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/cognito",
145+
{
146+
"__Stage__": "*",
147+
"__ApiId__": {
148+
"Ref": "MyApiWithCognitoAuth"
149+
}
150+
}
151+
]
152+
}
141153
}
142154
},
143155
"MyAuthFn": {
@@ -163,15 +175,6 @@
163175
]
164176
}
165177
},
166-
"MyApiWithCognitoAuthDeployment2eadfec019": {
167-
"Type": "AWS::ApiGateway::Deployment",
168-
"Properties": {
169-
"RestApiId": {
170-
"Ref": "MyApiWithCognitoAuth"
171-
},
172-
"Description": "RestApi deployment id: 2eadfec019d342cb7f6d66f595b9ab88e82fa00a"
173-
}
174-
},
175178
"MyFnRole": {
176179
"Type": "AWS::IAM::Role",
177180
"Properties": {
@@ -196,11 +199,20 @@
196199
}
197200
}
198201
},
202+
"MyApiWithLambdaRequestAuthDeployment14ab3ddf12": {
203+
"Type": "AWS::ApiGateway::Deployment",
204+
"Properties": {
205+
"RestApiId": {
206+
"Ref": "MyApiWithLambdaRequestAuth"
207+
},
208+
"Description": "RestApi deployment id: 14ab3ddf12ee76d46cac076ecffc24b3acd2fb7f"
209+
}
210+
},
199211
"MyApiWithCognitoAuthProdStage": {
200212
"Type": "AWS::ApiGateway::Stage",
201213
"Properties": {
202214
"DeploymentId": {
203-
"Ref": "MyApiWithCognitoAuthDeployment2eadfec019"
215+
"Ref": "MyApiWithCognitoAuthDeployment87cdbda651"
204216
},
205217
"RestApiId": {
206218
"Ref": "MyApiWithCognitoAuth"
@@ -229,36 +241,6 @@
229241
}
230242
}
231243
},
232-
"MyApiWithLambdaRequestAuthDeployment54a6335ed7": {
233-
"Type": "AWS::ApiGateway::Deployment",
234-
"Properties": {
235-
"RestApiId": {
236-
"Ref": "MyApiWithLambdaRequestAuth"
237-
},
238-
"Description": "RestApi deployment id: 54a6335ed76c2060eaf1fff2ff6522f20ecaef0f"
239-
}
240-
},
241-
"MyUserPool": {
242-
"Type": "AWS::Cognito::UserPool",
243-
"Properties": {
244-
"UsernameAttributes": [
245-
"email"
246-
],
247-
"UserPoolName": "UserPoolName",
248-
"Policies": {
249-
"PasswordPolicy": {
250-
"MinimumLength": 8
251-
}
252-
},
253-
"Schema": [
254-
{
255-
"AttributeDataType": "String",
256-
"Required": false,
257-
"Name": "email"
258-
}
259-
]
260-
}
261-
},
262244
"MyApiWithLambdaRequestAuthMyLambdaRequestAuthAuthorizerPermission": {
263245
"Type": "AWS::Lambda::Permission",
264246
"Properties": {
@@ -383,25 +365,25 @@
383365
}
384366
}
385367
},
386-
"MyFnCognitoPermissionTest": {
387-
"Type": "AWS::Lambda::Permission",
368+
"MyUserPool": {
369+
"Type": "AWS::Cognito::UserPool",
388370
"Properties": {
389-
"Action": "lambda:invokeFunction",
390-
"Principal": "apigateway.amazonaws.com",
391-
"FunctionName": {
392-
"Ref": "MyFn"
371+
"UsernameAttributes": [
372+
"email"
373+
],
374+
"UserPoolName": "UserPoolName",
375+
"Policies": {
376+
"PasswordPolicy": {
377+
"MinimumLength": 8
378+
}
393379
},
394-
"SourceArn": {
395-
"Fn::Sub": [
396-
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/cognito",
397-
{
398-
"__Stage__": "*",
399-
"__ApiId__": {
400-
"Ref": "MyApiWithCognitoAuth"
401-
}
402-
}
403-
]
404-
}
380+
"Schema": [
381+
{
382+
"AttributeDataType": "String",
383+
"Required": false,
384+
"Name": "email"
385+
}
386+
]
405387
}
406388
},
407389
"MyFn": {
@@ -455,14 +437,23 @@
455437
"Type": "AWS::ApiGateway::Stage",
456438
"Properties": {
457439
"DeploymentId": {
458-
"Ref": "MyApiWithLambdaTokenAuthDeployment2ac4484273"
440+
"Ref": "MyApiWithLambdaTokenAuthDeployment4fdb5f4e3c"
459441
},
460442
"RestApiId": {
461443
"Ref": "MyApiWithLambdaTokenAuth"
462444
},
463445
"StageName": "Prod"
464446
}
465447
},
448+
"MyApiWithCognitoAuthDeployment87cdbda651": {
449+
"Type": "AWS::ApiGateway::Deployment",
450+
"Properties": {
451+
"RestApiId": {
452+
"Ref": "MyApiWithCognitoAuth"
453+
},
454+
"Description": "RestApi deployment id: 87cdbda651523df8d04d15fc50f72ae8ead08c1d"
455+
}
456+
},
466457
"MyApiWithLambdaRequestAuth": {
467458
"Type": "AWS::ApiGateway::RestApi",
468459
"Properties": {
@@ -522,6 +513,15 @@
522513
}
523514
}
524515
}
516+
},
517+
"MyApiWithLambdaTokenAuthDeployment4fdb5f4e3c": {
518+
"Type": "AWS::ApiGateway::Deployment",
519+
"Properties": {
520+
"RestApiId": {
521+
"Ref": "MyApiWithLambdaTokenAuth"
522+
},
523+
"Description": "RestApi deployment id: 4fdb5f4e3c6e0e2b12af6d7a637ce66bb5bf7d0a"
524+
}
525525
}
526526
}
527527
}

tests/translator/output/api_with_cors_openapi_3.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
"Type": "AWS::ApiGateway::Stage",
254254
"Properties": {
255255
"DeploymentId": {
256-
"Ref": "ServerlessRestApiDeployment36174ded39"
256+
"Ref": "ServerlessRestApiDeploymentf0997bcd64"
257257
},
258258
"RestApiId": {
259259
"Ref": "ServerlessRestApi"
@@ -265,7 +265,7 @@
265265
"Type": "AWS::ApiGateway::Stage",
266266
"Properties": {
267267
"DeploymentId": {
268-
"Ref": "ExplicitApiDeployment3a5a78688c"
268+
"Ref": "ExplicitApiDeployment8cc53ffaa5"
269269
},
270270
"RestApiId": {
271271
"Ref": "ExplicitApi"
@@ -318,13 +318,22 @@
318318
}
319319
}
320320
},
321-
"ExplicitApiDeployment3a5a78688c": {
321+
"ExplicitApiDeployment8cc53ffaa5": {
322322
"Type": "AWS::ApiGateway::Deployment",
323323
"Properties": {
324324
"RestApiId": {
325325
"Ref": "ExplicitApi"
326326
},
327-
"Description": "RestApi deployment id: 3a5a78688c9bc377d53aa4153a11f0c4f6e7364c"
327+
"Description": "RestApi deployment id: 8cc53ffaa59a19b69e73d5b422142c7396739b16"
328+
}
329+
},
330+
"ServerlessRestApiDeploymentf0997bcd64": {
331+
"Type": "AWS::ApiGateway::Deployment",
332+
"Properties": {
333+
"RestApiId": {
334+
"Ref": "ServerlessRestApi"
335+
},
336+
"Description": "RestApi deployment id: f0997bcd645ceb1529586bc2b9faf855687b46ce"
328337
}
329338
},
330339
"RestApiFunction": {
@@ -350,15 +359,6 @@
350359
]
351360
}
352361
},
353-
"ServerlessRestApiDeployment36174ded39": {
354-
"Type": "AWS::ApiGateway::Deployment",
355-
"Properties": {
356-
"RestApiId": {
357-
"Ref": "ServerlessRestApi"
358-
},
359-
"Description": "RestApi deployment id: 36174ded3978092f96669107074db6caeaaafddd"
360-
}
361-
},
362362
"ServerlessRestApi": {
363363
"Type": "AWS::ApiGateway::RestApi",
364364
"Properties": {

0 commit comments

Comments
 (0)