Skip to content

Commit 475b963

Browse files
author
Justin
committed
lint
1 parent 4c0d3b1 commit 475b963

File tree

4 files changed

+96
-110
lines changed

4 files changed

+96
-110
lines changed

aws_sra_examples/solutions/shield_advanced/shield_advanced/lambda/src/app.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
88
SPDX-License-Identifier: MIT-0
99
"""
10+
1011
from __future__ import annotations
1112

1213
import logging
1314
import os
1415
import re
15-
from time import sleep
1616
from typing import TYPE_CHECKING, Any, Dict, Optional
1717

1818
import boto3
@@ -44,12 +44,11 @@
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

539536
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.
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

568565
def 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

aws_sra_examples/solutions/shield_advanced/shield_advanced/lambda/src/common.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
66
SPDX-License-Identifier: MIT-0
77
"""
8+
89
from __future__ import annotations
910

1011
import logging
1112
import os
12-
import re
1313
from time import sleep
1414
from typing import TYPE_CHECKING
1515

1616
import boto3
1717
from botocore.exceptions import ClientError, EndpointConnectionError
1818

1919
if TYPE_CHECKING:
20-
from mypy_boto3_iam.client import IAMClient
2120
from mypy_boto3_organizations import OrganizationsClient
2221
from mypy_boto3_ssm.client import SSMClient
2322
from mypy_boto3_sts.client import STSClient

0 commit comments

Comments
 (0)