AWS Secrets Manager 辅助包

1.4 2021-11-24 10:05 UTC

This package is auto-updated.

Last update: 2024-09-24 17:16:51 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads

Composer 包,用于帮助处理 AWS Secrets Manager 服务中的保密信息(保密信息)。此包将自动从 AWS Secrets Manager 保密信息更新您的数据库凭证。

安装

使用 Composer 将 Hush-Hush 安装到您的 Laravel 项目中

composer require trenaldas/hush-hush

安装 Hush-Hush Composer 包后,使用以下命令

php artisan hush-hush:install

这将配置文件发布到 config/hush-hush.php,并在您的根目录中创建空的 hush-hush.yml 文件。

配置文件

配置文件有三个主要配置

environments
exception_throw
every_request

'环境'配置描述了您希望从哪些环境中检索保密信息。默认设置为两个最常见的环境:stagingproduction。您应该根据项目环境名称相应地修改这些设置(最好在运行数据库和保密命令之前完成)。

'异常抛出'配置默认设置为false。这将在发生任何失败时记录错误(例如,在无法访问 AWS SM 的环境中运行 composer install 时)。

'每个请求'配置默认设置为true。每次请求都会调用 SM,如果设置为false,则检查连接是否正常,如果不正常,则调用 SM 更新数据库凭证。

使用方法

对于数据库登录详情

使用以下命令

php artisan hush-hush:database

对于要存储的任何其他保密信息

使用以下命令

php artisan hush-hush:create-secret

创建的所有保密信息都可以在 hush-hush.yml 文件中手动编辑、删除或添加。

在代码的任何位置获取保密信息

使用 HushHush 类的 uncover('localSecretName') 函数获取保密信息。

.yml 文件示例

database:
  name: mysql
  environemts:
    local: hush-hush-secret-local
    staging: hush-hush-secret-staging
    production: hush-hush-secret-production
secrets:
  local_secret_name:
    local_name: app-secret
    environments:
      local: hush-hush-local
      staging: hush-hush-staging
      production: hush-hush-production
  local_super_secret_name:
    local_name: my-api-login
    environments:
      local: hush-hush-super-local
      staging: hush-hush-super-staging
      production: hush-hush-super-production       

作者

  _   _           _           _   _           _
 | | | |_   _ ___| |__       | | | |_   _ ___| |__
 | |_| | | | / __| '_ \ _____| |_| | | | / __| '_ \
 |  _  | |_| \__ \ | | |_____|  _  | |_| \__ \ | | |
 |_| |_|\__,_|___/_| |_|     |_| |_|\__,_|___/_| |_|