# Poetry AWS Plugin
This is a poetry plugin to help with AWS CodeArtifact authorization by automatically getting the authorization token.
When installing or publishing packages through poetry, the plugin will check whether the command requires CodeArtifact authorization, and if so, adds it automatically.
The plugin will try two methods of authorization, in this order:
1. Use AWS credentials to run `sts.AssumeRole`, then use that role to run `codeartifact.GetAuthorizationToken`.
2. Use AWS credentials to run `codeartifact.GetAuthorizationToken`.
## Installation
To install the plugin
```
poetry self add poetry-aws-plugin
```
To uninstall the plugin
```
poetry self remove poetry-aws-plugin
```
## Usage
You must ensure that your AWS credentials are configured and discoverable by `boto3`. The [`boto3` documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials) has details on how to configure your credentials and the order in which they searched.
When poetry runs a command that uses CodeArtifact, the plugin will automatically check whether the command needs authorization, and if so, requests a CodeArtifact authorization token and adds it to the command.
Your AWS credentials must be authorized to do atleast one of the following:
1. Run [`codeartifact.GetAuthorizationToken`](https://docs.aws.amazon.com/cli/latest/reference/codeartifact/get-authorization-token.html).
2. Run [`sts.AssumeRole`](https://docs.aws.amazon.com/cli/latest/reference/sts/assume-role.html) to assume a role with authorization to run [`codeartifact.GetAuthorizationToken`](https://docs.aws.amazon.com/cli/latest/reference/codeartifact/get-authorization-token.html).
**To use IAM roles to authorize, set the environment variable `POETRY_AWS_PLUGIN_ROLE_ARN` to the role's ARN before running any poetry commands**.
For example:
```bash
POETRY_AWS_PLUGIN_ROLE_ARN='arn:aws:codeartifact:<region>:<account-id>:repository/<domain>/<domain-owner>/<repository>' poetry install
```
or
```bash
echo "export POETRY_AWS_PLUGIN_ROLE_ARN='arn:aws:codeartifact:<region>:<account-id>:repository/<domain>/<domain-owner>/<repository>'" >> ~/.bashrc
source ~/.bashrc
poetry install
```
You can find more details in AWS's [CodeArtifact authentication and tokens documentation](https://docs.aws.amazon.com/codeartifact/latest/ug/tokens-authentication.html) and [CodeArtifact IAM documentation](https://docs.aws.amazon.com/codeartifact/latest/ug/security_iam_service-with-iam.html).
# Misc
You can also authorize by setting the environment variable `POETRY_AWS_PLUGIN_AUTH_TOKEN` to the CodeArtifact authorization token. This may be useful in CI/CD pipelines and reducing poetry configuration.
For example:
```bash
POETRY_AWS_PLUGIN_AUTH_TOKEN='<codeartifact-authorization-token>' poetry install
```
Raw data
{
"_id": null,
"home_page": "https://github.com/xiasongh/poetry-aws-plugin",
"name": "poetry-aws-plugin",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "aws, codeartifact, poetry",
"author": "Song Huang",
"author_email": "xiasongh@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/22/5d/4a2b3bbc156b7e4af9ce7caee5a0c05df4612962d90d4b60496f5ef5f347/poetry_aws_plugin-0.1.12.tar.gz",
"platform": null,
"description": "# Poetry AWS Plugin\n\nThis is a poetry plugin to help with AWS CodeArtifact authorization by automatically getting the authorization token.\n\nWhen installing or publishing packages through poetry, the plugin will check whether the command requires CodeArtifact authorization, and if so, adds it automatically.\n\nThe plugin will try two methods of authorization, in this order:\n\n1. Use AWS credentials to run `sts.AssumeRole`, then use that role to run `codeartifact.GetAuthorizationToken`.\n2. Use AWS credentials to run `codeartifact.GetAuthorizationToken`.\n\n## Installation\n\nTo install the plugin\n\n```\npoetry self add poetry-aws-plugin\n```\n\nTo uninstall the plugin\n\n```\npoetry self remove poetry-aws-plugin\n```\n\n## Usage\n\nYou must ensure that your AWS credentials are configured and discoverable by `boto3`. The [`boto3` documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials) has details on how to configure your credentials and the order in which they searched.\n\nWhen poetry runs a command that uses CodeArtifact, the plugin will automatically check whether the command needs authorization, and if so, requests a CodeArtifact authorization token and adds it to the command.\n\nYour AWS credentials must be authorized to do atleast one of the following:\n\n1. Run [`codeartifact.GetAuthorizationToken`](https://docs.aws.amazon.com/cli/latest/reference/codeartifact/get-authorization-token.html).\n2. Run [`sts.AssumeRole`](https://docs.aws.amazon.com/cli/latest/reference/sts/assume-role.html) to assume a role with authorization to run [`codeartifact.GetAuthorizationToken`](https://docs.aws.amazon.com/cli/latest/reference/codeartifact/get-authorization-token.html).\n\n**To use IAM roles to authorize, set the environment variable `POETRY_AWS_PLUGIN_ROLE_ARN` to the role's ARN before running any poetry commands**.\n\nFor example:\n\n```bash\nPOETRY_AWS_PLUGIN_ROLE_ARN='arn:aws:codeartifact:<region>:<account-id>:repository/<domain>/<domain-owner>/<repository>' poetry install\n```\n\nor\n\n```bash\necho \"export POETRY_AWS_PLUGIN_ROLE_ARN='arn:aws:codeartifact:<region>:<account-id>:repository/<domain>/<domain-owner>/<repository>'\" >> ~/.bashrc\nsource ~/.bashrc\npoetry install\n```\n\nYou can find more details in AWS's [CodeArtifact authentication and tokens documentation](https://docs.aws.amazon.com/codeartifact/latest/ug/tokens-authentication.html) and [CodeArtifact IAM documentation](https://docs.aws.amazon.com/codeartifact/latest/ug/security_iam_service-with-iam.html).\n\n# Misc\n\nYou can also authorize by setting the environment variable `POETRY_AWS_PLUGIN_AUTH_TOKEN` to the CodeArtifact authorization token. This may be useful in CI/CD pipelines and reducing poetry configuration.\n\nFor example:\n\n```bash\nPOETRY_AWS_PLUGIN_AUTH_TOKEN='<codeartifact-authorization-token>' poetry install\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A poetry plugin to help with AWS CodeArtifact authorization automatically",
"version": "0.1.12",
"project_urls": {
"Homepage": "https://github.com/xiasongh/poetry-aws-plugin",
"Repository": "https://github.com/xiasongh/poetry-aws-plugin"
},
"split_keywords": [
"aws",
" codeartifact",
" poetry"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "52535b60417f1eaea5e8454afff8a1cc57610d80cf92235a4fb590f393a30c4c",
"md5": "9f50d1e4b2f163b317c5dfb47f8cd554",
"sha256": "ca4e33f5a8c178b8ce5329ae26b054faa0d2c51f3fe0a01d19c0169bef48ffd2"
},
"downloads": -1,
"filename": "poetry_aws_plugin-0.1.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9f50d1e4b2f163b317c5dfb47f8cd554",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 5320,
"upload_time": "2024-05-02T17:10:01",
"upload_time_iso_8601": "2024-05-02T17:10:01.818496Z",
"url": "https://files.pythonhosted.org/packages/52/53/5b60417f1eaea5e8454afff8a1cc57610d80cf92235a4fb590f393a30c4c/poetry_aws_plugin-0.1.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "225d4a2b3bbc156b7e4af9ce7caee5a0c05df4612962d90d4b60496f5ef5f347",
"md5": "61b33e06fdf9fa8fff75366903843c9e",
"sha256": "19a261f9c38a91c5f9a80f074cbdafb3ef29ff40580d916327c16b4f87e4800f"
},
"downloads": -1,
"filename": "poetry_aws_plugin-0.1.12.tar.gz",
"has_sig": false,
"md5_digest": "61b33e06fdf9fa8fff75366903843c9e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 4329,
"upload_time": "2024-05-02T17:10:03",
"upload_time_iso_8601": "2024-05-02T17:10:03.358367Z",
"url": "https://files.pythonhosted.org/packages/22/5d/4a2b3bbc156b7e4af9ce7caee5a0c05df4612962d90d4b60496f5ef5f347/poetry_aws_plugin-0.1.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-02 17:10:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xiasongh",
"github_project": "poetry-aws-plugin",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "poetry-aws-plugin"
}