Wednesday, December 7, 2022

 

AWS CodeArtifact, NPM, PyPI, Twine, Django & Demo Project.

Introduction:

AWS CodeArtifact is a fully managed artifact repository service that makes it easy for organizations of any size to securely store, publish, and share software packages used in their software development process. CodeArtifact works with commonly used package managers and builds tools like Maven and Gradle (Java), npm and yarn (JavaScript), or pip and twine (Python).

AWS Code Artifact

Pre-requisites for this tutorial:

You should have a basic knowledge of:

  • Linux
  • Python
  • Node
  • Django

Let’s START

Now, without making any delay, let’s get our hand dirty with below 8 steps:

Step1: AWS Environment Setup

1. Login to Aws console

Step 2: Linux & Software installation

6. Setup you Linux box

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"unzip awscliv2.zipsudo ./aws/installaws --version
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codeartifact:*"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "sts:GetServiceBearerToken",
"Resource": "*",
"Condition": {
"StringEquals": {
"sts:AWSServiceName": "codeartifact.amazonaws.com"
}
}
}
]
}

Step 3: Connect to you code artifact repo

8. Login into your AWS code artifact repository command for NPM

aws codeartifact login --tool npm --repository varunArtifact --domain varunartifact --domain-owner 276701924684
yum install tree -ycurl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
Yum install nodejs -y
npm --versionnode --versioncurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bashnvm --versioncd /opt/nvm --versionnvm install --ltsnode --versionnvm -lsyum install gcc-c++ make
nvm use 12npm install -g aws-cdk
mkdir npm_packagecd npm_package/npm initnpm publishnpm install maniknpm
cd ../mkdir npmtempcd npmcd npmtemp/npm install maniknpmtree
git clone https://github.com/manikcloud/CodeArtifact-npm.git
vim package-lock.json
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"maniknpm": {
"version": "1.0.0",
"resolved": "https://varunartifact-276701924684.d.codeartifact.us-east-1.amazonaws.com:443/npm/varunArtifact/maniknpm/-/maniknpm-1.0.0.tgz",
"integrity": "sha512-Znm5+nCW+wwEqguBpR8a9fGV6gukdUC4Bdx7QiipXOWoR7Z8kjGoTL7DZhrO/5HaPUB3OHEAaougimSWgY2UaA=="
}
}
}

PYTHON PyPI

Step 4: Python installation & PyPi setup

13. Install Python 3 from Miniconda

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.shsh Miniconda3-latest-Linux-x86_64.sh
aws codeartifact login --tool pip --repository pypi-store --domain varunartifact --domain-owner 276701924684
pip install django==2.2

Step 5: Create your own Python Package Twine

17. Log in with twine in you was code artifact & create projects

aws codeartifact login --tool twine --repository pypi-store --domain varunartifact --domain-owner 276701924684mkdir projectscd projects
git clone https://github.com/manikcloud/AwsCodeArtifact
python setup.py sdist bdist_wheel

Step 6: Artifact creation and upload AWS Code Artifact

20. Install twine package

pip install twine
twine upload --repository codeartifact dist/manik_notebookc-1.1.3.tar.gz

Step 7: Create a new Django project

23. Start a Django project

django-admin startproject djangocodecd djangocode/
https://github.com/manikcloud/AwsCodeArtifact/tree/master/djangocode
python manage.py runserver 0.0.0.0:8080

Step 8: Verification

26. Verify your version on you AWS console

Step 9: Verify with New version of your Artifact

28. Update your code artifact with the new version of packages

twine upload --repository codeartifact dist/manik_notebookc-1.1.4.tar.gz
pip install manik-notebookc==1.1.4
python manage.py runserver 0.0.0.0:8080

Popular Posts

Evereagle Tech . 2017 Copyright. All rights reserved. Designed by Blogger Template | Manoj Tech