Skip to main content

Maps AWS Credentials to Docker Environment File

Project description

Creds To Env

creds-to-env is a CLI that maps AWS credentials (typically but not necessarily generated by gimme-aws-creds) to an environment file that can be passed to an AWS docker container using the --env-file flag.

When sending environment variables to docker containers, docker expects each line of the file to be in the format of VAR=VAL, but gimme-aws-creds writes the resulting credentials file with lower-case keys and spaces around the equal signs that delimit key/value pairs, both of which will result in different errors when passing the credentials file as an environment file to the docker container.

Problem Example

Assuming you have run gimme-aws-creds, and assuming your AWS credentials are in the default location of ~/.aws/credentials, and you wanted to run the local Step Functions container from AWS with the following command:

docker run -p 8083:8083 --env-file ~/.aws/credentials amazon/aws-stepfunctions-local

The following error would occur due to the whitespace around the equal sign:

docker: poorly formatted environment: variable 'aws_access_key_id ' contains whitespaces.
See 'docker run --help'.

If we remove the spaces around the equal sign on each line of the credentials file, running the same docker command gives us the next error:

Step Functions Local
Version: 1.8.1
Build: 2022-02-08
2022-03-10 23:49:49.620: Failed to load credentials from environment because Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY))
2022-03-10 23:49:49.664: Failed to load credentials from profile: default because profile file cannot be null
2022-03-10 23:49:49.664: Failed to load credentials from system properties because Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey)
2022-03-10 23:49:49.664: Failed to load credentials, default to dummy credentials, so any connection to AWS services will not work, connections to local endpoints are not affected.

Which indicates that the key/value pairs are not being recognized by the step functions process in the docker container. If we change the keys to be upper case and run the docker command again, the credentials are recognized and the container starts without issue.

Hard coding a persistent file for credentials won't work, as the key/value pairs will change each time gimme-aws-creds is run.

Prerequisites

Python 3.6+

Optional

Gimme-aws-creds can be used to initially create the credenttials file.

Installattion

This is a Python3 project. Install/upgrade from PyPi.

pip3 install --upgrade creds-to-env

Usage

This package will read in the data from the credentials file, transform it into the format the docker container is expecting, and write the transformed data out to a new file, which can then be used to pass in to the docker container, leaving the existing credentials in place and unmodified.

While no parameters are required, both the input file and output file can be specified as command line parameters. The input file must exist and the output folder must exist.

  • -i, --input specifices the path to the input file, defaults to ~/.aws/credentials

  • -o, --output specifieds the path to the output file, defaults to ~/.aws/credentials.env

If an input file is provided but an output file is not, the output file will automatically default to the same name as the input file with the extensions replace with .env.

License

Creds To Env is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

creds-to-env-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

creds_to_env-1.0.0-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file creds-to-env-1.0.0.tar.gz.

File metadata

  • Download URL: creds-to-env-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for creds-to-env-1.0.0.tar.gz
Algorithm Hash digest
SHA256 44651a5ab39b98f06479b91a93d52c496a56618e3285c863781aebee0b0e5471
MD5 2929414593151a6002889957d86ea42c
BLAKE2b-256 d250749d36ca51dbdab85b48daa9556e8579c3eb89152a381d44f71556dc2fce

See more details on using hashes here.

File details

Details for the file creds_to_env-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: creds_to_env-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for creds_to_env-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f0c93dd69617d18fbac67892adb154fa8f30bb20090f1f1acca1173fd02ca3ac
MD5 7ef0e4d5fab9757cc8515e25dba0c124
BLAKE2b-256 76722d38790ba3e5e185d6bc44a87b78d98286477da2563ad059b1160b3edf55

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page