code: def pre_deploy_assume_role(assume_role_config, context):
      
      if isinstance(assume_role_config, dict):
          assume_role_arn = ''
          if assume_role_config.get('post_deploy_env_revert'):
              context.save_existing_iam_env_vars()
          if assume_role_config.get('arn'):
              assume_role_arn = assume_role_config['arn']
              assume_role_duration = assume_role_config.get('duration')
          elif assume_role_config.get(context.env_name):
              if isinstance(assume_role_config[context.env_name], dict):
                  assume_role_arn = assume_role_config[context.env_name]['arn']  # noqa
                  assume_role_duration = assume_role_config[context.env_name].get('duration')  # noqa pylint: disable=line-too-long
              else:
                  assume_role_arn = assume_role_config[context.env_name]
                  assume_role_duration = None
          else:
              LOGGER.info('Skipping assume-role; no role found for '
                          'environment %s...',
                          context.env_name)
  
          if assume_role_arn:
              context.env_vars = merge_dicts(
                  context.env_vars,
                  assume_role(
                      role_arn=assume_role_arn,
                      session_name=assume_role_config.get('session_name', None),
                      duration_seconds=assume_role_duration,
                      region=context.env_region,
                      env_vars=context.env_vars
                  )
              )
      else:
          context.env_vars = merge_dicts(
              context.env_vars,
              assume_role(role_arn=assume_role_config,
                          region=context.env_region,
                          env_vars=context.env_vars)
          )
docs: Assume role (prior to deployment).