7
7
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8
8
SPDX-License-Identifier: MIT-0
9
9
"""
10
+
10
11
from __future__ import annotations
11
12
12
13
import logging
13
14
import os
14
15
import re
15
- from time import sleep
16
16
from typing import TYPE_CHECKING , Any , Dict , Optional
17
17
18
18
import boto3
44
44
raise ValueError ("Unexpected error executing Lambda function. Review CloudWatch logs for details." ) from None
45
45
46
46
47
- def process_add_update_event (params : dict , regions : list , accounts : list ) -> None :
47
+ def process_add_update_event (params : dict , accounts : list ) -> None :
48
48
"""Process Add or Update Events.
49
49
50
50
Args:
51
51
params: Configuration Parameters
52
- regions: list of regions
53
52
accounts: list of accounts
54
53
55
54
Returns:
@@ -113,7 +112,7 @@ def parameter_pattern_validator(parameter_name: str, parameter_value: Optional[s
113
112
return {parameter_name : parameter_value }
114
113
115
114
116
- def get_validated_parameters (event : Dict [str , Any ]) -> dict :
115
+ def get_validated_parameters (event : Dict [str , Any ]) -> dict : # noqa CFQ001
117
116
"""Validate AWS CloudFormation parameters.
118
117
119
118
Args:
@@ -127,7 +126,7 @@ def get_validated_parameters(event: Dict[str, Any]) -> dict:
127
126
params ["action" ] = actions [event .get ("RequestType" , "Create" )]
128
127
true_false_pattern = r"^true|false$"
129
128
protection_group_id_pattern = r"^[a-zA-Z0-9]{0,64}$|^$"
130
- protection_group_resource_type_pattern = r"^(CLOUDFRONT_DISTRIBUTION|ROUTE_53_HOSTED_ZONE|ELASTIC_IP_ALLOCATION|CLASSIC_LOAD_BALANCER|APPLICATION_LOAD_BALANCER|GLOBAL_ACCELERATOR)?$|^$"
129
+ protection_group_resource_type_pattern = r"^(CLOUDFRONT_DISTRIBUTION|ROUTE_53_HOSTED_ZONE|ELASTIC_IP_ALLOCATION|CLASSIC_LOAD_BALANCER|APPLICATION_LOAD_BALANCER|GLOBAL_ACCELERATOR)?$|^$" # noqa
131
130
protection_group_pattern_pattern = r"^(ALL|ARBITRARY|BY_RESOURCE_TYPE)?$|^$"
132
131
protection_group_aggregation_pattern = r"^(SUM|MEAN|MAX)?$|^$"
133
132
protection_group_members_pattern = r"^arn:aws:.*$|^$"
@@ -485,7 +484,6 @@ def teardown_shield_service(params: dict, accounts: list) -> None:
485
484
486
485
Args:
487
486
params: Configuration Parameters
488
- regions: list of regions
489
487
accounts: list of accounts
490
488
"""
491
489
if params ["SHIELD_ACCOUNTS_TO_PROTECT" ] == "ALL" :
@@ -514,7 +512,6 @@ def setup_shield_global(params: dict, accounts: list) -> None:
514
512
params: environment variables
515
513
accounts: list of accounts
516
514
"""
517
-
518
515
LOGGER .info ("Params \n " )
519
516
LOGGER .info (params )
520
517
if params ["SHIELD_ACCOUNTS_TO_PROTECT" ] == "ALL" :
@@ -537,7 +534,7 @@ def setup_shield_global(params: dict, accounts: list) -> None:
537
534
538
535
539
536
def teardown_shield (account_session : boto3 .Session , account_id : str , params : dict ) -> None :
540
- """removes the shield configurations but does not cancel the subscription
537
+ """Remove shield configuration.
541
538
542
539
Args:
543
540
account_session: boto3 session
@@ -566,7 +563,7 @@ def teardown_shield(account_session: boto3.Session, account_id: str, params: dic
566
563
567
564
568
565
def setup_shield (account_session : boto3 .Session , account_id : str , params : dict ) -> None :
569
- """Setup shield service for the account .
566
+ """Configure shield service.
570
567
571
568
Args:
572
569
account_session: boto3 session
0 commit comments