77Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
88SPDX-License-Identifier: MIT-0
99"""
10+
1011from __future__ import annotations
1112
1213import logging
1314import os
1415import re
15- from time import sleep
1616from typing import TYPE_CHECKING , Any , Dict , Optional
1717
1818import boto3
4444 raise ValueError ("Unexpected error executing Lambda function. Review CloudWatch logs for details." ) from None
4545
4646
47- def process_add_update_event (params : dict , regions : list , accounts : list ) -> None :
47+ def process_add_update_event (params : dict , accounts : list ) -> None :
4848 """Process Add or Update Events.
4949
5050 Args:
5151 params: Configuration Parameters
52- regions: list of regions
5352 accounts: list of accounts
5453
5554 Returns:
@@ -113,7 +112,7 @@ def parameter_pattern_validator(parameter_name: str, parameter_value: Optional[s
113112 return {parameter_name : parameter_value }
114113
115114
116- def get_validated_parameters (event : Dict [str , Any ]) -> dict :
115+ def get_validated_parameters (event : Dict [str , Any ]) -> dict : # noqa CFQ001
117116 """Validate AWS CloudFormation parameters.
118117
119118 Args:
@@ -127,7 +126,7 @@ def get_validated_parameters(event: Dict[str, Any]) -> dict:
127126 params ["action" ] = actions [event .get ("RequestType" , "Create" )]
128127 true_false_pattern = r"^true|false$"
129128 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
131130 protection_group_pattern_pattern = r"^(ALL|ARBITRARY|BY_RESOURCE_TYPE)?$|^$"
132131 protection_group_aggregation_pattern = r"^(SUM|MEAN|MAX)?$|^$"
133132 protection_group_members_pattern = r"^arn:aws:.*$|^$"
@@ -485,7 +484,6 @@ def teardown_shield_service(params: dict, accounts: list) -> None:
485484
486485 Args:
487486 params: Configuration Parameters
488- regions: list of regions
489487 accounts: list of accounts
490488 """
491489 if params ["SHIELD_ACCOUNTS_TO_PROTECT" ] == "ALL" :
@@ -514,7 +512,6 @@ def setup_shield_global(params: dict, accounts: list) -> None:
514512 params: environment variables
515513 accounts: list of accounts
516514 """
517-
518515 LOGGER .info ("Params \n " )
519516 LOGGER .info (params )
520517 if params ["SHIELD_ACCOUNTS_TO_PROTECT" ] == "ALL" :
@@ -537,7 +534,7 @@ def setup_shield_global(params: dict, accounts: list) -> None:
537534
538535
539536def 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.
541538
542539 Args:
543540 account_session: boto3 session
@@ -566,7 +563,7 @@ def teardown_shield(account_session: boto3.Session, account_id: str, params: dic
566563
567564
568565def setup_shield (account_session : boto3 .Session , account_id : str , params : dict ) -> None :
569- """Setup shield service for the account .
566+ """Configure shield service.
570567
571568 Args:
572569 account_session: boto3 session
0 commit comments