class_docstr: Contains lambda boto3 wrappers to Create, Update, Delete and Invoke Lambda functions.
class_docstr_tok: ["Contains","lambda","boto3","wrappers","to","Create",",","Update",",","Delete","and","Invoke","Lambda","functions","."]
docstr: Constructs a Lambda instance.
  
  This instance represents a Lambda function and provides methods for updating,
  deleting and invoking the function.
  
  This class can be used either for creating a new Lambda function or using an existing one.
  When using an existing Lambda function, only the function_arn argument is required.
  When creating a new one the function_name, execution_role_arn and handler arguments
  are required, as well as either script or zipped_code_dir.
  
  Args:
      function_arn (str): The arn of the Lambda function.
      function_name (str): The name of the Lambda function.
          Function name must be provided to create a Lambda function.
      execution_role_arn (str): The role to be attached to Lambda function.
      zipped_code_dir (str): The path of the zipped code package of the Lambda function.
      s3_bucket (str): The bucket where zipped code is uploaded.
          If not provided, default session bucket is used to upload zipped_code_dir.
      script (str): The path of Lambda function script for direct zipped upload
      handler (str): The Lambda handler. The format for handler should be
          file_name.function_name. For ex: if the name of the Lambda script is
          hello_world.py and Lambda function definition in that script is
          lambda_handler(event, context), the handler should be hello_world.lambda_handler
      session (sagemaker.session.Session): Session object which manages interactions
          with Amazon SageMaker APIs and any other AWS services needed.
          If not specified, new session is created.
      timeout (int): Timeout of the Lambda function in seconds. Default is 120 seconds.
      memory_size (int): Memory of the Lambda function in megabytes. Default is 128 MB.
      runtime (str): Runtime of the Lambda function. Default is set to python3.8.
      vpc_config (dict): VPC to deploy the Lambda function to. Default is None.
      environment (dict): Environment Variables for the Lambda function. Default is None.
      layers (list): List of Lambda layers for the Lambda function. Default is None.
docstr_tok: ["Constructs","a","Lambda","instance",".","This","instance","represents","a","Lambda","function","and","provides","methods","for","updating",",","deleting","and","invoking","the","function",".","This","class","can","be","used","either","for","creating","a","new","Lambda","function","or","using","an","existing","one",".","When","using","an","existing","Lambda","function",",","only","the","function_arn","argument","is","required",".","When","creating","a","new","one","the","function_name",",","execution_role_arn","and","handler","arguments","are","required",",","as","well","as","either","script","or","zipped_code_dir",".","Args",":","function_arn","(","str",")",":","The","arn","of","the","Lambda","function",".","function_name","(","str",")",":","The","name","of","the","Lambda","function",".","Function","name","must","be","provided","to","create","a","Lambda","function",".","execution_role_arn","(","str",")",":","The","role","to","be","attached","to","Lambda","function",".","zipped_code_dir","(","str",")",":","The","path","of","the","zipped","code","package","of","the","Lambda","function",".","s3_bucket","(","str",")",":","The","bucket","where","zipped","code","is","uploaded",".","If","not","provided",",","default","session","bucket","is","used","to","upload","zipped_code_dir",".","script","(","str",")",":","The","path","of","Lambda","function","script","for","direct","zipped","upload","handler","(","str",")",":","The","Lambda","handler",".","The","format","for","handler","should","be","file_name.function_name",".","For","ex",":","if","the","name","of","the","Lambda","script","is","hello_world.py","and","Lambda","function","definition","in","that","script","is","lambda_handler","(","event",",","context",")",",","the","handler","should","be","hello_world.lambda_handler","session","(","sagemaker.session.Session",")",":","Session","object","which","manages","interactions","with","Amazon","SageMaker","APIs","and","any","other","AWS","services","needed",".","If","not","specified",",","new","session","is","created",".","timeout","(","int",")",":","Timeout","of","the","Lambda","function","in","seconds",".","Default","is","120","seconds",".","memory_size","(","int",")",":","Memory","of","the","Lambda","function","in","megabytes",".","Default","is","128","MB",".","runtime","(","str",")",":","Runtime","of","the","Lambda","function",".","Default","is","set","to","python3.8",".","vpc_config","(","dict",")",":","VPC","to","deploy","the","Lambda","function","to",".","Default","is","None",".","environment","(","dict",")",":","Environment","Variables","for","the","Lambda","function",".","Default","is","None",".","layers","(","list",")",":","List","of","Lambda","layers","for","the","Lambda","function",".","Default","is","None","."]
code: def __init__(
      self,
      function_arn: str = None,
      function_name: str = None,
      execution_role_arn: str = None,
      zipped_code_dir: str = None,
      s3_bucket: str = None,
      script: str = None,
      handler: str = None,
      session: Session = None,
      timeout: int = 120,
      memory_size: int = 128,
      runtime: str = "python3.8",
      vpc_config: dict = None,
      environment: dict = None,
      layers: list = None,
  ):
      """Constructs a Lambda instance.
  
      This instance represents a Lambda function and provides methods for updating,
      deleting and invoking the function.
  
      This class can be used either for creating a new Lambda function or using an existing one.
      When using an existing Lambda function, only the function_arn argument is required.
      When creating a new one the function_name, execution_role_arn and handler arguments
      are required, as well as either script or zipped_code_dir.
  
      Args:
          function_arn (str): The arn of the Lambda function.
          function_name (str): The name of the Lambda function.
              Function name must be provided to create a Lambda function.
          execution_role_arn (str): The role to be attached to Lambda function.
          zipped_code_dir (str): The path of the zipped code package of the Lambda function.
          s3_bucket (str): The bucket where zipped code is uploaded.
              If not provided, default session bucket is used to upload zipped_code_dir.
          script (str): The path of Lambda function script for direct zipped upload
          handler (str): The Lambda handler. The format for handler should be
              file_name.function_name. For ex: if the name of the Lambda script is
              hello_world.py and Lambda function definition in that script is
              lambda_handler(event, context), the handler should be hello_world.lambda_handler
          session (sagemaker.session.Session): Session object which manages interactions
              with Amazon SageMaker APIs and any other AWS services needed.
              If not specified, new session is created.
          timeout (int): Timeout of the Lambda function in seconds. Default is 120 seconds.
          memory_size (int): Memory of the Lambda function in megabytes. Default is 128 MB.
          runtime (str): Runtime of the Lambda function. Default is set to python3.8.
          vpc_config (dict): VPC to deploy the Lambda function to. Default is None.
          environment (dict): Environment Variables for the Lambda function. Default is None.
          layers (list): List of Lambda layers for the Lambda function. Default is None.
      """
      self.function_arn = function_arn
      self.function_name = function_name
      self.zipped_code_dir = zipped_code_dir
      self.s3_bucket = s3_bucket
      self.script = script
      self.handler = handler
      self.execution_role_arn = execution_role_arn
      self.session = session if session is not None else Session()
      self.timeout = timeout
      self.memory_size = memory_size
      self.runtime = runtime
      self.vpc_config = vpc_config or {}
      self.environment = environment or {}
      self.layers = layers or []
  
      if function_arn is None and function_name is None:
          raise ValueError(
              "Either function_arn or function_name must be provided."
          )
  
      if function_name is not None:
          if execution_role_arn is None:
              raise ValueError("execution_role_arn must be provided.")
          if zipped_code_dir is None and script is None:
              raise ValueError(
                  "Either zipped_code_dir or script must be provided."
              )
          if zipped_code_dir and script:
              raise ValueError(
                  "Provide either script or zipped_code_dir, not both."
              )
          if handler is None:
              raise ValueError("Lambda handler must be provided.")
  
      if function_arn is not None:
          if zipped_code_dir and script:
              raise ValueError(
                  "Provide either script or zipped_code_dir, not both."
              )
  
file_path: sagemaker-python-sdk/src/sagemaker/lambda_helper.py
imports: from __future__ import print_function, absolute_import
  from io import BytesIO
  import zipfile
  import time
  from botocore.exceptions import ClientError
  from sagemaker import s3
  from sagemaker.session import Session
label_desc: Use image node_id 1 to create a new Lambda object  with example: obj = Lambda(function_arn, function_name, execution_role_arn, zipped_code_dir, s3_bucket, script, handler, session, timeout, memory_size, runtime, vpc_config, environment, layers)