@@ -26,29 +26,37 @@ xattr -dr com.apple.quarantine ~/aws-sso-config-generator
2626chmod +x ~/aws-sso-config-generator
2727#+end_example
2828
29+ More information here https://apple.stackexchange.com/a/436677
30+
2931** Usage
3032*Note: if no parameters are passed user will be prompted for ~region~ and ~start_url~.*
3133
3234Example call of ~aws-sso-config-generator~ where AWS access portal is in ~us-west-2~ with a url of ~https://<example>.awsapps.com/start/#/~.
3335
3436#+begin_example
35- aws-sso-config-generator --region us-west-2 --start-url https://<example>.awsapps.com/start/#/
37+ aws-sso-config-generator --region us-west-2 --sso-region us-east-1 -- start-url https://<example>.awsapps.com/start/#/
3638#+end_example
3739
3840#+begin_example
39- aws-sso-config-generator -r us-west-2 -u https://<example>.awsapps.com/start/#/
41+ aws-sso-config-generator -r us-west-2 --sso-region us-east-1 - u https://<example>.awsapps.com/start/#/
4042#+end_example
4143
4244** Parameters
4345
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 |
46+ | Option | Type | Example | Description | Default |
47+ |---------------------+--------+-------------------------------------------+-------------------------------------------------+-----------------------------|
48+ | --sso-region | string | --sso-region us-west-2 | Region where AWS resources are hosted. | |
49+ | --region or -r | string | -r us-west-2 | Region where AWS access portal is hosted. | |
50+ | --start-url or -u | string | -u https://<example>.awsapps.com/start/#/ | The URL for the AWS access portal | |
51+ | --help or -h | N/A | -h | Help menu | |
52+ | --template or -t | string | -t ~/.aws/config.template.json | JSON template file to re-kap accounts and roles | ~/.aws/config.template.json |
53+ | --out or -o | string | -o ~/.aws/config.generated | Output file for generated AWS config file | ~/.aws/config.generated |
54+
4955
50- ** Example Config (~/.aws/sso .generated)
56+ ** Example Config (~/.aws/config .generated)
5157
58+ ~/.aws/config.generated:
59+ #+name: ~/.aws/config.generated
5260#+begin_example
5361# config generated via https://github.com/djgoku/aws-sso-config-generator
5462#
@@ -57,14 +65,45 @@ aws-sso-config-generator -r us-west-2 -u https://<example>.awsapps.com/start/#/
5765# 1. log into aws sso via `aws sso login --profile use-any-profile-name`
5866# 2. validate `AWS_PROFILE=use-any-profile-name aws sts get-caller-identity`
5967
60- # AWS_CONFIG_FILE=~/.aws/config.generated AWS_PROFILE=1111111-RoleName aws sts get-caller-identity
61- [profile 1111111-RoleName ]
68+ # AWS_CONFIG_FILE=~/.aws/config.generated AWS_PROFILE=1111111-ReadOnly aws sts get-caller-identity
69+ [profile 1111111-ReadOnly ]
6270sso_start_url = https://<example>.awsapps.com/start/#/
6371sso_region = us-east-2
6472sso_account_id = 1111111
65- sso_role_name = RoleName
73+ sso_role_name = ReadOnly
6674region = us-west-2
6775output = json
76+
77+ # AWS_CONFIG_FILE=~/.aws/config.generated AWS_PROFILE=1111111-ReadOnly aws sts get-caller-identity
78+ [profile 1111111-ReadOnly]
79+ sso_start_url = https://<example>.awsapps.com/start/#/
80+ sso_region = us-east-2
81+ sso_account_id = 1111111
82+ sso_role_name = ReadOnly
83+ region = us-west-2
84+ output = json
85+ #+end_example
86+
87+ ** Example JSON Template (~/.aws/config.template.json)
88+
89+ In the =template.json= structure, the values under the =accounts= and =roles= keys are used to replace their respective keys during config generation. For example:
90+ - ="111111"= in =accounts= will be replaced with ="dev"=
91+ - ="Admin"= in =roles= will be replaced with =""= (empty string)
92+
93+ ~/.aws/config.template:
94+ #+name: ~/.aws/config.template
95+ #+begin_example
96+ {
97+ "accounts": {
98+ "111111": "dev",
99+ "222222": "uat",
100+ "333333": "prod"
101+ },
102+ "roles": {
103+ "Admin": "",
104+ "ReadOnly": "read"
105+ }
106+ }
68107#+end_example
69108
70109** Development
0 commit comments