Skip to content

Commit

Permalink
Doc Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
castrapel committed Mar 4, 2023
1 parent cf85394 commit ee9eb81
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
id: build-container
run: |
docker logout ghcr.io
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/o4z3c2v2
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/iambic
. build-env/bin/activate && make build_docker
make trivy_scan
make trivy_sbom
make upload_docker
docker logout public.ecr.aws/o4z3c2v2
docker logout public.ecr.aws/iambic
docker buildx prune --filter=until=96h -f
- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/o4z3c2v2/iambic_container_base:1.0
FROM public.ecr.aws/iambic/iambic_container_base:1.0

ARG FUNCTION_DIR="/app"
WORKDIR ${FUNCTION_DIR}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
BUILD_VERSION := $(shell python build_utils/tag_and_build_container.py print-current-version)
IAMBIC_PUBLIC_ECR_ALIAS := o4z3c2v2
IAMBIC_PUBLIC_ECR_ALIAS := iambic

.PHONY: prepare_for_dist
prepare_for_dist:
rm -f proposed_changes.yaml # especially important if this is run locally

.PHONY: auth_to_ecr
auth_to_ecr:
bash -c "AWS_PROFILE=iambic_open_source/iambic_image_builder aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/o4z3c2v2"
bash -c "AWS_PROFILE=iambic_open_source/iambic_image_builder aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/${IAMBIC_PUBLIC_ECR_ALIAS}"

docker_buildx := docker buildx build \
--platform=linux/amd64 \
Expand Down
2 changes: 1 addition & 1 deletion deployment/github_app/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ variable "iambic_public_repo_url" {
type = string
description = "Iambic Public Repo URL"

default = "public.ecr.aws/o4z3c2v2"
default = "public.ecr.aws/iambic"
}

variable "iambic_image_name" {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
iambic-cicd:
# NOTE: This compose file loads the image from ECR, not from what you are running
# locally.
image: public.ecr.aws/o4z3c2v2/iambic:latest
image: public.ecr.aws/iambic/iambic:latest
environment:
- IAMBIC_CONFIG=arn:aws:secretsmanager:us-west-2:759357822767:secret:dev/iambic-full
- IAMBIC_CONFIG_ASSUME_ROLE=arn:aws:iam::759357822767:role/IambicSpokeRole
Expand Down
2 changes: 2 additions & 0 deletions docs/web/docs/1-getting_started/1-install_and_configure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ git init
cat <<EOF > .gitignore
**/secrets.yaml
proposed_changes.yaml
env/
venv/
EOF
```

Expand Down
1 change: 0 additions & 1 deletion docs/web/docs/1-getting_started/2-aws.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ After configuring IAMbic, you should see your accounts referenced in your reposi
Feel free to move this file around in the repository. When IAMbic is run, it will look for the configuration
by referencing the `template_type` and it expects to find a template_type of `NOQ::Core::Config`.


### 2. Import AWS Resources

After configuring IAMbic for AWS, run the `iambic import` command from the repository you created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ toc_max_heading_level: 5

Before you begin, you'll need to have the following tools installed on your system:

* Docker

If you don't have these tools installed, follow the instructions below:

* [Install Docker](https://docs.docker.com/get-docker/)
* Docker ([Install Docker](https://docs.docker.com/get-docker/))

### Steps

Expand All @@ -24,38 +20,38 @@ To run the docker container locally, you can use the docker command:

Basic run:

docker run public.ecr.aws/s2p9s3r8/iambic:latest <command>
docker run public.ecr.aws/iambic/iambic:latest <command>

We recommend mounting a local volume for the templates that are imported:

docker run -it -v <local_dir>:/templates public.ecr.aws/s2p9s3r8/iambic:latest <command>
docker run -it -v <local_dir>:/templates public.ecr.aws/iambic/iambic:latest <command>

If you want to run IAMbic from the current directory, you can use a BASH trick to get the current working directory:

docker run -it -v ${pwd}:/templates public.ecr.aws/s2p9s3r8/iambic:latest <command>
docker run -it -v ${pwd}:/templates public.ecr.aws/iambic/iambic:latest <command>

It is best to run as the current user to make sure that templates written to disk are written in the user and group currently active on the host:

docker run -it -u $(id -u):$(id -g) -v ${pwd}:/templates public.ecr.aws/s2p9s3r8/iambic:latest <command>
docker run -it -u $(id -u):$(id -g) -v ${pwd}:/templates public.ecr.aws/iambic/iambic:latest <command>

Optionally you can store the volume in your system's docker context - be forwarned that the docker context could be coerced to delete the volume without warning using a command like `docker system prune` - it is generally best to store templates on your hard drive in a place where the chances of accidental deletion are minimized:

docker run -it -u $(id -u):$(id -g) -v /templates public.ecr.aws/s2p9s3r8/iambic:latest <command>
docker run -it -u $(id -u):$(id -g) -v /templates public.ecr.aws/iambic/iambic:latest <command>

Depending on where your cloud credentials are stored, you may have to mount the relevant directory inside the docker container as well:

docker run -it -u $(id -u):$(id -g) -v ${HOME}/.aws:/app/.aws -e AWS_CONFIG_FILE=/app/.aws/config -e AWS_SHARED_CREDENTIALS_FILE=/app/.aws/credentials -e "AWS_PROFILE=${AWS_PROFILE}" -v ${pwd}:/templates:Z public.ecr.aws/s2p9s3r8/iambic:latest <command>
docker run -it -u $(id -u):$(id -g) -v ${HOME}/.aws:/app/.aws -e AWS_CONFIG_FILE=/app/.aws/config -e AWS_SHARED_CREDENTIALS_FILE=/app/.aws/credentials -e "AWS_PROFILE=${AWS_PROFILE}" -v ${pwd}:/templates:Z public.ecr.aws/iambic/iambic:latest <command>

### Shortcut

We recommend that you add the following to your ~/.bashrc or ~/.bash_profile:

```bash
echo 'alias iambic="docker run -it -u $(id -u):$(id -g) -v ${HOME}/.aws:/app/.aws -e AWS_CONFIG_FILE=/app/.aws/config -e AWS_SHARED_CREDENTIALS_FILE=/app/.aws/credentials -e "AWS_PROFILE=${AWS_PROFILE}" -v <local_dir\>:/templates:Z public.ecr.aws/s2p9s3r8/iambic:latest <command>"' >> ~/.bashrc
echo 'alias iambic="docker run -it -u $(id -u):$(id -g) -v ${HOME}/.aws:/app/.aws -e AWS_CONFIG_FILE=/app/.aws/config -e AWS_SHARED_CREDENTIALS_FILE=/app/.aws/credentials -e "AWS_PROFILE=${AWS_PROFILE}" -v <local_dir\>:/templates:Z public.ecr.aws/iambic/iambic:latest <command>"' >> ~/.bashrc
```

```zsh
echo 'alias iambic="docker run -it -u $(id -u):$(id -g) -v ${HOME}/.aws:/app/.aws -e AWS_CONFIG_FILE=/app/.aws/config -e AWS_SHARED_CREDENTIALS_FILE=/app/.aws/credentials -e "AWS_PROFILE=${AWS_PROFILE}" -v <local_dir\>:/templates:Z public.ecr.aws/s2p9s3r8/iambic:latest <command>"' >> ~/.zshrc
echo 'alias iambic="docker run -it -u $(id -u):$(id -g) -v ${HOME}/.aws:/app/.aws -e AWS_CONFIG_FILE=/app/.aws/config -e AWS_SHARED_CREDENTIALS_FILE=/app/.aws/credentials -e "AWS_PROFILE=${AWS_PROFILE}" -v <local_dir\>:/templates:Z public.ecr.aws/iambic/iambic:latest <command>"' >> ~/.zshrc
```

That way you can just execute iambic seamlessly as an application within your system:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Install IAMbic via Python Wheel
toc_min_heading_level: 2
toc_max_heading_level: 5
---

## Pre-requisites

* Python 3.10 or later

## Install Python if you have not already

To download IAMbic from PyPI, you will need to ensure that Python is installed on your machine. Here are two methods for installing Python:

### Method 1: Python

1. Go to the [Python Downloads page]( https://www.python.org/downloads) and download and install Python 3.10 or later.
1. Create a virtual environment and install IAMbic by running the following commands:

```bash
# Create a directory for your iambic templates if you didn't already create one
mkdir iambic-templates
cd iambic-templates

# Create a virtual environment to store iambic and its dependencies
python -m venv venv
. venv/bin/activate

# Install IAMbic
pip install iambic-core
```

Test by running `iambic --help`

### Method 2: Use pyenv (Recommended for managing multiple versions of Python)

1. Install [pyenv](https://github.com/pyenv/pyenv) by following the instructions on their GitHub page. (`brew install pyenv` on Mac)
1. Install [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) by following the instructions on their GitHub page. (`brew install pyenv-virtualenv` on Mac)
1. Create a virtual environment and install IAMbic by running the following commands:

```bash
# Install the desired version of Python (replace 3.10 with your desired version).
pyenv install 3.10
# Set the Python version globally with `pyenv global 3.10` or locally within a folder with `pyenv local 3.10`.
pyenv local 3.10
# Create a virtual environment (replace 3.10 and iambic with your desired version and environment name).
pyenv virtualenv 3.10 iambic
# Activate the virtual environment
pyenv activate iambic
# Install IAMbic
pip install iambic-core
```

Test by running `iambic --help`

This file was deleted.

4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fi

echo

ECR_PATH="public.ecr.aws/o4z3c2v2/iambic:latest"
ECR_PATH="public.ecr.aws/iambic/iambic:latest"

echo "Installing iambic..."
DOCKER_CMD="#!/bin/bash
Expand All @@ -53,7 +53,7 @@ done
ENV_VAR_ARGS=\"\$ENV_VAR_ARGS -e AWS_SHARED_CREDENTIALS_FILE=/app/.aws/credentials\"
ENV_VAR_ARGS=\"\$ENV_VAR_ARGS -e AWS_CONFIG_FILE=/app/.aws/config\"
docker run -w /templates -it -u \$(id -u):\$(id -g) -v \${HOME}/.aws:/app/.aws \$ENV_VAR_ARGS --mount \"type=bind,src=\$(pwd),dst=/templates\" public.ecr.aws/o4z3c2v2/iambic:latest \"\$@\""
docker run -w /templates -it -u \$(id -u):\$(id -g) -v \${HOME}/.aws:/app/.aws \$ENV_VAR_ARGS --mount \"type=bind,src=\$(pwd),dst=/templates\" public.ecr.aws/iambic/iambic:latest \"\$@\""

echo

Expand Down

0 comments on commit ee9eb81

Please sign in to comment.