def delete_agent()

in source/CRRdeployagent/CRRdeployagent.py [0:0]


def delete_agent(event, context):
    # For manager/agent account you will receive:
    # - Topic
    # - CRRQueueArn
    # For agent-only (remote) account you will receive:
    # - MyAccountId
    #
    monitor_account = ''
    topic_name = ''
    queue_arn = ''
    agent_accounts = []

    if 'Topic' in event["ResourceProperties"]:
        topic_name = event["ResourceProperties"]["Topic"] # SNS topic

    if 'CRRQueueArn' in event["ResourceProperties"]:
        queue_arn = event["ResourceProperties"]["CRRQueueArn"]
        arnparts = queue_arn.split(':')
        monitor_account = arnparts[4]

    if 'CRRMonitorAccount' in event["ResourceProperties"]:
        monitor_account = event["ResourceProperties"]["CRRMonitorAccount"]

    if 'AgentAccounts' in event["ResourceProperties"]:
        agent_accounts = event["ResourceProperties"]["AgentAccounts"]

    # Get a list of regions where we have source or replica buckets
    agent_regions = get_agent_regions()

    for region in agent_regions:
        agent_deleter(region, topic_name, queue_arn, monitor_account, agent_accounts)

    return {}