This git repository is designed to demonstrate how to build and publish pip packages to CodeArtifact Repositories in Multiple Regions by using CodePipeline and the AWS CDK.
- Have NPM installed (You can download it by installing Node.js)
- Have the AWS CLI installed and configured
- Have the AWS CDK installed and your AWS Account bootstrapped for all regions to be used
- This sample uses regions
us-east-1
,us-east-2
, andus-west-2
; bootstrap both these regions - Be sure you either have AWS Environment variables set or an AWS CLI profile to provide CDK your Credentials
- This sample uses regions
- Fork the aws-samples/multi-region-python-package-publishing-pipeline repository
git clone [email protected]:<YOUR_GITHUB_USERNAME>/multi-region-python-package-publishing-pipeline.git
cd multi-region-python-package-publishing-pipeline
npm i
- (Optional) Override default configurations for the CodeArtifact domainName, repositoryName, primaryRegion, and replicaRegion
- navigate to
./bin/multiregion_package_publishing.ts
and update relevant fields
- navigate to
cdk deploy --all
from the app root directorymulti-region-python-package-publishing-pipeline/
- Enter
y
for all prompts
- Enter
Look at the CodePipeline that has three stages (Source, Build, and Publish) and the monitor the CodeBuild Projects in the Build/Publish phases while you wait for the pipeline to complete. After ~7 minutes, the pipeline should have a status of success
Navigate to the CodeCommit Repository which has the Source Code for your Custom pip Package. Follow the instructions in the CodeCommit PackageSourceCode
Repository's README (source code originates from this directory) to add a commit to the main
branch and trigger the pipeline to run again
- Configure your local
pip
to use the CodeArtifact Primary (or Replica) Repositoryaws codeartifact login --tool pip --repository package-artifact-repo --domain custom-package-domain --domain-owner <ACCOUNTID>
- Download the package:
pip3 install mypippackage==1.0.0
- Start the Python REPL
python3
>>> import customPackage1
>>> from customPackage1 import module1, module2
>>> from customPackage1.module2 import function2
>>> customPackage1.module1.function1()
This is function1
>>> module1.function1()
This is function1
>>> module2.function2()
This is function2
Time to call function1...
This is function1
>>> function2()
This is function2
Time to call function1...
This is function1
- Destroy cloud resources by running
cdk destroy --all
from the root app directorymulti-region-python-package-publishing-pipeline/
- Reconfigure pip to look at the standard pypi repository
pip3 config set global.index-url https://pypi.org/simple
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.