-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: decrypt postgres password for use in connection string #41
Conversation
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
@@ -141,7 +147,7 @@ def add_namespace(obj): | |||
}) | |||
|
|||
# Configuration Values are stored in the configuration: | |||
# ../config/Pulumi.STACKNAME.yaml | |||
# ./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.
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.