Skip to content

Commit e528bf2

Browse files
author
Connor Robertson
authored
Fix: Raise Error When UpdateReplacePolicy is not correctly defined. (#3392)
1 parent 3e3b498 commit e528bf2

File tree

5 files changed

+1291
-4
lines changed

5 files changed

+1291
-4
lines changed

samtranslator/plugins/api/implicit_api_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ def _update_resource_attributes_from_api_event( # noqa: PLR0913
496496
method_conditions = api_dict_condition.setdefault(path, {})
497497
method_conditions[method] = condition
498498

499-
api_dict_deletion = self.api_deletion_policies.setdefault(api_id, set())
500-
api_dict_deletion.add(deletion_policy)
499+
api_dict_deletion = self.api_deletion_policies.setdefault(api_id, [])
500+
api_dict_deletion.append(deletion_policy)
501501

502-
api_dict_update_replace = self.api_update_replace_policies.setdefault(api_id, set())
503-
api_dict_update_replace.add(update_replace_policy)
502+
api_dict_update_replace = self.api_update_replace_policies.setdefault(api_id, [])
503+
api_dict_update_replace.append(update_replace_policy)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform:
3+
- AWS::LanguageExtensions
4+
- AWS::Serverless-2016-10-31
5+
6+
Resources:
7+
MyFunction:
8+
Type: AWS::Serverless::Function
9+
UpdateReplacePolicy: Delete
10+
Properties:
11+
Handler: LambdaASP.NETCoreWebAPI2::LambdaASP.NETCoreWebAPI2.LambdaEntryPoint::FunctionHandlerAsync
12+
Runtime: dotnet6
13+
CodeUri: s3://bucket/key
14+
Events:
15+
None:
16+
Type: Api
17+
Properties:
18+
Method: get
19+
Path: /method
20+
MyFunction2:
21+
Type: AWS::Serverless::Function
22+
UpdateReplacePolicy: Delete
23+
Properties:
24+
Handler: LambdaASP.NETCoreWebAPI2::LambdaASP.NETCoreWebAPI2.LambdaEntryPoint::FunctionHandlerAsync
25+
Runtime: dotnet6
26+
CodeUri: s3://bucket/key
27+
Events:
28+
Hi:
29+
Type: Api
30+
Properties:
31+
Method: post
32+
Path: /method
33+
MyFunction3:
34+
Type: AWS::Serverless::Function
35+
DeletionPolicy: Delete
36+
Properties:
37+
Handler: LambdaASP.NETCoreWebAPI2::LambdaASP.NETCoreWebAPI2.LambdaEntryPoint::FunctionHandlerAsync
38+
Runtime: dotnet6
39+
CodeUri: s3://bucket/key
40+
Events:
41+
All:
42+
Type: Api
43+
Properties:
44+
Method: get
45+
Path: /method2
46+
MyFunction4:
47+
Type: AWS::Serverless::Function
48+
DeletionPolicy: Retain
49+
UpdateReplacePolicy: Retain
50+
Properties:
51+
Handler: LambdaASP.NETCoreWebAPI2::LambdaASP.NETCoreWebAPI2.LambdaEntryPoint::FunctionHandlerAsync
52+
Runtime: dotnet6
53+
CodeUri: s3://bucket/key
54+
Events:
55+
Bye:
56+
Type: Api
57+
Properties:
58+
Method: post
59+
Path: /method2

0 commit comments

Comments
 (0)