定制 madeiramadeirabr/hagrid 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

madeiramadeirabr/hagrid

最新稳定版本:v1.2.002

Composer 安装命令:

composer require madeiramadeirabr/hagrid

包简介

Simplified integration with aws secrets manager.

README 文档

README

Simplified integration with AWS Secrets Manager.

Getting Started

The purpose of this package is to simplify integration with AWS Secrets Manager, providing an easy way to retrive stored data.

All helpers considers that you have an role in EC2. This role must be allowed to access secrets manager. If EC2 doesn't has role to access SM, you need to create you own helpers using aws id and key to authenticate. All methods are explained here.

Prerequisites

* PHP >= 7.1;
* JSON PHP Extension;
* Composer

Installing

Download the package using composer.

composer require madeiramadeirabr/hagrid

Basic Usage

Basic integration can be accomplished in three ways.

First Method: Raw Data Retrive

This way retrive the raw json from secrets manager. This is useful if you application need to manipulate environment variables before save it.

To do that, call secrets manager helper, as in the example below:

$rawData = retrive_secrets($secretId);

The response will be something like that:

{
    "APP_NAME": "My App Name", 
    "APP_ENV": "production"
}

Second Method: Create .env File

This method will verify if .env file exists, if it don't, it will be created from data retrived from secrets manager.

$fileCreated = create_env_file($directory, $secretId);

The response will be TRUE, if the file was created, and FALSE, if don't.

Third Method: Save data on environment

This method will read data from secrets manager and save using putenv.

add_env_vars($secretId);

This method doesn't have any response.

Use without helpers

If EC2 doesn't have role, you can instatiate SecretsManager and pass the the credentials to authenticate.

First Method

Instantiating the SecretsManager class and calling the setters.

$secretsManager = new SecretsManager();

$secretsManager->setSecretId($secretId)
    ->setRegion($awsRegion)
    ->setId($myAwsId)
    ->setKey($myAwsKey);

Second Method

Instantiating the SecretsManager with AWS credentials.

$secretsManager = new SecretsManager($secretId, $awsRegion, $myAwsId, $myAwsKey);

And Finally

After using either of the two methods above, call the method that performs data recovery.

$secretValue = $secretsManager->getSecretValue();

Response

The response of the method 'getSecretValue' will be something like this.

{
    "APP_NAME": "My App Name", 
    "APP_ENV": "production"
}

Authors

See also the list of contributors who participated in this project.

统计信息

  • 总下载量: 5.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 26
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-25