original_docstring: 
          Returns a boto session in the target account.
  
          If an ``iam_role`` is specified in ConnectionManager's initialiser,
          then STS is used to assume the specified IAM role in the account and
          uses temporary credentials to create the boto session. If ``iam_role``
          is not specified, the default AWS credentials are used to create the
          boto session.
  
          :returns: The Boto3 session.
          :rtype: boto3.session.Session
          :raises: botocore.exceptions.ClientError
          
docstring: Returns a boto session in the target account.
  If an ``iam_role`` is specified in ConnectionManager's initialiser,
  then STS is used to assume the specified IAM role in the account and
  uses temporary credentials to create the boto session. If ``iam_role``
  is not specified, the default AWS credentials are used to create the
  boto session.
docstring_tokens: Returns a boto session in the target account . If an ` ` iam_role ` ` is specified in ConnectionManager ' s initialiser then STS is used to assume the specified IAM role in the account and uses temporary credentials to create the boto session . If ` ` iam_role ` ` is not specified the default AWS credentials are used to create the boto session .
code: def boto_session(self):
          """
          Returns a boto session in the target account.
  
          If an ``iam_role`` is specified in ConnectionManager's initialiser,
          then STS is used to assume the specified IAM role in the account and
          uses temporary credentials to create the boto session. If ``iam_role``
          is not specified, the default AWS credentials are used to create the
          boto session.
  
          :returns: The Boto3 session.
          :rtype: boto3.session.Session
          :raises: botocore.exceptions.ClientError
          """
          with self._session_lock:
              self.logger.debug("Getting Boto3 session")
  
              if self._boto_session is None:
                  self.logger.debug("No Boto3 session found, creating one...")
                  if self.iam_role:
                      self.logger.debug("Assuming role '%s'...", self.iam_role)
                      sts_client = boto3.client("sts")
                      sts_response = sts_client.assume_role(
                          RoleArn=self.iam_role,
                          RoleSessionName="{0}-session".format(
                              self.iam_role.split("/")[-1]
                          )
                      )
                      credentials = sts_response["Credentials"]
                      self._boto_session = boto3.session.Session(
                          aws_access_key_id=credentials["AccessKeyId"],
                          aws_secret_access_key=credentials["SecretAccessKey"],
                          aws_session_token=credentials["SessionToken"],
                          region_name=self.region
                      )
                      self.logger.debug(
                          "Using temporary credential set: %s",
                          {
                              "AccessKeyId": mask_key(
                                  credentials["AccessKeyId"]
                              ),
                              "SecretAccessKey": mask_key(
                                  credentials["SecretAccessKey"]
                              )
                          }
                      )
                  else:
                      self.logger.debug("Using cli credentials...")
                      self._boto_session = boto3.session.Session(
                          region_name=self.region
                      )
                      self.logger.debug(
                          "Using credential set from %s: %s",
                          self._boto_session.get_credentials().method,
                          {
                              "AccessKeyId": mask_key(
                                  self._boto_session.get_credentials().access_key
                              ),
                              "SecretAccessKey": mask_key(
                                  self._boto_session.get_credentials().secret_key
                              ),
                              "Region": self._boto_session.region_name
                          }
                      )
  
                  self.logger.debug("Boto3 session created")
  
              return self._boto_session
code_tokens: def boto_session ( self ) : with self . _session_lock : self . logger . debug ( "Getting Boto3 session" ) if self . _boto_session is None : self . logger . debug ( "No Boto3 session found, creating one..." ) if self . iam_role : self . logger . debug ( "Assuming role '%s'..." , self . iam_role ) sts_client = boto3 . client ( "sts" ) sts_response = sts_client . assume_role ( RoleArn = self . iam_role , RoleSessionName = "{0}-session" . format ( self . iam_role . split ( "/" ) [ - 1 ] ) ) credentials = sts_response [ "Credentials" ] self . _boto_session = boto3 . session . Session ( aws_access_key_id = credentials [ "AccessKeyId" ] , aws_secret_access_key = credentials [ "SecretAccessKey" ] , aws_session_token = credentials [ "SessionToken" ] , region_name = self . region ) self . logger . debug ( "Using temporary credential set: %s" , { "AccessKeyId" : mask_key ( credentials [ "AccessKeyId" ] ) , "SecretAccessKey" : mask_key ( credentials [ "SecretAccessKey" ] ) } ) else : self . logger . debug ( "Using cli credentials..." ) self . _boto_session = boto3 . session . Session ( region_name = self . region ) self . logger . debug ( "Using credential set from %s: %s" , self . _boto_session . get_credentials ( ) . method , { "AccessKeyId" : mask_key ( self . _boto_session . get_credentials ( ) . access_key ) , "SecretAccessKey" : mask_key ( self . _boto_session . get_credentials ( ) . secret_key ) , "Region" : self . _boto_session . region_name } ) self . logger . debug ( "Boto3 session created" ) return self . _boto_session
short_docstring: Returns a boto session in the target account.
short_docstring_tokens: Returns a boto session in the target account .
comment: """
          Returns a boto session in the target account.
  
          If an ``iam_role`` is specified in ConnectionManager's initialiser,
          then STS is used to assume the specified IAM role in the account and
          uses temporary credentials to create the boto session. If ``iam_role``
          is not specified, the default AWS credentials are used to create the
          boto session.
  
          :returns: The Boto3 session.
          :rtype: boto3.session.Session
          :raises: botocore.exceptions.ClientError
          """