hamlet-io / executor-bash

Executor for hamlet based on bash
GNU General Public License v3.0
0 stars 4 forks source link

Standardise AWS authentication process #245

Closed roleyfoley closed 3 years ago

roleyfoley commented 3 years ago

Expected Behaviour

I can use the same authentication configuration across commands run within the generation commands and those in the automation commands

Current Behaviour

Possible Solution

Extend the environment variable based approach in the automation provider to use profiles as their configuration source and add support for defining the profiles that hamlet uses through the provided env vars

The AWS_AUTOMATION_USER env var would be extended to support different base auth process and essentially become the HAMLET_AWS_AUTH_SOURCE which would permit the following values

When using ROLE,ENV or USER a new config file would be created within HAMLET_HOME_DIR/.aws/config and the AWS_CONFIG_FILE variable would be updated to use that file

Each time setCredentials.sh is called the config file will be updated ( https://docs.aws.amazon.com/cli/latest/reference/configure/set.html ) with the appropriate profile to align with the configuration option.

The different sources would align with the configuration in https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html

ROLE would align with the credential_source profile option ENV would align with the credential_source profile option and the Environment value USER would create a new base profile in the config and subsequent profiles would use this profile as its source_profile

The HAMLET_AWS_AUTH_SOURCE would also support the standard Account ID overrides to handle different accounts using different processes

So HAMLET_MYACCT1_AWS_AUTH_SOURCE would override the source for the account MYACCT1

Context

This provides a standardised way of handing AWS authentication that supports different methods and allows us to automate configuration approach that works locally or across different automation providers in a standard way