Skip to content

Commit

Permalink
Addressing Linting issues:
Browse files Browse the repository at this point in the history
  • Loading branch information
StewartW committed Apr 12, 2022
1 parent fce5731 commit 26a70ce
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
Pipeline Management Lambda Function
Creates or Updates an Event Rule for forwarding events
If the source account != the Deplyment account
"""

import os
import boto3

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

"""
Pipeline Management Lambda Function
Creates or Updates a CodeCommit Repository
"""

import os
import boto3
from repo import Repo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Pipeline Management Lambda Function
Generates Pipeline Inputs
"""

import os
import boto3

Expand All @@ -24,13 +30,13 @@ def store_regional_parameter_config(pipeline, parameter_store):
"""
if pipeline.top_level_regions:
parameter_store.put_parameter(
"/deployment/{0}/regions".format(pipeline.name),
f"/deployment/{pipeline.name}/regions",
str(list(set(pipeline.top_level_regions))),
)
return

parameter_store.put_parameter(
"/deployment/{0}/regions".format(pipeline.name),
f"/deployment/{pipeline.name}/regions",
str(list(set(Pipeline.flatten_list(pipeline.stage_regions)))),
)

Expand All @@ -41,10 +47,10 @@ def fetch_required_ssm_params(regions):
parameter_store = ParameterStore(region, boto3)
output[region] = {
"s3": parameter_store.fetch_parameter(
"/cross_region/s3_regional_bucket/{0}".format(region)
f"/cross_region/s3_regional_bucket/{region}"
),
"kms": parameter_store.fetch_parameter(
"/cross_region/kms_arn/{0}".format(region)
f"/cross_region/kms_arn/{region}"
),
}
if region == DEPLOYMENT_ACCOUNT_REGION:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import boto3
"""
Pipeline Management Lambda Function
Compares pipeline definitions in S3 to the definitions stored in SSM Param Store.
Any that exist in param store but not S3 are marked for removal.
"""

import os
import json
import hashlib

import boto3

from logger import configure_logger
from deployment_map import DeploymentMap
from parameter_store import ParameterStore
Expand All @@ -23,14 +31,14 @@ def download_deployment_maps(resource, prefix, local):
LOGGER.info(result)
for subdir in result.get("CommonPrefixes", []):
download_deployment_maps(resource, subdir.get("Prefix"), local)
for file in result.get("Contents", []):
LOGGER.info(file)
dest_path_name = os.path.join(local, file.get("Key"))
if not os.path.exists(os.path.dirname(dest_path_name)):
os.makedirs(os.path.dirname(dest_path_name))
resource.meta.client.download_file(
S3_BUCKET_NAME, file.get("Key"), dest_path_name
)
for file in result.get("Contents", []):
LOGGER.info(file)
dest_path_name = os.path.join(local, file.get("Key"))
if not os.path.exists(os.path.dirname(dest_path_name)):
os.makedirs(os.path.dirname(dest_path_name))
resource.meta.client.download_file(
S3_BUCKET_NAME, file.get("Key"), dest_path_name
)


def get_current_pipelines(parameter_store):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""
Pipeline Management Lambda Function
Stores pipeline input from prior funtion to S3.
"""

import os
import boto3
import json
from botocore.exceptions import ClientError

import boto3

from logger import configure_logger


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
"""
Standardised class for pushing CloudWatch metric data to a service within the ADF Namespace
"""

import boto3


class ADFMetrics:
def __init__(self, client: boto3.client, service, namespace="ADF") -> None:
"""
Client: Any Boto3 Cloudwatch client
Service: The name of the Service e.g PipelineManagement/Repository or AccountManagement/EnableSupport
namespace: Defaults to ADF
"""
self.cw = client
self.namespace = f"{namespace}/{service}"

def put_metric_data(self, metric_data):
if type(metric_data) is not list:
if isinstance(metric_data, list):
metric_data = [metric_data]
self.cw.put_metric_data(Namespace=self.namespace, MetricData=metric_data)

0 comments on commit 26a70ce

Please sign in to comment.