Skip to content

Commit 3c55cee

Browse files
committed
chore: Change conditionals
1 parent eecae25 commit 3c55cee

18 files changed

Lines changed: 39 additions & 39 deletions

File tree

layer/python/cloudtrail_watcher/services/airflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def _set_mandatory_tag(event: dict):
99
""" Set mandatory tag for MWAA(Managed Workflow for Apache Airflow) resources. """
1010

1111
if 'Tags' in event['requestParameters'].keys():
12-
if check_contain_mandatory_tag_dict(event['requestParameters']['tags']) is True:
12+
if check_contain_mandatory_tag_dict(event['requestParameters']['tags']):
1313
return
1414

1515
resource_arn = event['responseElements']['Arn']
@@ -24,7 +24,7 @@ def _set_mandatory_tag(event: dict):
2424

2525
def _process_create_environment(event: dict, set_tag: bool = False) -> list:
2626

27-
if set_tag is True:
27+
if set_tag:
2828
_set_mandatory_tag(event)
2929

3030
return [event['requestParameters']['Name']]

layer/python/cloudtrail_watcher/services/cloudfront.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ def _process_create_distribution(event: dict, set_tag: bool = False) -> list:
1111

1212
distribution_arn = event['responseElements']['distribution']['aRN']
1313

14-
if set_tag is True:
14+
if set_tag:
1515
tags = cloudfront.list_tags_for_resource(Resource=distribution_arn)
1616

1717
exists_mandatory_tag = check_contain_mandatory_tag_list(tags['Tags']['Items'])
1818

19-
if exists_mandatory_tag is False:
19+
if not exists_mandatory_tag:
2020
cloudfront.tag_resource(Resource=distribution_arn,
2121
Tags={'Items': [{
2222
'Key': 'User',

layer/python/cloudtrail_watcher/services/dynamodb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def _process_create_table(event: dict, set_tag: bool = False) -> list:
1919

2020
resource_ids = [event['responseElements']['tableDescription']['tableName']]
2121

22-
if set_tag is True:
22+
if set_tag:
2323
has_user_tags = False
2424

2525
# Check tags
2626
if 'tags' in event['requestParameters'].keys():
2727
has_user_tags = check_contain_mandatory_tag_list(event['requestParameters']['tags'])
2828

2929
# If mandatory tags are not set, set mandatory tags
30-
if has_user_tags is False:
30+
if not has_user_tags:
3131
dynamodb.tag_resource(
3232
ResourceArn=event['responseElements']['tableDescription']['tableArn'],
3333
Tags=[{

layer/python/cloudtrail_watcher/services/ec2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _process_run_instances(event: dict, set_tags: bool = False) -> list:
3232
resource_ids = _get_instance_resource_ids(event)
3333

3434
# Set mandatory tags
35-
if set_tags is True:
35+
if set_tags:
3636
has_user_tag = {
3737
'instance': False,
3838
'volume': False,
@@ -50,10 +50,10 @@ def _process_run_instances(event: dict, set_tags: bool = False) -> list:
5050
for resource_id in resource_ids:
5151
instance = ec2.Instance(resource_id)
5252

53-
if has_user_tag['instance'] is False:
53+
if not has_user_tag['instance']:
5454
instance.create_tags(Tags=common_tags)
5555

56-
if has_user_tag['volume'] is False:
56+
if not has_user_tag['volume']:
5757
for volume in instance.volumes.all():
5858
volume.create_tags(Tags=common_tags)
5959

@@ -70,7 +70,7 @@ def _process_create_security_group(event: dict, set_tag: bool = False) -> list:
7070

7171
sg = ec2.SecurityGroup(resource_ids[0])
7272

73-
if set_tag is True:
73+
if set_tag:
7474
has_user_tags = False
7575

7676
# Check tags
@@ -81,7 +81,7 @@ def _process_create_security_group(event: dict, set_tag: bool = False) -> list:
8181
break
8282

8383
# If mandatory tags are not set, set mandatory tags
84-
if has_user_tags is False:
84+
if not has_user_tags:
8585
sg.create_tags(Tags=[{
8686
'Key': 'User',
8787
'Value': get_user_identity(event)

layer/python/cloudtrail_watcher/services/ecr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ def _process_create_repository(event: dict, set_tag: bool = False) -> list:
1010

1111
repository_arn = event['responseElements']['repository']['repositoryArn']
1212

13-
if set_tag is True:
13+
if set_tag:
1414
tags = ecr.list_tags_for_resource(resourceArn=repository_arn)
1515

1616
exists_mandatory_tag = check_contain_mandatory_tag_list(tags['tags'])
1717

18-
if exists_mandatory_tag is False:
18+
if not exists_mandatory_tag:
1919
ecr.tag_resource(resourceArn=repository_arn,
2020
tags=[{
2121
'Key': 'User',

layer/python/cloudtrail_watcher/services/ecs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
def _process_create_cluster(event: dict, set_tag: bool = False) -> list:
99
""" Process ECS CreateCluster API. """
1010

11-
if set_tag is True:
12-
if check_contain_mandatory_tag_list(event['responseElements']['cluster']['tags']) is False:
11+
if set_tag:
12+
if not check_contain_mandatory_tag_list(event['responseElements']['cluster']['tags']):
1313
ecs.tag_resource(
1414
resourceArn=event['responseElements']['cluster']['clusterArn'],
1515
tags=[{

layer/python/cloudtrail_watcher/services/eks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
def _process_create_cluster(event: dict, set_tag: bool = False) -> list:
99
""" Process ECS CreateCluster API. """
1010

11-
if set_tag is True:
12-
if check_contain_mandatory_tag_dict(event['responseElements']['cluster']['tags']) is False:
11+
if set_tag:
12+
if not check_contain_mandatory_tag_dict(event['responseElements']['cluster']['tags']):
1313
eks.tag_resource(
1414
resourceArn=event['responseElements']['cluster']['arn'],
1515
tags={'User': get_user_identity(event)}

layer/python/cloudtrail_watcher/services/elasticache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def _set_mandatory_tag(event: dict):
99
""" Set mandatory tag for ElastiCache resources. """
1010

1111
if 'tags' in event['requestParameters'].keys():
12-
if check_contain_mandatory_tag_list(event['requestParameters']['tags']) is True:
12+
if check_contain_mandatory_tag_list(event['requestParameters']['tags']):
1313
return
1414

1515
resource_id = event['responseElements']['aRN']
@@ -25,15 +25,15 @@ def _set_mandatory_tag(event: dict):
2525

2626
def _process_create_cache_cluster(event: dict, set_tag: bool = False) -> list:
2727

28-
if set_tag is True:
28+
if set_tag:
2929
_set_mandatory_tag(event)
3030

3131
return [event['responseElements']['aRN'].split(':')[-1]]
3232

3333

3434
def _process_create_replication_group(event: dict, set_tag: bool = False) -> list:
3535

36-
if set_tag is True:
36+
if set_tag:
3737
_set_mandatory_tag(event)
3838

3939
return [event['responseElements']['aRN'].split(':')[-1]]

layer/python/cloudtrail_watcher/services/elasticloadbalancing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def _process_create_load_balancer(event: dict, set_tags: bool = False) -> list:
1010

1111
is_clb = 'type' not in event['requestParameters']
1212

13-
if set_tags is True:
13+
if set_tags:
1414
if is_clb is True:
1515
response = elb.describe_tags(LoadBalancerNames=[event['requestParameters']['loadBalancerName']])
1616
else:
@@ -20,7 +20,7 @@ def _process_create_load_balancer(event: dict, set_tags: bool = False) -> list:
2020

2121
exists_mandatory_tags = check_contain_mandatory_tag_list(response['TagDescriptions'][0]['Tags'])
2222

23-
if exists_mandatory_tags is False:
23+
if not exists_mandatory_tags:
2424
if is_clb is True:
2525
elb.add_tags(
2626
LoadBalancerNames=[event['requestParameters']['loadBalancerName']],

layer/python/cloudtrail_watcher/services/elasticmapreduce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def _process_run_job_flow(event: dict, set_tag: bool = False) -> list:
1010

1111
job_flow_id = event['responseElements']['jobFlowId']
1212

13-
if set_tag is True:
13+
if set_tag:
1414
if 'tags' not in event['requestParameters'] or \
1515
check_contain_mandatory_tag_list(event['requestParameters']['tags']) is False:
1616
emr.add_tags(

0 commit comments

Comments
 (0)