use-cases/lambda-chaining-with-redshift-data-api/cloud_formation_template/lambda-chaining-with-redshift-data-api.yaml [199:239]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Handler: index.handler
      Runtime: python3.7
      Role: !GetAtt 'LambdaRedshiftDataApiETLRole.Arn'
      Timeout: 30
      Code:
        ZipFile: |
          import json
          import time
          import unicodedata
          import traceback
          import sys
          from pip._internal import main
          # install latest version of boto3
          main(['install', '-I', '-q', 'boto3', '--target', '/tmp/', '--no-cache-dir', '--disable-pip-version-check'])
          sys.path.insert(0,'/tmp/')
          import boto3
          # initiate redshift-data client in boto3
          client = boto3.client("redshift-data")
          def handler(event, context):
              print(event)
              # input parameters passed from the caller event
              # cluster identifier for the Amazon Redshift cluster
              redshift_cluster_id = event['Input'].get('redshift_cluster_id')
              # database name for the Amazon Redshift cluster
              redshift_database = event['Input'].get('redshift_database')
              # database user in the Amazon Redshift cluster with access to run relevant SQL queries
              redshift_user = event['Input'].get('redshift_user')
              # Amazon SNS topic to be used to publish notifications to end-users
              sns_topic_arn = event['Input'].get('sns_topic_arn')
              # action to be taken by the lambda function. Allowed values: [run_sql, status_check, notify]
              action = event['Input'].get('action')
              # sql text to be run. e.g. call my_stored_procedure(input_params)
              sql_text = event['Input'].get('sql_text')
              # subject line to be used while publishing message through Amazon SNS
              subject = event['Input'].get('subject')
              # detailed body to be used while publishing message through Amazon SNS
              body = event['Input'].get('body')
              # query_id to input for action status_check
              query_id = event['Input'].get('query_id')
              try:
                  if action == 'run_sql':
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



use-cases/lambda-chaining-with-redshift-data-api/cloud_formation_template/lambda-chaining-with-redshift-data-api.yaml [444:484]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Handler: index.handler
      Runtime: python3.7
      Role: !GetAtt 'LambdaRedshiftDataApiETLRole.Arn'
      Timeout: 30
      Code:
        ZipFile: |
          import json
          import time
          import unicodedata
          import traceback
          import sys
          from pip._internal import main
          # install latest version of boto3
          main(['install', '-I', '-q', 'boto3', '--target', '/tmp/', '--no-cache-dir', '--disable-pip-version-check'])
          sys.path.insert(0,'/tmp/')
          import boto3
          # initiate redshift-data client in boto3
          client = boto3.client("redshift-data")
          def handler(event, context):
              print(event)
              # input parameters passed from the caller event
              # cluster identifier for the Amazon Redshift cluster
              redshift_cluster_id = event['Input'].get('redshift_cluster_id')
              # database name for the Amazon Redshift cluster
              redshift_database = event['Input'].get('redshift_database')
              # database user in the Amazon Redshift cluster with access to run relevant SQL queries
              redshift_user = event['Input'].get('redshift_user')
              # Amazon SNS topic to be used to publish notifications to end-users
              sns_topic_arn = event['Input'].get('sns_topic_arn')
              # action to be taken by the lambda function. Allowed values: [run_sql, status_check, notify]
              action = event['Input'].get('action')
              # sql text to be run. e.g. call my_stored_procedure(input_params)
              sql_text = event['Input'].get('sql_text')
              # subject line to be used while publishing message through Amazon SNS
              subject = event['Input'].get('subject')
              # detailed body to be used while publishing message through Amazon SNS
              body = event['Input'].get('body')
              # query_id to input for action status_check
              query_id = event['Input'].get('query_id')
              try:
                  if action == 'run_sql':
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



