Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blue_green/python/get_launch_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
insts = [("flywheel", fresponse), ("crawler", cresponse)]

for x in insts:
with open(x[0] + ".json", "w") as write_file:
with open(f"{x[0]}.json", "w") as write_file:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 17-17 refactored with the following changes:

json.dump(x[1], write_file, indent=4, sort_keys=True)
3 changes: 0 additions & 3 deletions blue_green/python/kill_all_not_in_vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def delete_items(aws_creds):
f"Failed to Remove {policy_arn} from Profile {role.name} - skipping ",
e,
)
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function delete_items refactored with the following changes:

else:
print(f"Removed {policy_arn} from Profile {role.name} OK")

Expand All @@ -67,7 +66,6 @@ def delete_items(aws_creds):
f"Failed to Remove {rolename} from Profile {inst_prof} - skipping ",
e,
)
pass
else:
print(f"Removed Role {rolename} from Profile {inst_prof} OK")

Expand All @@ -77,7 +75,6 @@ def delete_items(aws_creds):
print(f"Role {role.name} does not exist at all")
except Exception as e:
print(f"Failed to Delete Role {role.name} - skipping -", e)
pass
else:
print(f"Deleted Instance Role {role.name} OK")

Expand Down
1 change: 0 additions & 1 deletion blue_green/python/kill_all_vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def vpc_delete(vpcid, aws_creds):
print(
f"SG {sec_group['GroupName']} {sec_group['GroupId']} does not have a group dependancy"
)
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function vpc_delete refactored with the following changes:

else:
print(
f"SG {sec_group['GroupName']} {sec_group['GroupId']} has a "
Expand Down
2 changes: 0 additions & 2 deletions blue_green/python/list_vpcs_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def main(aws_creds):
name = "No Name Set"
except Exception as e:
print(type(e), e)
else:
pass
Comment on lines -28 to -29
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

finally:
print(vpcid, name)

Expand Down
14 changes: 2 additions & 12 deletions blue_green/python/prod_vpc_lb_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ def my_create_vpc(self, tagged=True):
except Exception:
raise
else:
if self.tagged:
return self.message + "and tagged OK"
else:
return self.message + "OK"
return f"{self.message}and tagged OK" if self.tagged else f"{self.message}OK"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BUILD.my_create_vpc refactored with the following changes:


def my_create_subnet(self, subnet_bundle):
""" Create Subnets in precise Availability Zones """
Expand Down Expand Up @@ -268,7 +265,6 @@ def my_create_instance_profile(self, inst_prof_name):
self.iam_client.create_instance_profile(InstanceProfileName=inst_prof_name)
except self.iam_client.exceptions.EntityAlreadyExistsException:
print(f"IP: Instance Profle {inst_prof_name} Already Exists -- skipping")
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BUILD.my_create_instance_profile refactored with the following changes:

except Exception as e:
print("IP: Inst prof problem ", e)
else:
Expand All @@ -289,10 +285,8 @@ def my_create_app_role(self, app_role_name, app_role_file):
)
except self.iam_client.exceptions.EntityAlreadyExistsException:
print(f"AR: App role {app_role_name} Already Exists -- skipping")
pass
except Exception as e:
print("AR: App Role problem - Still need to insert to Inst Prof", e)
pass
Comment on lines -292 to -295
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BUILD.my_create_app_role refactored with the following changes:

else:
print(f"AR: App role {app_role_name} Created OK")

Expand All @@ -302,7 +296,6 @@ def my_create_app_role(self, app_role_name, app_role_file):
)
except self.iam_client.exceptions.LimitExceededException:
print(f"AR: {inst_prof_name} already has a Role -- Skipping")
pass
except Exception as e:
print(
"AR: Problem adding role {app_role_name} to instance profile {inst_prof_name} ",
Expand Down Expand Up @@ -330,7 +323,6 @@ def my_create_policy(self, policy_name, policy_file, policy_desc):

except self.iam_client.exceptions.EntityAlreadyExistsException:
print(f"PL: Policy {policy_name} Already exists -- skipping")
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BUILD.my_create_policy refactored with the following changes:

except Exception as e:
print("PL: Policy Creation problem ", e)
else:
Expand Down Expand Up @@ -365,7 +357,6 @@ def my_create_log_groups(self, log_group_name):
self.logs_client.create_log_group(logGroupName=log_group_name)
except self.logs_client.exceptions.ResourceAlreadyExistsException:
print(f"LG: Log Group {log_group_name} Already Exists -- skipping")
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BUILD.my_create_log_groups refactored with the following changes:

except Exception as e:
print("LG: Log Group problem ", e)
else:
Expand Down Expand Up @@ -440,7 +431,6 @@ def my_create_t_a_p_group(self, auto_scaling_bundle, subnet_bundles):

except self.elbv2_client.exceptions.DuplicateTargetGroupNameException:
print("TG: Target Group Exists Already -- skipping")
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BUILD.my_create_t_a_p_group refactored with the following changes:

except Exception:
raise
else:
Expand All @@ -456,7 +446,7 @@ def my_create_load_balancer(self, randomAS=False):

if randomAS:
""" We randomly choose the Target / ASGroup """
FirstTg_Group = random.choice([x for x in self.target_groups.keys()])
FirstTg_Group = random.choice(list(self.target_groups.keys()))
Comment on lines -459 to +449
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BUILD.my_create_load_balancer refactored with the following changes:

else:
FirstTg_Group = "Target-GRP-Auto-Scale-GREEN"

Expand Down
8 changes: 2 additions & 6 deletions getSecret.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ def get_secret(secret_name, region_name):
# Decrypts secret using the associated KMS CMK.
# Depending on whether the secret is a string or binary, one of these fields will be populated.
if "SecretString" in get_secret_value_response:
secret = get_secret_value_response["SecretString"]
return secret
return get_secret_value_response["SecretString"]
else:
decoded_binary_secret = base64.b64decode(
get_secret_value_response["SecretBinary"]
)
return decoded_binary_secret
return base64.b64decode(get_secret_value_response["SecretBinary"])
Comment on lines -46 to +48
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_secret refactored with the following changes:



if __name__ == "__main__":
Expand Down