Beispiel #1
0
def clean(parameter_store, deployment_map):
    """
    Function used to remove stale entries in Parameter Store and
    Deployment Pipelines that are no longer in the Deployment Map
    """
    current_pipeline_parameters = parameter_store.fetch_parameters_by_path(
        '/deployment/')

    parameter_store = ParameterStore(DEPLOYMENT_ACCOUNT_REGION, boto3)
    cloudformation = CloudFormation(
        region=DEPLOYMENT_ACCOUNT_REGION,
        deployment_account_region=DEPLOYMENT_ACCOUNT_REGION,
        role=boto3)
    stacks_to_remove = []
    for parameter in current_pipeline_parameters:
        name = parameter.get('Name').split('/')[-2]
        if name not in [
                p.get('name') for p in deployment_map.map_contents['pipelines']
        ]:
            parameter_store.delete_parameter(name)
            stacks_to_remove.append(name)

    for stack in list(set(stacks_to_remove)):
        cloudformation.delete_stack("{0}-{1}".format(ADF_PIPELINE_PREFIX,
                                                     stack))
Beispiel #2
0
    def _clean_stale_stacks(self, name):
        cloudformation = CloudFormation(
            region=os.environ['AWS_REGION'],
            deployment_account_region=os.environ['AWS_REGION'],
            role=boto3,
        )

        LOGGER.warning('Removing Deployment Pipeline for %s', name)
        cloudformation.delete_stack("{0}-{1}".format(self.pipeline_name_prefix,
                                                     name))