Skip to content

Instantly share code, notes, and snippets.

View hankehly's full-sized avatar

Hank Ehly hankehly

View GitHub Profile
@hankehly
hankehly / company-x-internal-tools.csv
Last active September 12, 2022 00:14
Blog Article Snippets - How to share private code without exposing it to the world
Image URI Short Description Contact
ghcr.io/<company>/start_ec2_instances Starts one or more EC2 instances by their `Name` tag Jane Doe (SRE)
registry.hub.docker.com/<company>/zips3file Downloads, zips and re-uploads a file to S3 John Deere (Data Science)
@hankehly
hankehly / CrossAccountECRPolicy1.json
Created September 12, 2022 00:25
Blog Article Snippets - How to share private code without exposing it to the world
{
"Version": "2012-10-17",
"Id": "CrossAccountECRPolicy1",
"Statement": [
{
"Sid": "AllowPushPull",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::123456789012:user/*"
@hankehly
hankehly / 01_tree.txt
Last active September 12, 2022 00:55
Blog Article Snippets - How to share private code without exposing it to the world
test123
├── test123.py
└── pyproject.toml
@hankehly
hankehly / 01_twine_setup.sh
Last active September 15, 2022 00:17
Blog Article Snippets - How to share private code without exposing it to the world
# Option 1: login command
aws codeartifact login --tool twine --domain <my_domain> --repository test123
# Option 2: environment variables
export TWINE_USERNAME=aws
export TWINE_PASSWORD=`aws codeartifact get-authorization-token --domain <my_domain> --query authorizationToken --output text`
export TWINE_REPOSITORY_URL=`aws codeartifact get-repository-endpoint --domain <my_domain> --repository test123 --format pypi --query repositoryEndpoint --output text`
@hankehly
hankehly / 01_twine_upload.sh
Last active September 15, 2022 00:16
Blog Article Snippets - How to share private code without exposing it to the world
python3 -m pip install --upgrade build twine
python3 -m build
python3 -m twine upload --repository test123 dist/*
@hankehly
hankehly / pip_install.sh
Last active September 15, 2022 00:16
Blog Article Snippets - How to share private code without exposing it to the world
# 1. Obtain an authentication token
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain <my_domain> --query authorizationToken --output text`
# 2. Set the --index-url argument during installation.
# Use the token from (1) as the password for HTTP basic authentication.
python3 -m pip install --index-url "https://aws:${CODEARTIFACT_AUTH_TOKEN}@<my_domain>-<account_id>.d.codeartifact.<region>.amazonaws.com/pypi/test123/simple/" test123==0.0.1
@hankehly
hankehly / requirements-private.txt
Created September 15, 2022 00:07
Blog Article Snippets - How to share private code without exposing it to the world
--index-url https://aws:${CODEARTIFACT_AUTH_TOKEN}@<my_domain>-<account_id>.d.codeartifact.<region>.amazonaws.com/pypi/test123/simple/
test123
@hankehly
hankehly / pyproject.toml
Last active September 15, 2022 00:12
Blog Article Snippets - How to share private code without exposing it to the world
[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = ["example <example@example.com>"]
[[tool.poetry.source]]
name = "test123_codeartifact"
url = "https://<my_domain>-<account_id>.d.codeartifact.<region>.amazonaws.com/pypi/test123/simple/"
@hankehly
hankehly / poetry_install.sh
Created September 15, 2022 00:14
Blog Article Snippets - How to share private code without exposing it to the world
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain <my_domain> --query authorizationToken --output text`
export CODEARTIFACT_USER=aws
poetry config http-basic.test123 $CODEARTIFACT_USER $CODEARTIFACT_AUTH_TOKEN
poetry install
@hankehly
hankehly / build.sh
Created September 15, 2022 00:39
Blog Article Snippets - How to share private code without exposing it to the world
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token \
--duration-seconds 900 \
 --domain <my_domain> \
 --query authorizationToken \
 --output text`
docker build \
 --build-arg CODEARTIFACT_USER=aws \
 --build-arg CODEARTIFACT_AUTH_TOKEN=$CODEARTIFACT_AUTH_TOKEN \
 --tag example \
 .