Package: creds-to-env
Creds To Envcreds-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-fileflag.When sending environment variables to docker containers,docker expectseach line of the file to be in the format ofVAR=VAL, butgimme-aws-credswrites 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 ExampleAssuming you have rungimme-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:dockerrun-p8083:8083--env-file~/.aws/credentialsamazon/aws-stepfunctions-localThe 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 thecredentialsfile, 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 timegimme-aws-credsis run.PrerequisitesPython 3.6+OptionalGimme-aws-credscan be used to initially create the credenttials file.InstallattionThis is a Python3 project. Install/upgrade from PyPi.pip3 install --upgrade creds-to-envUsageThis 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,--inputspecifices the path to the input file, defaults to~/.aws/credentials-o,--outputspecifieds the path to the output file, defaults to~/.aws/credentials.envIf 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.LicenseCreds To Env is released under theMIT License.