Skip to main content

Gossamer/AWS Alias Generator

Generates Gossamer and AWS aliases based on a single configuration file.

Requirements

Installation

  1. Install the latest release of Gossamer

  2. Make sure the path that you saved Gossamer to is in your $PATH.

    Linux/Mac:

    Add to your .bashrc (Linux) or .bash_profile (Mac):

    export PATH=$PATH:<add the path to the folder containing the Gossamer binary>
    

    Windows:

    https://helpdeskgeek.com/windows-10/add-windows-path-environment-variable/

  3. Install goss-config-gen

    pip install goss-config-gen
    
  4. Add the following to the bottom of your .bash_profile:

    # Generated aliases
    if [ -f $HOME/gossamer/goss-generated-aliases.sh ]; then
        . $HOME/gossamer/goss-generated-aliases.sh
    fi
    

Configuration

The configuration file can be specified manually as an argument --config-file or -c, or it can be set using the GOSS_GEN_CONFIG environment variable. It defaults to $HOME/goss-config.json. This is where goss-config-gen by default expects the configuration file to be stored. A sample configuration file is available to get you started. Customize the values as appropriate.

OutputDirectory

Output directory that files will be written to.

This argument is optional and defaults to $HOME/gossamer.

OutputFile

Output file that will contain all the generated aliases

This argument is optional and defaults to goss-generated-aliases.sh.

RoleAliases

Mapping of aliases to roles.

This argument is optional and allows for the creation of an alias that maps to one or more roles.

"RoleAliases": {
    "all": [
        "path/role1",
        "path/role2
    ]
}

For instance, if you are trying to assume roles path/role1 and path/role2 in all accounts using the above configuration, the generated alias would be goss-all. In addition to these aliases, by default, an alias for each normalized version (/'s are replaced with -'s) of a role name will be created.

GossamerPath

Path to the Gossamer executable. Defaults to /usr/local/bin/gossamer

AWSCredentialsPath

Path to the AWS credentials file. Defaults to $HOME/.aws/credentials

AWSCLIPath

Path to the AWS CLI executable. Defaults to /usr/local/bin/aws

BaseProfile

Base profile that has credentials from which roles can be assumed. This profile should already be configured in your AWS credentials file. Defaults to "default".

Accounts

List of objects contining information about accounts. This argument is required.

Below is an overview of the fields supported by each object.

Field Description Required Defaults
Id Account ID Yes
Name Account Name Yes
Alias String to use in the generated alias (i.e. if this is r1, the generated alias will be goss-r1) No Value of the "Name" field
Region AWS region Yes
Role Role name, including path, to assume Yes

Usage

  1. Run goss-config-gen:

    goss-config-gen
    
  2. Restart your terminal

  3. Use one of the generated aliases. For example, if one of your Alias's is set to a, an alias named goss-a would be generated. The alias can be used as follows:

    goss-a [enter your MFA code here]
    

Importing existing role files

If you already have a number of gossamer role files, you can generated a goss-config-gen configuration file by passing those role files into goss-config-gen.

For example, if you have the following role files:

role-file-1

{
    "Roles": [
        {
            "AccountName": "acct-a",
            "Region": "us-east-1",
            "RoleArn": "arn:aws:iam::123456789012:role/path/role1"
        },
        {
            "AccountName": "acct-b",
            "Region": "us-east-1",
            "Role": "arn:aws:iam::987654321098:role/path/role1"
        }
    ]
}

role-file-2

{
    "Roles": [
        {
            "AccountName": "acct-c",
            "Region": "us-east-1",
            "Role": "arn:aws:iam::123456789012:role/cs/role2"
        },
        {
            "AccountName": "acct-d",
            "Region": "us-east-1",
            "Role": "arn:aws:iam::111111111111:role/cs/role2"
        }
    ]
}

Run the following command to generate the config file:

goss-config-gen \
    --config-file <path-where-config-file-will-be-saved> \
    --import-file <path-to-role-file-1> \
    --import-file <path-to-role-file-2>

Note: The --config-file argument is optional and only needed if the config file should be saved to a custom location.

It will generate the following configuration file that can be used for subsequent

{
    "Accounts": [
        {
            "Id": "123456789012",
            "Name": "acct-a",
            "Region": "us-east-1",
            "Role": "path/role1"
        },
        {
            "Id": "987654321098",
            "Name": "acct-b",
            "Region": "us-east-1",
            "Role": "path/role1"
        },
        {
            "Id": "123456789012",
            "Name": "acct-c",
            "Region": "us-east-1",
            "Role": "path/role2"
        },
        {
            "Id": "111111111111",
            "Name": "acct-d",
            "Region": "us-east-1",
            "Role": "path/role2"
        }
    ]
}

Now to generate the aliases with the new configuration file, simply run goss-config-gen as normal:

goss-config-gen --config-file <path-to-config-file>

Note: Again, the --config-file argument is optional and only needed if the config file is stored in a custom location.

Sample

The sample configuration file will generate the following aliases:

goss-a
goss-b
goss-c
goss-d
goss-e
goss-acct-f

aws-a
aws-b
aws-c
aws-d
aws-e
aws-acct-f

awsi-a
awsi-b
awsi-c
awsi-d
awsi-e
awsi-acct-f

Metadata

Release files for goss-config-gen 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for goss-config-gen 1.3.0
File Size Uploaded
goss-config-gen-1.3.0.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for goss-config-gen 1.3.0
File Interpreter ABI Platform
goss_config_gen-1.3.0-py2-none-any.whl Python 2 none any Details

Total release size: 15.7 kB

Release files / goss-config-gen-1.3.0.tar.gz

Download URL goss-config-gen-1.3.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
de4bc8b44aa66f1b424b46f185f701a8a4b7f693e599bfd04f25b404f7011a36
BLAKE2b-256 checksum
How to use checksums
20d77791116357ccd27f9abf68b589e9b7a7b7339c5a7ab6c8b627a64e4786b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15

Release files / goss_config_gen-1.3.0-py2-none-any.whl

Download URL goss_config_gen-1.3.0-py2-none-any.whl
Size 7.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
4e710866fb7288114b6c06605a99e37ecdc6001aece392f3ef4c8e0a41715a85
BLAKE2b-256 checksum
How to use checksums
9f5cf63e3367871d8e66bee0a296efd609f22c3224e09eb032c09bcbd63b3d21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page