def lambda_handler()

in lambda_destroy_pcluster/destroy.py [0:0]


def lambda_handler(event, context):
    output = {}
    #Create the cloudformation client
    client_cloudformation = boto3.client('cloudformation')
    #Section related to the creation of the stack
    if event['RequestType'] == 'Create':
      send_response(event, context, "SUCCESS", output)
    #Section related to the deletion of the stack
    elif event['RequestType'] == 'Delete':
      #delete the stacks
      try:
        client_cloudformation.delete_stack(StackName='parallelcluster-cluster1')
        client_cloudformation.delete_stack(StackName='parallelcluster-cluster2')
        LOGGER.info('Deleting stacks')
        send_response(event, context, "SUCCESS", output)
      except Exception as e:
        LOGGER.info('Error: %s', e)
        send_response(event, context, "FAILED", output)