Package: poetry-plugin-code-artifact
Poetry Plugin: (AWS) Code ArtifactThis package is a plugin that attempts to give improved integration of AWS CodeArtifact repositories with poetry.InstallationThe easiest way to install thecode-artifactplugin is via theself addcommand of Poetry.poetryselfaddpoetry-plugin-code-artifactIf you usedpipxto install Poetry you can add the plugin via thepipx injectcommand.pipxinjectpoetrypoetry-plugin-code-artifactOtherwise, if you usedpipto install Poetry you can add the plugin packages via thepip installcommand.pipinstallpoetry-plugin-code-artifactPrerequisitesIt is assumed there are one or more AWS CodeArtifact repositories set up and that you have a set of credentials that have permissions to available either, to search and download, and/or, publish packages.Identity policiesIn order to grant access to a repository forreadaccess, the following policy will need to be applied to the AWS identity for which credentials will be used to access the repository.{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["sts:GetServiceBearerToken"],"Resource":"*"},{"Effect":"Allow","Action":["codeartifact:DescribeDomain","codeartifact:GetAuthorizationToken","codeartifact:ListRepositoriesInDomain"],"Resource":"arn:aws:codeartifact:us-east-1:345125489763:domain/my-domain"},{"Effect":"Allow","Action":["codeartifact:Describe*","codeartifact:List*","codeartifact:GetPackageVersionReadme","codeartifact:GetRepositoryEndpoint","codeartifact:ReadFromRepository"],"Resource":["arn:aws:codeartifact:us-east-1:345125489763:repository/my-domain/my-repo","arn:aws:codeartifact:us-east-1:345125489763:repository/my-domain/my-repo/*","arn:aws:codeartifact:us-east-1:345125489763:package/my-domain/my-repo/*"]}]}In order to grant access to a repository forwriteaccess, the following policy will need to be applied to the AWS identity for which credentials will be used to access the repository.{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["codeartifact:GetRepositoryEndpoint","codeartifact:PublishPackageVersion","codeartifact:PutPackageMetadata"],"Resource":["arn:aws:codeartifact:us-east-1:345125489763:repository/my-domain/my-repo","arn:aws:codeartifact:us-east-1:345125489763:repository/my-domain/my-repo/*","arn:aws:codeartifact:us-east-1:345125489763:package/my-domain/my-repo/*"]}]}Cross-account policiesFor cross-account access to the AWS CodeArtifact domain, thedomainmust have the resource policy,{"Version":"2012-10-17","Statement":[{"Principal":{"AWS":"arn:aws:iam::345125489763:root"},"Effect":"Allow","Action":["codeartifact:DescribeDomain","codeartifact:GetAuthorizationToken","codeartifact:ListRepositoriesInDomain"],"Resource":"*"}]}For cross-accountreadaccess to a repository, therepositorywill require the following resource policy,{"Version":"2012-10-17","Statement":[{"Principal":{"AWS":"arn:aws:iam::345125489763:root"},"Effect":"Allow","Action":["codeartifact:DescribePackageVersion","codeartifact:DescribeRepository","codeartifact:Get*","codeartifact:List*","codeartifact:ReadFromRepository"],"Resource":"*"}]}For cross-accountwriteaccess, therepositorywill require the following resource policy,{"Version":"2012-10-17","Statement":[{"Principal":{"AWS":"arn:aws:iam::345125489763:root"},"Effect":"Allow","Action":["codeartifact:GetRepositoryEndpoint","codeartifact:PublishPackageVersion","codeartifact:PutPackageMetadata"],"Resource":"*"}]}UsageOther than configuration, usage is the same as adding any other repository to poetry.The plugin is configured in the pyproject.toml file, below is an example of adding three AWS CodeArtifact repositories..[[tool.poetry-plugin-code-artifact.sources]]name="dev"# The name of the repositroy in poetryaws-codeartefact-domain="my-domain"# The AWS CodeArtifact domain.aws-codeartefact-owner="564131876131"# The AWS CodeArtifact domain owner.aws-codeartefact-region="us-east-1"# The AWS CodeArtifact region.aws-codeartefact-repository="dev"# The AWS CodeArtifact repository name.[[tool.poetry-plugin-code-artifact.sources]]name="qa"aws-codeartefact-domain="my-domain"aws-codeartefact-owner="564131876131"aws-codeartefact-region="us-east-1"aws-codeartefact-repository="dev"[[tool.poetry-plugin-code-artifact.sources]]name="prod"aws-codeartefact-domain="my-domain"aws-codeartefact-owner="564131876131"aws-codeartefact-region="eus-east-1"aws-codeartefact-repository="dev"To use the above repositories via poetry, just use the normal commands,Note: You must first be logged into AWS with an identity that has the correct permissions as given in the prerequisites section above. For more information on configuring credentials, seehttps://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html# To add a dependency,poetryaddmy-lib# Searches all repositories# orpoetryaddmy-lib--sourcedev# Prioritizes dev repository then searches all repositories.# To publish a dependency,poetrypublish-rdevRelated Projectswebsite: The official Poetry website and blogpoetry-plugin-export: Export Poetry projects/lock files to
foreign formats like requirements.txt (Used some test code from this project)poetry-plugin-package-info: Poetry Plugin for including project and git information in your distributable files. (Shameless plug to one of my other poetry plugins)