Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a JSON file to be used for configuration #14

Open
mtwalsh opened this issue Jan 21, 2016 · 4 comments
Open

Allow a JSON file to be used for configuration #14

mtwalsh opened this issue Jan 21, 2016 · 4 comments

Comments

@mtwalsh
Copy link

mtwalsh commented Jan 21, 2016

Personal preference but I'd prefer to use a config.json file in the same directory as the Python script for configuration rather than the environment variable.

@tylrd
Copy link

tylrd commented Jan 21, 2016

Added a get_config() method that seems to work:

def get_config():
    aws_json = os.getenv(ENV_VAR)
    if aws_json is not None:
        return json.loads(aws_json)
    else:
        try:
            script_dir = os.path.dirname(os.path.abspath(__file__))
        except NameError:
            script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
        abs_file_path = os.path.join(script_dir, CONFIG_FILE)
        return json.loads(open(abs_file_path).read())

Commit is here: https://github.com/taylor-d/letsencrypt-aws/commit/7a8a67bede1b6623535061a333480cff369e74df. Need to do some testing before PR.

@mtwalsh
Copy link
Author

mtwalsh commented Jan 21, 2016

Awesome, thanks for this!

@kbroughton
Copy link

+1
The docs might also explain how to pass json as an env variable.

@pugsley
Copy link

pugsley commented Aug 1, 2016

If you want to use a config.json file, create a simple wrapper like this in the same directory as letsencrypt-aws.py.

e.g. run.sh

#!/bin/bash
LETSENCRYPT_AWS_CONFIG=$(cat -) python letsencrypt-aws.py "$@"

Make it executable: chmod +x run.sh

Then you can use it like:

cat ./config.json | ./run.sh update-certificates

Then you can easily create multiple configs for each set of domains, e.g.

cat ./domain.com.json | ./run.sh update-certificates
cat ./otherdomain.net.json | ./run.sh update-certificates

This assumes run.sh and config.json are in the same directory as letsencrypt-aws.py (modify paths if they're not).


Here's a sample config.json file:

{
    "domains": [
        {
            "elb": {
                "name": "YOUR_ELB_NAME"
            },
            "hosts": ["HOST1.COM", "SUB.HOST1.COM"]
        }
    ],
    "acme_account_key": "file:///PATH/TO/YOUR/KEY"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants