Skip to content

Commit 4c7a82d

Browse files
committed
feat: Start of aws-sso-config-generator
0 parents  commit 4c7a82d

File tree

14 files changed

+1225
-0
lines changed

14 files changed

+1225
-0
lines changed

.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

.github/workflows/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: main
2+
on:
3+
push:
4+
branches:
5+
- main
6+
env:
7+
DEVBOX_API_TOKEN: ${{ secrets.DEVBOX_API_TOKEN }}
8+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
if: github.repository_owner == 'djgoku'
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Install devbox with empty devbox.json
16+
uses: jetify-com/[email protected]
17+
with:
18+
enable-cache: 'true'
19+
- name: upload release artifacts
20+
run: |
21+
set -x
22+
devbox run do-all
23+
devbox run version-info

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# If the VM crashes, it generates a dump, let's ignore it too.
14+
erl_crash.dump
15+
16+
# Also ignore archive artifacts (built via "mix archive.build").
17+
*.ez
18+
19+
# Ignore package tarball (built via "mix hex.build").
20+
aws_sso_config_generator-*.tar
21+
22+
# Temporary files, for example, from tests.
23+
/tmp/
24+
25+
/burrito_out/
26+
27+
.DS_Store
28+
29+
notes.org
30+
31+
.devbox

README.org

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#+STARTUP: inlineimages
2+
3+
* AwsSsoConfigGenerator
4+
5+
Tool to generate an AWS config file (~​~/.aws/config~) (our file is saved to ~​~/.aws/config.generated~) after authenticating and authorizing AWS SSO IAM Identity Center.
6+
7+
** Downloads
8+
9+
Available downloads for macOS (x86 and m series), linux (x86 and arm64) and windows.
10+
11+
*** macOS
12+
13+
On macOS you will get a popup if you run without doing the below.
14+
15+
~Apple could not verify “aws-sso-config-generator” is free of malware that may harm your Mac or compromise your privacy.~
16+
17+
#+caption: macOS Apple popup could not verify
18+
[[file:./images/macos-popup.png]]
19+
20+
**** Allow executable to not be quarantined
21+
22+
Make sure to only do this for verified executable downloaded from https://github.com/djgoku/aws-sso-config-generator or built locally.
23+
24+
#+begin_example
25+
xattr -dr com.apple.quarantine ~/aws-sso-config-generator
26+
chmod +x ~/aws-sso-config-generator
27+
#+end_example
28+
29+
** Usage
30+
*Note: if no parameters are passed user will be prompted for ~region~ and ~start_url~.*
31+
32+
Example call of ~aws-sso-config-generator~ where AWS access portal is in ~us-west-2~ with a url of ~https://​<example>.awsapps.com/start/#/~.
33+
34+
#+begin_example
35+
aws-sso-config-generator --region us-west-2 --start-url https://<example>.awsapps.com/start/#/
36+
#+end_example
37+
38+
#+begin_example
39+
aws-sso-config-generator -r us-west-2 -u https://<example>.awsapps.com/start/#/
40+
#+end_example
41+
42+
** Parameters
43+
44+
| Option | Type | Example | Description |
45+
|---------------------+--------+-------------------------------------------+-------------------------------------------|
46+
| --region or -r | string | -r us-west-2 | Region where AWS access portal is hosted. |
47+
| --start-url or -u | string | -u https://<example>.awsapps.com/start/#/ | The URL for the AWS access portal |
48+
| --help or -h | N/A | -h | Help menu |
49+
50+
** Example Config (~/.aws/sso.generated)
51+
52+
#+begin_example
53+
# config generated via https://github.com/djgoku/aws-sso-config-generator
54+
#
55+
# This requires AWS CLI v2
56+
#
57+
# 1. log into aws sso via `aws sso login --profile use-any-profile-name`
58+
# 2. validate `AWS_PROFILE=use-any-profile-name aws sts get-caller-identity`
59+
60+
# AWS_CONFIG_FILE=~/.aws/config.generated AWS_PROFILE=1111111-RoleName aws sts get-caller-identity
61+
[profile 1111111-RoleName]
62+
sso_start_url = https://<example>.awsapps.com/start/#/
63+
sso_region = us-east-2
64+
sso_account_id = 1111111
65+
sso_role_name = RoleName
66+
region = us-west-2
67+
output = json
68+
#+end_example
69+
70+
** Development
71+
72+
1. Clone repository
73+
2. ~devbox run do-all~
74+
75+
** FAQ
76+
77+
*** Why am I seeing an old version of an aws-sso-config-generator?
78+
79+
You might need to clean-up old resources from a previous version and re-run the application.
80+
81+
#+begin_example
82+
./burrito_out/aws_sso_config_generator maintenance uninstall
83+
[w] This will uninstall the application runtime for this Burrito binary!
84+
[?] Please confirm this action [y/n]: y
85+
y
86+
[i] Deleting directory: /home/devbox/.local/share/.burrito/aws_sso_config_generator_erts-15.2.2_0.1.0
87+
[i] Uninstall complete!
88+
[i] Quitting.
89+
#+end_example
90+
91+
*** How do these binaries work?
92+
93+
We are using [[https://github.com/burrito-elixir/burrito][burrito]] which packages everything required to run the application into a self-extracting executable. Once ran the application is extracted and then ran.
94+
95+
** References
96+
*** Elixir
97+
- https://github.com/burrito-elixir/burrito
98+
- https://github.com/aws-beam/aws-elixir
99+
100+
*** Other
101+
- https://github.com/jetify-com/devbox
102+
- https://stackoverflow.com/a/71850591
103+
- https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html

devbox.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.14.0/.schema/devbox.schema.json",
3+
"packages": {
4+
"beam.packages.erlang_27.elixir_1_18": "",
5+
"erlang": "latest",
6+
"beam27Packages.elixir-ls": "latest",
7+
"git": "latest",
8+
"zig": "latest",
9+
"xz": "latest",
10+
"_7zz": "latest",
11+
"github-cli": "latest",
12+
"curl": "latest",
13+
"darwin.apple_sdk.frameworks.CoreServices": {
14+
"platforms": [
15+
"aarch64-darwin",
16+
"x86_64-darwin",
17+
],
18+
},
19+
"act": "latest",
20+
},
21+
"env": {
22+
"ELIXIR_ERL_OPTIONS": "+fnu",
23+
},
24+
"shell": {
25+
"init_hook": [
26+
"mkdir -p .nix-mix",
27+
"mkdir -p .nix-hex",
28+
"export MIX_HOME=$PWD/.nix-mix",
29+
"export HEX_HOME=$PWD/.nix-hex",
30+
"export ERL_AFLAGS='-kernel shell_history enabled'",
31+
"mix local.hex --force",
32+
"mix local.rebar --force",
33+
],
34+
"scripts": {
35+
"do-all": [
36+
"mix deps.get --only prod",
37+
"mix format --check-formatted",
38+
"MIX_ENV=prod mix release --overwrite"
39+
],
40+
"version-info": [
41+
"MIX_APPLICATION_VERSION=$(elixir -e 'Regex.run(~r/version: \"(\\d+.\\d+.\\d+)\"/, File.read!(\"mix.exs\"), capture: :all_but_first) |> List.first() |> IO.puts()')",
42+
"echo \"version $MIX_APPLICATION_VERSION\"",
43+
"cd burrito_out",
44+
"bash -c 'for file in *_*; do mv \"$file\" \"${file//_/-}\"; done'",
45+
"shasum -a 256 ./* > aws-sso-config-generator-checksums.txt",
46+
"cd -",
47+
"gh release create ${MIX_APPLICATION_VERSION} --generate-notes",
48+
"gh release upload ${MIX_APPLICATION_VERSION} ./burrito_out/* -R djgoku/aws-sso-config-generator"
49+
]
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)