briancaffey / django-step-by-step

A Django + Vue reference project that focuses on developer tooling and CI/CD + IaC
https://briancaffey.github.io/django-step-by-step/
174 stars 37 forks source link

Pass Github secrets to ECS environment variables #38

Closed pdang29 closed 1 year ago

pdang29 commented 1 year ago

I tried to pass Github secrets to terraform using TF_VAR_variable_name, then use as an environment variable for Gunicorn task, but so far it has not been successful. I saw in your terraform-aws-django modules/prod/app module "api" there is a variable called extra_env_vars. What is the use case for this? Can we actually use this variable to pass secrets from Github?

I would appreciate if you have any suggestions on how to pass extra environment variables to django.

Thanks!

brian-ixlayer commented 1 year ago

The use case for extra_env_vars is for merging extra environment variables on top of the default ones if you need to do so. You would add these in your {env}.tfvars file like so:

extra_env_vars = [
    {
        name = "MY_ENV_VAR"
        value = "my-value"
    }
]

If you want to add sensitive data that should not be committed to code, there are a few options:

Let me know if you have any other questions about these suggestions, hope that helps!

pdang29 commented 1 year ago

Thanks for the suggestions, I was able to get it to work using secret manager. Thanks again!