-
Notifications
You must be signed in to change notification settings - Fork 103
fix: decrypt postgres password for use in connection string #41
Conversation
fix: add logic to decrypt postgres pw to build connection string nginxinc#37
pulumi/aws/anthos/__main__.py
Outdated
# The database password is a secret, and in order to use it in a string concat | ||
# we need to decrypt the password with Output.unsecret() before we use it. | ||
# This function provides the logic to accomplish this. | ||
accounts_db_uri = pulumi.Output.unsecret(accounts_pwd).apply( |
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.
Consider modifying this such that Pulumi continues to use secrets:
def create_pg_uri(password_object):
user = str(accounts_admin)
password = str(password_object)
database = str(accounts_db)
uri = f'postgresql://{user}:{password}@accounts-db:5432/{database}'
return pulumi.Output.secret(uri)
accounts_db_uri = pulumi.Output.unsecret(accounts_pwd).apply(create_pg_uri)
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.
Fixed; that's a great example construct for this use case.
pulumi/aws/anthos/__main__.py
Outdated
# ./config/Pulumi.STACKNAME.yaml | ||
config = pulumi.Config('anthos') | ||
demo_pwd = config.require_secret('demo_pwd') | ||
|
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.
Let's delete the demo_login
and demo_pwd
bits.
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.
Done and updated in all other locations and configs.
fix: remove demo login/pwd from config and fix secret logic
Running full test overnight. |
Proposed changes
This addresses a bug introduced with #30 - the password is part of the connection string, but pulumi does not decrypt it for use in the string concatenation needed to build it. This has been fixed by using the
Output.unsecret
method.Checklist
Before creating a PR, run through this checklist and mark each as complete.