[Python] Aurora - password authentication failed for user "postgres" - after password rotation

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I'm using python lambda functions. In the beginning of the file I call this function:

    def create_db_engines():
    session = boto3.session.Session()
    client = session.client(
    service_name='secretsmanager',
    region_name=os.environ['region']
    )

    try:
    get_secret_value_response = client.get_secret_value(
    SecretId=os.environ['rds_credentials']
    )
    except ClientError as e:
    print('ERROR getting secret ' + str(e))
    raise e
    # Decrypts secret using the associated KMS key.
    secret = json.loads(get_secret_value_response['SecretString'])
    username = secret['username']
    password = secret['password']
    print('password:' + password) # added temporarily for debugging
    engine = create_engine(
    f"postgresql://{username}:{password}@{os.environ['db_endpoint']}/postgres")

    engine_async = create_async_engine(
    f"postgresql+asyncpg://{username}:{password}@{os.environ['db_endpoint']}/postgres")
    return engine, engine_async



    I see in the log that the password is correct and I'm able to connect with it in pgadmin. But I still get the error "password authentication failed for user "postgres"" and I don't know why. If I rotate the password in rds it works ok, but it stops working in the next rotation.

    Continue reading...

Compartilhe esta Página