简体   繁体   English

Vault - AWS RDS Postgres 集成

[英]Vault - AWS RDS Postgres integration

I'm setting up integration between vault and an postgres instance running in AWS RDS.我正在设置保管库和在 AWS RDS 中运行的 postgres 实例之间的集成。 My strategy is as follows:我的策略如下:

  1. Database registration数据库注册

    a.一种。 Use the RDS master credentials to create a role named server_admin:使用 RDS 主凭据创建名为 server_admin 的角色:

     CREATE ROLE server_admin WITH LOGIN PASSWORD '${password}' CREATEROLE CREATEDB

    b.Register the database with vault, using the server_admin postgres role (python hvac library):使用 server_admin postgres 角色(python hvac 库)向 vault 注册数据库:

     vault.write("database/config/{0}".format(database_identifier), plugin_name=plugin_name, connection_url=connection_url, allowed_roles="*")`

    c. C。 Next, create a vault role for administration (schema creation):接下来,为管理创建一个保管库角色(架构创建):

     vault.write("database/roles/{0}".format(role_name), db_name=database_identifier, creation_statements='"CREATE ROLE \\"{{name}}\\" WITH LOGIN INHERIT PASSWORD '{{password}}' IN ROLE SERVER_ADMIN;"', default_ttl="10000h")
  2. Schema registration模式注册

    a.一种。 Use vault to obtain a user with the server_admin role.使用 Vault 获取具有 server_admin 角色的用户。 b.Create the schema创建架构

    CREATE SCHEMA IF NOT EXISTS ${schema_name} AUTHORIZATION server_admin

    c. C。 Create 3 vault roles (read_only, read_write, admin)创建 3 个保管库角色(read_only、read_write、admin)

  3. Application initialisation应用初始化

    a.一种。 Obtain a database user from vault with the admin role, and run a flyway migration从 Vault 中获取一个具有 admin 角色的数据库用户,并运行 flyway 迁移

    b.Obtain a database user from vault with the read_write role for normal operation从 Vault 中获取具有 read_write 角色的数据库用户以进行正常操作

My issue is that during initial schema initialisation by my application (flyway), the tables are owned by the dynamically generated user.我的问题是,在我的应用程序(flyway)的初始架构初始化期间,表归动态生成的用户所有。 The next time I attempt a migration, I obtain a new user (via vault) with the admin role, but it does not have permissions to access the tables created by the first user.下次尝试迁移时,我获得了一个具有 admin 角色的新用户(通过 vault),但它无权访问第一个用户创建的表。

What is the recommended strategy for database/schema/table ownership when using vault integration with postgresql?使用 Vault 与 postgresql 集成时,推荐的数据库/模式/表所有权策略是什么?

I've struggled with the same problem and in the end, I implemented the solution described in this article.我一直在努力解决同样的问题,最后,我实现了本文中描述的解决方案。 (The relevant part ends at 'Using Liquibase') https://www.jannikarndt.de/blog/2018/08/rotating_postgresql_passwords_with_no_downtime/ (相关部分以“使用 Liquibase”结尾) https://www.jannikarndt.de/blog/2018/08/rotating_postgresql_passwords_with_no_downtime/

Vault can be used to rotate the roles as described above by using Vault Static Roles. Vault 可用于通过使用 Vault 静态角色来轮换上述角色。 In this case, the usernames remain constant and the passwords are rotated and managed by Vault.在这种情况下,用户名保持不变,密码由 Vault 轮换和管理。 https://learn.hashicorp.com/vault/secrets-management/db-creds-rotation https://learn.hashicorp.com/vault/secrets-management/db-creds-rotation

I use a Blue/Green setup where I set the unused role to NOLOGIN and switch them when I want.我使用蓝/绿设置,将未使用的角色设置为 NOLOGIN 并在需要时切换它们。

By keeping the Role names static, you avoid the problem of new roles that don't inherit the permissions of the previous role.通过保持角色名称静态,您可以避免新角色不继承先前角色权限的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM