Add documentation
This commit is contained in:
parent
7f6d282cda
commit
a095a988fd
2 changed files with 24 additions and 3 deletions
23
README.md
23
README.md
|
|
@ -46,4 +46,25 @@ variable "workspace" {
|
|||
}
|
||||
```
|
||||
|
||||
This will make Terraform lookup AWS credentials from the `~/.aws/credentials` file using the workspace name as the stanza name. For example the credentials file would look like the shared-creds file in this repo.
|
||||
This will make Terraform lookup AWS credentials from the `~/.aws/credentials` file using the workspace name as the stanza name. For example the credentials file would look like the shared-creds file in this repo.
|
||||
|
||||
## atmos -t
|
||||
|
||||
Adding the `-t` flag to atmos will make it generate a new `~/.aws/credentials` file from environment variables. You must first include the `default` access key ID & secret access key like this:
|
||||
|
||||
```
|
||||
DEFAULT_ACCESS_KEY_ID=id
|
||||
DEFAULT_SECRET_ACCESS_KEY=key
|
||||
```
|
||||
|
||||
All additional workspaces need to be prefixed in the same way:
|
||||
|
||||
```
|
||||
DEV_ACCESS_KEY_ID=id
|
||||
DEV_SECRET_ACCESS_KEY=key
|
||||
|
||||
QA_ACCESS_KEY_ID=id
|
||||
QA_SECRET_ACCESS_KEY=key
|
||||
```
|
||||
|
||||
Note: Atmos will override your default credentials file as this functionality is for use in a docker container or in situations where you would rather use variables.
|
||||
4
atmos.py
4
atmos.py
|
|
@ -7,7 +7,7 @@ def main(argv):
|
|||
parser = argparse.ArgumentParser(description='Control Terraform Workspaces.')
|
||||
g = parser.add_mutually_exclusive_group()
|
||||
g.add_argument("command", help="Send commands to terraform with workspace variable context", nargs='?', default=False)
|
||||
parser.add_argument("-t", help="Template mode, gather shared-creds from environment variables", action='store_true', default=False)
|
||||
parser.add_argument("-t", help="Template mode, gather shared-creds from environment variables (Dont use this flag if you dont want your ~/.aws/credentials replaced. This is for CI/CD", action='store_true', default=False)
|
||||
args, params = parser.parse_known_args()
|
||||
if args.command:
|
||||
determine_actions(args, params)
|
||||
|
|
@ -42,7 +42,7 @@ def generate_creds():
|
|||
contents = contents + "[{workspace}]\n".format(workspace=workspace)
|
||||
contents = contents + "access_key_id=" + os.environ.get(workspace.upper() + '_ACCESS_KEY_ID') + "\n"
|
||||
contents = contents + "secret_access_key=" + os.environ.get(workspace.upper() + '_SECRET_ACCESS_KEY') + "\n"
|
||||
with open(os.path.expanduser('~/.aws/credentials.atmos'), 'w+') as f:
|
||||
with open(os.path.expanduser('~/.aws/credentials'), 'w+') as f:
|
||||
f.write(contents)
|
||||
|
||||
def get_valid_envs():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue