Skip to content

Commit f02bc7b

Browse files
authored
Merge pull request #2 from rrakhmanto/develop
adjust lambda logical id resource name
2 parents 72a5248 + f47efd9 commit f02bc7b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ runtime: `python3.6`
5959

6060
Required parameters:
6161

62+
- `Name` - Custom Resource name.
6263
- `RegexPatterns` - List format, regex pattern to match.
6364
- `Type` - The part of the web request that you want AWS WAF to search for a specified string
6465
- `Data` - Data such as when the value of Type is HEADER , enter the name of the header that you want AWS WAF to search, for example, User-Agent or Referer

waf_regex/handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ def lambda_handler(event, context):
1616

1717
lambda_response = cr_response.CustomResourceResponse(event)
1818
cr_params = event['ResourceProperties']
19-
match_name = event['LogicalResourceId']
20-
waf_logic = WafRegexLogic(match_name , cr_params)
19+
waf_logic = WafRegexLogic(cr_params)
2120
try:
2221
# if create request, generate physical id, both for create/update copy files
2322
if event['RequestType'] == 'Create':

waf_regex/logic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
class WafRegexLogic:
1313

14-
def __init__(self, name, resource_properties):
14+
def __init__(self, resource_properties):
1515
self.regex_patterns = resource_properties['RegexPatterns']
1616
self.match_type = resource_properties['Type']
1717
self.match_data = resource_properties['Data']
1818
self.transform = resource_properties['Transform']
19-
self.match_name = name
20-
self.pattern_name = f"{name}-pattern"
19+
self.match_name = resource_properties['Name']
20+
self.pattern_name = f"{resource_properties['Name']}-pattern"
2121
self.client = boto3.client('waf-regional')
2222

2323
def new_pattern_set(self):

0 commit comments

Comments
 (0)