Merge branch 'master' of gitlab.com:spengreb/atmos

This commit is contained in:
Conor McManus 2023-01-24 15:06:56 +01:00
commit 4829fe8f54
3 changed files with 6 additions and 8 deletions

View file

@ -65,7 +65,7 @@ This will make Terraform lookup AWS credentials from the `~/.aws/credentials` fi
## atmos -e
Adding the `-e` flag to atmos will make it generate a new `~/.aws/credentials-atmos` file from environment variables. You must first include the `default` access key ID & secret access key like this:
Adding the `-e` 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
@ -82,8 +82,6 @@ QA_ACCESS_KEY_ID=id
QA_SECRET_ACCESS_KEY=key
```
This requires a `shared_credentials_file` variable on the top level. To support standard Terraform workflows its recommened to default this to the default shared credentials file location `$HOME/.aws/credentials`. Atmos will then handle the overriding safely in the background
# atmos -m
Adding `-m` flag will set to manual mode. It will not try to automatically switch workspace per branch. It will adhere to whatever you last set the workspace to.

View file

@ -8,7 +8,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("-e", help="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)
parser.add_argument("-e", help="Gather shared-creds from environment variables. This is for CI/CD", action='store_true', default=False)
parser.add_argument("-m", help="Prevents workspace from changing with git branches automatically", action='store_true', default=False)
parser.add_argument("-n", help="Atmos will not add -var-file or -var args to terraform", action='store_true', default=False)
parser.add_argument("-p", "--project", help="Add a project prefix for env vars", nargs='?', default="")
@ -57,4 +57,4 @@ def is_git_directory():
if __name__ == "__main__":
main(sys.argv)
main(sys.argv)

View file

@ -40,8 +40,8 @@ def generate(args):
print("[ERROR]: Env Variable " + secret_key_name + " not found.")
sys.exit(1)
if os.path.isfile(aws_creds_full):
answer = input("Found aws creds file already, do you want to override? [y/n]")
if os.path.isfile(os.path.expanduser(aws_creds_full)):
answer = input(f"[WARNING] File {aws_creds_full} already exists. Atmos will generate a new credentials file from your env vars. \nDo you want to override {aws_creds_full}? [y/N]")
if not answer or answer[0].lower() != 'y':
print("File not changed. This flag is for CI/CD only")
exit(1)
@ -50,4 +50,4 @@ def generate(args):
os.makedirs(os.path.expanduser(aws_creds_dir))
with open(os.path.expanduser(aws_creds_full), 'w+') as f:
f.write(contents)
f.write(contents)