{"id":9558,"library":"boto3-assume","title":"boto3-assume","description":"boto3-assume is a Python library that simplifies creating boto3 assume role sessions with automatic credential refreshing. It provides a convenient API for managing temporary AWS credentials via IAM roles. The library is actively maintained with frequent, small releases.","status":"active","version":"0.2.1","language":"en","source_language":"en","source_url":"https://github.com/btemplep/boto3-assume","tags":["aws","boto3","iam","assume-role","security","credentials","session"],"install":[{"cmd":"pip install boto3-assume","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for AWS SDK functionality, used for creating and managing AWS sessions.","package":"boto3","optional":false}],"imports":[{"note":"`assume_role_session` was deprecated in v0.2.0 and replaced by `assume_role`.","wrong":"from boto3_assume import assume_role_session","symbol":"assume_role","correct":"from boto3_assume import assume_role"},{"note":"`assume_role_aio_session` was moved to the `aioboto3-assume` package in v0.2.0.","wrong":"from boto3_assume import assume_role_aio_session","symbol":"assume_role_aio_session","correct":"from aioboto3_assume import assume_role_aio_session"}],"quickstart":{"code":"import boto3_assume\nimport boto3\nimport os\n\n# Replace with your actual role ARN and session name\n# For local testing, ensure your AWS credentials are configured (e.g., via ~/.aws/credentials or environment variables)\nrole_arn = os.environ.get('AWS_ASSUME_ROLE_ARN', 'arn:aws:iam::123456789012:role/MyTestRole')\nrole_session_name = os.environ.get('AWS_ASSUME_SESSION_NAME', 'Boto3AssumeQuickstartSession')\n\nif not role_arn.startswith('arn:aws:iam::'):\n    print(\"Warning: AWS_ASSUME_ROLE_ARN not set or invalid. Using a placeholder ARN. This example will likely fail unless configured correctly.\")\n\ntry:\n    # Assume the role and get a boto3 session object\n    assumed_session = boto3_assume.assume_role(\n        role_arn=role_arn,\n        role_session_name=role_session_name\n    )\n\n    # Use the assumed session to create a client (e.g., S3)\n    s3_client = assumed_session.client('s3')\n    print(f\"Successfully assumed role '{role_arn}' with session name '{role_session_name}'.\")\n\n    # Example: List S3 buckets using the assumed role\n    print(\"Attempting to list S3 buckets...\")\n    buckets_response = s3_client.list_buckets()\n    bucket_names = [b['Name'] for b in buckets_response.get('Buckets', [])]\n    print(f\"Found {len(bucket_names)} S3 buckets: {bucket_names[:3]}...\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your AWS credentials are configured and the role ARN is correct and accessible.\")\n","lang":"python","description":"This quickstart demonstrates how to use `boto3-assume.assume_role` to obtain a boto3 session with temporary credentials from an assumed IAM role, and then use that session to interact with an AWS service like S3. Ensure your environment has AWS credentials configured (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, or `AWS_PROFILE`) and replace the placeholder `role_arn`."},"warnings":[{"fix":"Update your code to use `from boto3_assume import assume_role` and call `boto3_assume.assume_role(...)` instead of `assume_role_session`.","message":"The primary function `assume_role_session` was deprecated and replaced by `assume_role` in v0.2.0. The new `assume_role` function offers more flexibility.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"If you need async assume role functionality, install `aioboto3-assume` (`pip install aioboto3-assume`) and import `assume_role_aio_session` from there.","message":"Asynchronous (aioboto3) functionality, specifically `assume_role_aio_session`, was moved to a separate package `aioboto3-assume` to simplify dependencies.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Upgrade your Python environment to 3.10 or newer to use versions 0.1.3 and above.","message":"Support for Python versions 3.7-3.9 was removed in v0.1.3.","severity":"breaking","affected_versions":">=0.1.3"},{"fix":"No action needed for newer versions. If on an older version and trying to use extras, simply remove the extra specification in your `pip install` command (e.g., `pip install boto3-assume`).","message":"Previous versions (before v0.1.2) had non-functional `boto3` and `aioboto3` package extras which were removed. These extras were not needed as `boto3` is a core dependency.","severity":"gotcha","affected_versions":"<0.1.2"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Update your import and function call to `from boto3_assume import assume_role` and use `boto3_assume.assume_role(...)`.","cause":"You are using version 0.2.0 or newer of boto3-assume, but your code is still calling the deprecated `assume_role_session` function.","error":"AttributeError: module 'boto3_assume' has no attribute 'assume_role_session'"},{"fix":"Install `aioboto3-assume` (`pip install aioboto3-assume`) and change your import to `from aioboto3_assume import assume_role_aio_session`.","cause":"`assume_role_aio_session` was moved to a new package, `aioboto3-assume`, in version 0.2.0.","error":"ImportError: cannot import name 'assume_role_aio_session' from 'boto3_assume'"},{"fix":"Upgrade your Python environment to version 3.10 or newer.","cause":"Your Python version is too old (e.g., 3.7-3.9) for boto3-assume versions 0.1.3 and above, which dropped support for these Python versions.","error":"SyntaxError: future feature annotations is not defined"}]}