-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feat: helper script to read KeyVault secrets #1859
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
788d522
to
978cbca
Compare
4237342
to
6ec2455
Compare
function rather than variable to enable dynamic runtime calculation e.g. for unit tests
move module-level variables into configure function, unneeded outside module, wait for Django startup before using settings
similar to how this is done in the Terraform module
1371de3
to
c542647
Compare
c542647
to
3c3fdc9
Compare
Preview url: https://benefits-1859--cal-itp-previews.netlify.app |
allow interfacing with Azure inside devcontainer
the secret does not contain any sensitive information and is only configured in the dev environment
Preview url: https://benefits-1859--cal-itp-previews.netlify.app |
Yes! I hadn't noticed these before, but I do see them in trying to hit the local I think this reflects
Since these are |
@machikoyasuda please make sure you can go through the |
Moving back to draft as I work on some additional fixes for running the app locally and unit/integration testing. |
used to shortcut secret store for e.g. local testing
Preview url: https://benefits-1859--cal-itp-previews.netlify.app |
da261e4
to
e055d86
Compare
Preview url: https://benefits-1859--cal-itp-previews.netlify.app |
@angela-tran @machikoyasuda ready for re-review! Please see the updated steps in How to verify the POC above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to confirm support for local configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Able to go thru all the testing steps and read KV secret values for local, dev and test
Part of #1847
What this PR does
RUNTIME_ENVIRONMENT()
to dynamically calculate one oflocal
,dev
,test
, orprod
based on the values inALLOWED_HOSTS
azure-keyvault-secrets
andazure-identity
based on Getting Started with Azure Key Vault Secrets client library for Pythonlocal
runtime environment, falls back to reading from environment variablesTodo
Done
The existing Terraform
app_service
definition includes a system-defined managed identity.Further, this managed identity should be able to GET secrets via an existing policy definition.
According to the Python package docs,
DefaultCredential
will check for access via this system-defined managed identity when running in Azure. This PR adds aDEBUG
-only route/testsecret
to help verify access from within Azure.How to verify the POC
Update your local
.env
file to add a new variableRebuild and Reopen the devcontainer
Call the helper script, setting the
DJANGO_SETTINGS_MODULE
env var and passing the name of the secret to readVerify output:
From the devcontainer terminal, login to the Azure CLI with the
--use-device-code
flag, following instructions printed in the terminal. You may need to login to Azure on the website first, if you receive an error related to 2FA, to trigger that flow. Then run:Call the helper script again configuring
DJANGO_ALLOWED_HOSTS
for thedev
environment:Verify output:
Launch the local app with
F5
and visit the/testsecret
endpoint, verify output in the browser:Override
DJANGO_ALLOWED_HOSTS
in.vscode/launch.json
to point todev
. Be sure to includelocalhost
so you can launch the app!Launch the local app with
F5
and visit the/testsecret
endpoint, verify output in the browser:Try another call against e.g. the
test
environment:And verify the expected output:
Post-merge verification steps
After this PR is merged and deployed to
dev
, visit the/testsecret
route, which should print the value of the test secret in the browser (shown inlocalhost
below):Confirmed in
dev