An open API service indexing awesome lists of open source software.

https://github.com/eigo-mt-fuji/ex-awsconf

Elixir cli tool for generating aws-cli config
https://github.com/eigo-mt-fuji/ex-awsconf

aws docker elixir elixir-lang

Last synced: about 1 year ago
JSON representation

Elixir cli tool for generating aws-cli config

Awesome Lists containing this project

README

          

# README

[![hex.pm version](https://img.shields.io/hexpm/v/ex_awsconf.svg)](https://hex.pm/packages/ex_awsconf)
[![hex.pm](https://img.shields.io/hexpm/l/ex_awsconf.svg)](https://github.com/Eigo-Mt-Fuji/ex-awsconf/blob/master/LICENSE.md)

Simple cli-tool for generating aws config.

(and also generating AWS switch role login links markdown file.)

## Installation

If [available Docker](https://hub.docker.com/r/efgriver/ex-awsconf), the docker image can be installed by `docker pull efgriver/ex-awsconf` command on terminal.

If [available in Hex](https://hexdocs.pm/ex_awsconf), the package can be installed by adding `ex_awsconf` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:ex_awsconf, "~> 0.1.2"}
]
end
```

## Require

* elixir version 1.9 (or later)
* erlang version 21 (or later)

## How to use

* Clone Repository and Get Dependencies

```bash
$ git clone git@github.com:Eigo-Mt-Fuji/ex-awsconf.git
$ cd ex-awsconf/
$ mix deps.get
```

* Prepare csv file(with your aws accounts, save into files directory)

```bash
mkdir -p files/
cat < files/my-accounts.csv
"","","aws IAM-Role name","profile name(aws-cli )","display name(for browser)"
EOF
```

* Build escript

```bash
MIX_ENV=prod mix escript.build
```

* Prepare artifacts directory (results will be saved into this directory.)

```bash
rm -rf ./artifacts
mkdir -p ./artifacts
```

* Execute

```bash
./ex_awsconf ./files ./artifacts json arn:aws:iam:::mfa/
```

- with Docker.

```bash
docker run \
-v $(pwd)/files:/usr/local/src/files:ro \
-v $(pwd)/artifacts:/usr/local/src/artifacts:rw \
efgriver/ex-awsconf:latest \
/usr/local/src/files /usr/local/src/artifacts \
arn:aws:iam:::mfa/ \

```

* Execute Output is JSON format like following.

```json
{
"artifacts": [
{
"aws_config": "./artifacts/my-accounts/config",
"src": "./files/my-accounts.csv",
"switch_role_link_md": "./artifacts/my-accounts/switch_role_link.md"
},
..
],
"status": "ok"
}
```

* aws-cli's config, markdown(for aws switch-role login) should be exists (per each csv file in files directory)

```bash
$ find -type f $(pwd)/artifacts
/Users/fujikawa/Documents/git/ex-awsconf/artifacts/my-accounts/config
/Users/fujikawa/Documents/git/ex-awsconf/artifacts/my-accounts/switch_role_link.md
```