hamlet-io / executor-bash

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

feat: manage aws auth through profiles #247

Closed roleyfoley closed 3 years ago

roleyfoley commented 3 years ago

Intent of Change

Description

Our existing providers now support environment variable based configuration that in turns configures how authentication is managed to access a cloud provider

The configuration is provided trough environment variables name-spaced under HAMLET_<PROVIDER>_AUTH

Each of these variables can be qualified with the Hamlet Account id to allow for configuring different auth config for different accounts. The values mentioned above are the global values that will be used if a qualified value can't be found

the format for the qualification is HAMLET_<ACCOUNT_NAME>_<CONFIG_VAR> So to override the auth source for an account called ACCT1 the variable would be HAMLET_ACCT1_AWS_AUTH_SOURCE

AWS

The default method is the ENV based approach which aligns with how the Cli normally works. If an AWS config file can be found then the mode will switch to CONFIG unless overridden

For all sources except for the CONFIG source hamlet maintains its own config and credentials file under ${HAMLET_HOME_DIR}/.aws/. This ensures that we don't override user configuration and allows us to name and manage the configuration as we need

After setCredentials has been run there will be 3 variables exported by the script

The AWS cli supports using these values and will use it for all cli calls that are made after they have been set

The script will also validate that the chosen profile can access the requested AWS_ACCOUNT_ID as part of the script. So on each call to setCredentials there will be call to authenticate with the selected profile.

Azure

Motivation and Context

Closes #245 fixes #199 This standardises how we authenticate with cloud providers and defines our approach to authentication. For AWS moving to profile based configuration allows the aws cli to manage credential refresh and removes the need to share and store access keys and secret keys across different scripts.

How Has This Been Tested?

Tested locally across automation and generation scripts using the ENV, USER and CONFIG methods

Related Changes

Prerequisite PRs:

Dependent PRs:

Consumer Actions:

roleyfoley commented 3 years ago

One thing found while testing

If you are generating deployments in a product that you currently don't have access to such as isolated environments and provider access is required the access check script will fail

Added a new HAMLET_AWS_AUTH_SOURCE called NONE . Which similar to the Azure setup will skip the auth process but still allow you to generate a template.

This is different from the current behaviour, but I don't mind it as a feature.

ml019 commented 3 years ago

Added #253 to capture cleanup of credentials post hamlet command runs. Added #254 to capture cleanup of the integrator tree

ml019 commented 3 years ago

@roleyfoley agree adding NONE is a good feature when doing local template generation testing that involves scripts like pregeneration that run provider cli commands.