### Install AWS CLI v2 binary Source: https://github.com/youtype/awscliv2/blob/main/README.md Install the AWS CLI v2 binary. Docker is used as a fallback if this installation is skipped. ```bash # do not worry if this fails, you can still use awsv2 if you have docker installed awsv2 --install ``` -------------------------------- ### Install multiplatform binaries via Python Source: https://github.com/youtype/awscliv2/blob/main/README.md Trigger the installation of AWS CLI binaries from within a Python script. ```python from awscliv2.installers import install_multiplatform install_multiplatform() ``` -------------------------------- ### Install project dependencies Source: https://github.com/youtype/awscliv2/blob/main/README.md Synchronize the environment with all extras and development dependencies. ```bash uv sync --all-extras --dev ``` -------------------------------- ### Install awscliv2 via pip Source: https://github.com/youtype/awscliv2/blob/main/README.md Install the package using pip. ```bash python -m pip install awscliv2 ``` -------------------------------- ### Install uv package manager Source: https://github.com/youtype/awscliv2/blob/main/README.md Use this command to install the uv tool required for managing project dependencies. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install AWS CLI v2 binaries Source: https://github.com/youtype/awscliv2/blob/main/README.md Run this command to install the AWS CLI v2 binaries for your specific operating system. ```bash awsv2 --install ``` -------------------------------- ### Configure Navigation and Base URL Source: https://github.com/youtype/awscliv2/blob/main/site/search.html Sets the base URL and enables the Sphinx Read the Docs theme navigation. ```javascript var base_url = '.'; window.onload = function () { SphinxRtdTheme.Navigation.enable(true); }; ``` -------------------------------- ### Configure AWS profile Source: https://github.com/youtype/awscliv2/blob/main/README.md Set up AWS credentials and region configuration for the CLI. ```bash AWS_ACCESS_KEY_ID='my-access-key' AWS_SECRET_ACCESS_KEY='my-secret-key' # --configure [] awsv2 --configure default ${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY} awsv2 configure set region us-west-1 ``` -------------------------------- ### Initialize Syntax Highlighting Source: https://github.com/youtype/awscliv2/blob/main/site/search.html Initializes the highlight.js library on page load. ```javascript hljs.initHighlightingOnLoad(); ``` -------------------------------- ### Run pre-commit script Source: https://github.com/youtype/awscliv2/blob/main/README.md Execute the manual pre-commit script to ensure code quality before committing changes. ```bash ./scripts/before_commit.sh ``` -------------------------------- ### Configure credentials and assume roles via Python Source: https://github.com/youtype/awscliv2/blob/main/README.md Programmatically set AWS credentials and assume roles using the AWSAPI instance. ```python from awscliv2.api import AWSAPI aws_api = AWSAPI() aws_api.set_credentials( profile_name="my_profile", aws_access_key_id="access_key", aws_secret_access_key="secret_key", region="us-east-1", ) aws_api.assume_role( profile_name="my_profile", source_profile="source_profile", role_arn="role_arn", ) ``` -------------------------------- ### AWSAPI.execute Source: https://github.com/youtype/awscliv2/blob/main/README.md Executes an AWS CLI command using the provided list of arguments. ```APIDOC ## AWSAPI.execute(args) ### Description Executes an AWS CLI command. The command is passed as a list of strings, similar to how arguments are passed to a command-line interface. ### Parameters - **args** (list) - Required - A list of strings representing the AWS CLI command and its arguments (e.g., ["s3", "ls"]). ### Returns - **output** (str) - The standard output of the executed AWS CLI command. ### Example ```python from awscliv2.api import AWSAPI aws_api = AWSAPI() output = aws_api.execute(["s3", "ls"]) ``` ``` -------------------------------- ### Execute AWS CLI commands Source: https://github.com/youtype/awscliv2/blob/main/README.md Run AWS CLI commands using the awsv2 wrapper or as a Python module. ```bash # alias for # docker run --rm -i -v ~/.aws:/root/.aws -v $(pwd):/aws amazon/aws-cli $@ awsv2 s3 ls # or as a python module python -m awscliv2 s3 ls ``` -------------------------------- ### AWSAPI.assume_role Source: https://github.com/youtype/awscliv2/blob/main/README.md Creates a new profile using assumed role credentials. ```APIDOC ## AWSAPI.assume_role(profile_name, source_profile, role_arn) ### Description Configures a new profile that uses credentials derived from assuming a specific IAM role. ### Parameters - **profile_name** (str) - Required - The name of the new profile to create. - **source_profile** (str) - Required - The existing profile to use as the source for the assume-role request. - **role_arn** (str) - Required - The Amazon Resource Name (ARN) of the role to assume. ``` -------------------------------- ### Execute AWS commands via Python API Source: https://github.com/youtype/awscliv2/blob/main/README.md Use the AWSAPI class to execute CLI commands programmatically within Python. ```python from awscliv2.api import AWSAPI from awscliv2.exceptions import AWSCLIError aws_api = AWSAPI() try: output = aws_api.execute(["s3", "ls"]) except AWSCLIError as e: print(f"Something went wrong: {e}") else: print(output) ``` -------------------------------- ### Alias aws command Source: https://github.com/youtype/awscliv2/blob/main/README.md Add an alias to your shell configuration to use awsv2 as the standard aws command. ```bash alias aws='awsv2' ``` -------------------------------- ### AWSAPI.set_credentials Source: https://github.com/youtype/awscliv2/blob/main/README.md Configures AWS credentials for a specific profile. ```APIDOC ## AWSAPI.set_credentials(profile_name, aws_access_key_id, aws_secret_access_key, region) ### Description Sets the AWS credentials and region for a specified profile in the local configuration. ### Parameters - **profile_name** (str) - Required - The name of the profile to configure. - **aws_access_key_id** (str) - Required - The AWS access key ID. - **aws_secret_access_key** (str) - Required - The AWS secret access key. - **region** (str) - Optional - The AWS region to set for the profile. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.