Skip to content

Commit

Permalink
docs(codeartifact): 📝 Add a simple generic package example to codeart…
Browse files Browse the repository at this point in the history
…ifact
  • Loading branch information
chrisguest75 committed May 14, 2024
1 parent 91d3b0b commit 025ce56
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
42 changes: 42 additions & 0 deletions 33_awscli/CODEARTIFACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ TODO:

* Create a domain and repository

NOTES:

- CodeArtifact supports NPM, pypi and generic artifacts.
- Downloading a generic artifact still requires `awscli`.

## Contents

- [CODEARTIFACT](#codeartifact)
- [Contents](#contents)
- [Prepare](#prepare)
- [Login](#login)
- [Pipenv](#pipenv)
- [Interrogate](#interrogate)
- [Generic Packages](#generic-packages)
- [Resoures](#resoures)

## Prepare

```sh
Expand All @@ -20,6 +36,8 @@ export PAGER=
# get name, domainname and domainowner for login
aws codeartifact list-repositories

aws codeartifact list-repositories | jq '.repositories[] | select(.name == "codeartifact-test")'

export CODEARTIFACT_DOMAIN=mydomain
export CODEARTIFACT_DOMAIN_OWNER=000000000000
export CODEARTIFACT_REPOSITORY=myrepo
Expand Down Expand Up @@ -70,10 +88,34 @@ aws codeartifact list-package-versions --domain $CODEARTIFACT_DOMAIN --domain-ow
aws codeartifact list-package-version-dependencies --domain $CODEARTIFACT_DOMAIN --domain-owner $CODEARTIFACT_DOMAIN_OWNER --repository ${CODEARTIFACT_REPOSITORY} --package codeartifact_test_package --format pypi --package-version 0.0.2
```

## Generic Packages

```sh
mkdir -p ./generic-package/in ./generic-package/out

cat >./generic-package/in/files.txt <<EOF
CODEARTIFACT.md
BATCH.md
EOF

# create a tar from a list of files
tar -a -cvf ./generic-package/out/test.tar.gz -T ./generic-package/in/files.txt

export ASSET_SHA256=$(sha256sum ./generic-package/out/test.tar.gz | awk '{print $1;}')
echo $ASSET_SHA256

# publish package
aws codeartifact publish-package-version --domain $CODEARTIFACT_DOMAIN --repository $CODEARTIFACT_REPOSITORY --format generic --namespace my-ns --package test-generic-package --package-version 1.0.0 --asset-content ./generic-package/out/test.tar.gz --asset-name test.tar.gz --asset-sha256 $ASSET_SHA256

# download package
aws codeartifact get-package-version-asset --domain $CODEARTIFACT_DOMAIN --repository $CODEARTIFACT_REPOSITORY --format generic --namespace my-ns --package test-generic-package --package-version 1.0.0 --asset test.tar.gz ./generic-package/out/downloaded-test.tar.gz
```

## Resoures

* AWS CodeArtifact concepts [here](https://docs.aws.amazon.com/codeartifact/latest/ug/codeartifact-concepts.html)
* codeartifact awscli [here](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/codeartifact/index.html)
* How to Import Private Python Packages with pipenv and Gitlab [here](https://medium.com/@matt_tich/how-to-use-private-python-packages-with-pipenv-and-gitlab-8d35f73e5329)
* Using CodeArtifact as Pypi mirror for Pipenv [gist](https://gist.github.com/smparekh/a2bf43e514f65b920c8ca8fb55aaefbb)
* Injecting credentials into Pipfile via environment variables [here](https://pipenv.pypa.io/en/latest/credentials.html)
* Generic packages overview [here](https://docs.aws.amazon.com/codeartifact/latest/ug/generic-packages-overview.html)
4 changes: 4 additions & 0 deletions 73_creating_archives/TAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ EOF

# create a tar from a list of files
tar -cvf ./out/test.tar -T ./in/files.txt
# auto compress with extension tgz (creates tar.gz)
tar -a -cvf ./out/test.tgz -T ./in/files.txt
# works as well
tar -a -cvf ./out/test.tar.gz -T ./in/files.txt
```

## List
Expand Down

0 comments on commit 025ce56

Please sign in to comment.