Skip to content

Commit 60d49c7

Browse files
praneetapShreya
authored andcommitted
fix: dependency fixes for v20 (#1358)
1 parent 4e1d5d5 commit 60d49c7

15 files changed

+169
-121
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ test:
4444
@pytest --cov samtranslator --cov-report term-missing --cov-fail-under $(CODE_COVERAGE) tests
4545

4646
black:
47+
rm -f tests/*.pyc samtranslator/*.pyc
4748
black setup.py samtranslator/* tests/* bin/*
4849

4950
black-check:
51+
rm -f tests/*.pyc samtranslator/*.pyc
5052
black --check setup.py samtranslator/* tests/* bin/*
5153

5254
# Command to run everytime you make changes to verify everything works

samtranslator/model/api/api_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def _construct_api_domain(self, rest_api):
304304
basepath_mapping = ApiGatewayBasePathMapping(
305305
self.logical_id + "BasePathMapping", attributes=self.passthrough_resource_attributes
306306
)
307-
basepath_mapping.DomainName = self.domain.get("DomainName")
307+
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName"))
308308
basepath_mapping.RestApiId = ref(rest_api.logical_id)
309309
basepath_mapping.Stage = ref(rest_api.logical_id + ".Stage")
310310
basepath_resource_list.extend([basepath_mapping])
@@ -315,7 +315,7 @@ def _construct_api_domain(self, rest_api):
315315
basepath_mapping = ApiGatewayBasePathMapping(
316316
logical_id, attributes=self.passthrough_resource_attributes
317317
)
318-
basepath_mapping.DomainName = self.domain.get("DomainName")
318+
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName"))
319319
basepath_mapping.RestApiId = ref(rest_api.logical_id)
320320
basepath_mapping.Stage = ref(rest_api.logical_id + ".Stage")
321321
basepath_mapping.BasePath = path

samtranslator/model/sam_resources.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def to_cloudformation(self, **kwargs):
148148
if self.EventInvokeConfig:
149149
function_name = lambda_function.logical_id
150150
event_invoke_resources, event_invoke_policies = self._construct_event_invoke_config(
151-
function_name, alias_name, intrinsics_resolver, conditions
151+
function_name, alias_name, lambda_alias, intrinsics_resolver, conditions
152152
)
153153
resources.extend(event_invoke_resources)
154154

@@ -171,7 +171,7 @@ def to_cloudformation(self, **kwargs):
171171

172172
return resources
173173

174-
def _construct_event_invoke_config(self, function_name, lambda_alias, intrinsics_resolver, conditions):
174+
def _construct_event_invoke_config(self, function_name, alias_name, lambda_alias, intrinsics_resolver, conditions):
175175
"""
176176
Create a `AWS::Lambda::EventInvokeConfig` based on the input dict `EventInvokeConfig`
177177
"""
@@ -182,7 +182,14 @@ def _construct_event_invoke_config(self, function_name, lambda_alias, intrinsics
182182
resolved_event_invoke_config = intrinsics_resolver.resolve_parameter_refs(self.EventInvokeConfig)
183183

184184
logical_id = "{id}EventInvokeConfig".format(id=function_name)
185-
lambda_event_invoke_config = LambdaEventInvokeConfig(logical_id=logical_id, attributes=self.resource_attributes)
185+
if lambda_alias:
186+
lambda_event_invoke_config = LambdaEventInvokeConfig(
187+
logical_id=logical_id, depends_on=[lambda_alias.logical_id], attributes=self.resource_attributes
188+
)
189+
else:
190+
lambda_event_invoke_config = LambdaEventInvokeConfig(
191+
logical_id=logical_id, attributes=self.resource_attributes
192+
)
186193

187194
dest_config = {}
188195
input_dest_config = resolved_event_invoke_config.get("DestinationConfig")
@@ -209,8 +216,8 @@ def _construct_event_invoke_config(self, function_name, lambda_alias, intrinsics
209216
policy_document.append(policy)
210217

211218
lambda_event_invoke_config.FunctionName = ref(function_name)
212-
if lambda_alias:
213-
lambda_event_invoke_config.Qualifier = lambda_alias
219+
if alias_name:
220+
lambda_event_invoke_config.Qualifier = alias_name
214221
else:
215222
lambda_event_invoke_config.Qualifier = "$LATEST"
216223
lambda_event_invoke_config.DestinationConfig = dest_config

tests/translator/output/api_with_basic_custom_domain.json

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@
151151
"Type": "AWS::ApiGateway::BasePathMapping",
152152
"Properties": {
153153
"BasePath": "fetch",
154-
"DomainName": "api-example.com",
154+
"DomainName": {
155+
"Ref": "ApiGatewayDomainName23cdccdf9c"
156+
},
155157
"RestApiId": {
156158
"Ref": "MyApi"
157159
},
@@ -163,15 +165,6 @@
163165
"MyFunctionRole": {
164166
"Type": "AWS::IAM::Role",
165167
"Properties": {
166-
"ManagedPolicyArns": [
167-
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
168-
],
169-
"Tags": [
170-
{
171-
"Value": "SAM",
172-
"Key": "lambda:createdBy"
173-
}
174-
],
175168
"AssumeRolePolicyDocument": {
176169
"Version": "2012-10-17",
177170
"Statement": [
@@ -187,14 +180,25 @@
187180
}
188181
}
189182
]
190-
}
183+
},
184+
"ManagedPolicyArns": [
185+
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
186+
],
187+
"Tags": [
188+
{
189+
"Value": "SAM",
190+
"Key": "lambda:createdBy"
191+
}
192+
]
191193
}
192194
},
193195
"MyApigetBasePathMapping": {
194196
"Type": "AWS::ApiGateway::BasePathMapping",
195197
"Properties": {
196198
"BasePath": "get",
197-
"DomainName": "api-example.com",
199+
"DomainName": {
200+
"Ref": "ApiGatewayDomainName23cdccdf9c"
201+
},
198202
"RestApiId": {
199203
"Ref": "MyApi"
200204
},
@@ -246,7 +250,9 @@
246250
"MyAnotherApiBasePathMapping": {
247251
"Type": "AWS::ApiGateway::BasePathMapping",
248252
"Properties": {
249-
"DomainName": "another-example.com",
253+
"DomainName": {
254+
"Ref": "ApiGatewayDomainNameeab65c1531"
255+
},
250256
"RestApiId": {
251257
"Ref": "MyAnotherApi"
252258
},
@@ -301,7 +307,9 @@
301307
"ServerlessRestApiBasePathMapping": {
302308
"Type": "AWS::ApiGateway::BasePathMapping",
303309
"Properties": {
304-
"DomainName": "another-example.com",
310+
"DomainName": {
311+
"Ref": "ApiGatewayDomainNameeab65c1531"
312+
},
305313
"RestApiId": {
306314
"Ref": "ServerlessRestApi"
307315
},

tests/translator/output/api_with_basic_custom_domain_intrinsics.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"Properties": {
9797
"BasePath": "fetch",
9898
"DomainName": {
99-
"Fn::Sub": "example-ap-southeast-1.com"
99+
"Ref": "ApiGatewayDomainNamec0ed6fae34"
100100
},
101101
"RestApiId": {
102102
"Ref": "MyApi"
@@ -110,15 +110,6 @@
110110
"MyFunctionRole": {
111111
"Type": "AWS::IAM::Role",
112112
"Properties": {
113-
"ManagedPolicyArns": [
114-
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
115-
],
116-
"Tags": [
117-
{
118-
"Value": "SAM",
119-
"Key": "lambda:createdBy"
120-
}
121-
],
122113
"AssumeRolePolicyDocument": {
123114
"Version": "2012-10-17",
124115
"Statement": [
@@ -134,7 +125,16 @@
134125
}
135126
}
136127
]
137-
}
128+
},
129+
"ManagedPolicyArns": [
130+
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
131+
],
132+
"Tags": [
133+
{
134+
"Value": "SAM",
135+
"Key": "lambda:createdBy"
136+
}
137+
]
138138
},
139139
"Condition": "C1"
140140
},
@@ -143,7 +143,7 @@
143143
"Properties": {
144144
"BasePath": "get",
145145
"DomainName": {
146-
"Fn::Sub": "example-ap-southeast-1.com"
146+
"Ref": "ApiGatewayDomainNamec0ed6fae34"
147147
},
148148
"RestApiId": {
149149
"Ref": "MyApi"

tests/translator/output/api_with_custom_domain_route53.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@
112112
"Type": "AWS::ApiGateway::BasePathMapping",
113113
"Properties": {
114114
"BasePath": "one",
115-
"DomainName": "example.com",
115+
"DomainName": {
116+
"Ref": "ApiGatewayDomainName0caaf24ab1"
117+
},
116118
"RestApiId": {
117119
"Ref": "MyApi"
118120
},
@@ -136,15 +138,6 @@
136138
"MyFunctionRole": {
137139
"Type": "AWS::IAM::Role",
138140
"Properties": {
139-
"ManagedPolicyArns": [
140-
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
141-
],
142-
"Tags": [
143-
{
144-
"Value": "SAM",
145-
"Key": "lambda:createdBy"
146-
}
147-
],
148141
"AssumeRolePolicyDocument": {
149142
"Version": "2012-10-17",
150143
"Statement": [
@@ -160,7 +153,16 @@
160153
}
161154
}
162155
]
163-
}
156+
},
157+
"ManagedPolicyArns": [
158+
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
159+
],
160+
"Tags": [
161+
{
162+
"Value": "SAM",
163+
"Key": "lambda:createdBy"
164+
}
165+
]
164166
}
165167
},
166168
"MyApi": {

tests/translator/output/aws-cn/api_with_basic_custom_domain.json

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@
159159
"Type": "AWS::ApiGateway::BasePathMapping",
160160
"Properties": {
161161
"BasePath": "fetch",
162-
"DomainName": "api-example.com",
162+
"DomainName": {
163+
"Ref": "ApiGatewayDomainName23cdccdf9c"
164+
},
163165
"RestApiId": {
164166
"Ref": "MyApi"
165167
},
@@ -171,15 +173,6 @@
171173
"MyFunctionRole": {
172174
"Type": "AWS::IAM::Role",
173175
"Properties": {
174-
"ManagedPolicyArns": [
175-
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
176-
],
177-
"Tags": [
178-
{
179-
"Value": "SAM",
180-
"Key": "lambda:createdBy"
181-
}
182-
],
183176
"AssumeRolePolicyDocument": {
184177
"Version": "2012-10-17",
185178
"Statement": [
@@ -195,14 +188,25 @@
195188
}
196189
}
197190
]
198-
}
191+
},
192+
"ManagedPolicyArns": [
193+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
194+
],
195+
"Tags": [
196+
{
197+
"Value": "SAM",
198+
"Key": "lambda:createdBy"
199+
}
200+
]
199201
}
200202
},
201203
"MyApigetBasePathMapping": {
202204
"Type": "AWS::ApiGateway::BasePathMapping",
203205
"Properties": {
204206
"BasePath": "get",
205-
"DomainName": "api-example.com",
207+
"DomainName": {
208+
"Ref": "ApiGatewayDomainName23cdccdf9c"
209+
},
206210
"RestApiId": {
207211
"Ref": "MyApi"
208212
},
@@ -262,7 +266,9 @@
262266
"MyAnotherApiBasePathMapping": {
263267
"Type": "AWS::ApiGateway::BasePathMapping",
264268
"Properties": {
265-
"DomainName": "another-example.com",
269+
"DomainName": {
270+
"Ref": "ApiGatewayDomainNameeab65c1531"
271+
},
266272
"RestApiId": {
267273
"Ref": "MyAnotherApi"
268274
},
@@ -319,7 +325,9 @@
319325
"ServerlessRestApiBasePathMapping": {
320326
"Type": "AWS::ApiGateway::BasePathMapping",
321327
"Properties": {
322-
"DomainName": "another-example.com",
328+
"DomainName": {
329+
"Ref": "ApiGatewayDomainNameeab65c1531"
330+
},
323331
"RestApiId": {
324332
"Ref": "ServerlessRestApi"
325333
},

tests/translator/output/aws-cn/api_with_basic_custom_domain_intrinsics.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"Properties": {
6969
"BasePath": "fetch",
7070
"DomainName": {
71-
"Fn::Sub": "example-cn-north-1.com"
71+
"Ref": "ApiGatewayDomainNamec0cd2d9dfc"
7272
},
7373
"RestApiId": {
7474
"Ref": "MyApi"
@@ -116,15 +116,6 @@
116116
"MyFunctionRole": {
117117
"Type": "AWS::IAM::Role",
118118
"Properties": {
119-
"ManagedPolicyArns": [
120-
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
121-
],
122-
"Tags": [
123-
{
124-
"Value": "SAM",
125-
"Key": "lambda:createdBy"
126-
}
127-
],
128119
"AssumeRolePolicyDocument": {
129120
"Version": "2012-10-17",
130121
"Statement": [
@@ -140,7 +131,16 @@
140131
}
141132
}
142133
]
143-
}
134+
},
135+
"ManagedPolicyArns": [
136+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
137+
],
138+
"Tags": [
139+
{
140+
"Value": "SAM",
141+
"Key": "lambda:createdBy"
142+
}
143+
]
144144
},
145145
"Condition": "C1"
146146
},
@@ -149,7 +149,7 @@
149149
"Properties": {
150150
"BasePath": "get",
151151
"DomainName": {
152-
"Fn::Sub": "example-cn-north-1.com"
152+
"Ref": "ApiGatewayDomainNamec0cd2d9dfc"
153153
},
154154
"RestApiId": {
155155
"Ref": "MyApi"

0 commit comments

Comments
 (0)