|
3 | 3 | When you test functionality that involves external services such as UPS, FedEx, PayPal, or SignifyD, |
4 | 4 | use the MFTF credentials feature to hide sensitive [data][] like integration tokens and API keys. |
5 | 5 |
|
6 | | -Currently the MFTF supports two types of credential storage: |
| 6 | +Currently the MFTF supports three types of credential storage: |
7 | 7 |
|
8 | 8 | - **.credentials file** |
9 | | -- **HashiCorp vault** |
| 9 | +- **HashiCorp Vault** |
| 10 | +- **Aws Secret Manager** |
10 | 11 |
|
11 | 12 | ## Configure File Storage |
12 | 13 |
|
@@ -135,11 +136,64 @@ CREDENTIAL_VAULT_ADDRESS=http://127.0.0.1:8200 |
135 | 136 | CREDENTIAL_VAULT_SECRET_BASE_PATH=secret |
136 | 137 | ``` |
137 | 138 |
|
138 | | -## Configure both File Storage and Vault Storage |
| 139 | +## Configure Aws Secret Manager |
139 | 140 |
|
140 | | -It is possible and sometimes useful to setup and use both `.credentials` file and vault for secret storage at the same time. |
141 | | -In this case, the MFTF tests are able to read secret data at runtime from both storage options, but the local `.credentials` file will take precedence. |
| 141 | +Aws Secrets Manager offers secret management that supports: |
| 142 | +- Secret rotation with built-in integration for Amazon RDS, Amazon Redshift, and Amazon DocumentDB |
| 143 | +- Fine-grained policies and permissions |
| 144 | +- Audit secret rotation centrally for resources in the AWS Cloud, third-party services, and on-premises |
142 | 145 |
|
| 146 | +### Prerequisites |
| 147 | +- AWS account |
| 148 | +- AWS Secret Manger is created and configured |
| 149 | +- IAM User or Role is created |
| 150 | + |
| 151 | +### Store secrets in Aws Secret Manager |
| 152 | + |
| 153 | +#### Secrets format |
| 154 | +`Secret Name`, `Secret Key`, `Secret Value` are three key pieces of information to construct an Aws Secret. |
| 155 | +`Secret Key` and `Secret Value` can be any content you want to secure, `Secret Name` must follow the format: |
| 156 | + |
| 157 | +```conf |
| 158 | +mftf/<VENDOR>/<SECRET_KEY> |
| 159 | +``` |
| 160 | + |
| 161 | +```conf |
| 162 | +# Secret name for carriers_usps_userid |
| 163 | +mftf/magento/carriers_usps_userid |
| 164 | +
|
| 165 | +# Secret key for carriers_usps_userid |
| 166 | +carriers_usps_userid |
| 167 | +
|
| 168 | +# Secret name for carriers_usps_password |
| 169 | +mftf/magento/carriers_usps_password |
| 170 | +
|
| 171 | +# Secret key for carriers_usps_password |
| 172 | +carriers_usps_password |
| 173 | +``` |
| 174 | + |
| 175 | +### Setup MFTF to use Aws Secret Manager |
| 176 | + |
| 177 | +To use Aws Secret Manager, the Aws region to connect to is required. You can set it through environment variable [`CREDENTIAL_AWS_SECRET_MANAGER_REGION`][] in `.env`. |
| 178 | + |
| 179 | +MFTF uses the recommended [Default Credential Provider Chain][credential chain] to establish connection to Aws Secret Manager service. |
| 180 | +You can setup credentials according to [Default Credential Provider Chain][credential chain] and there is no MFTF specific setup required. |
| 181 | +Optionally, however, you can explicitly set Aws profile through environment variable [`CREDENTIAL_AWS_SECRET_MANAGER_PROFILE`][] in `.env`. |
| 182 | + |
| 183 | +```conf |
| 184 | +# Sample Aws Secret Manager configuration |
| 185 | +CREDENTIAL_AWS_SECRET_MANAGER_REGION=us-east-1 |
| 186 | +CREDENTIAL_AWS_SECRET_MANAGER_PROFILE=default |
| 187 | +``` |
| 188 | + |
| 189 | +## Configure multiple credential storage |
| 190 | + |
| 191 | +It is possible and sometimes useful to setup and use multiple credential storage at the same time. |
| 192 | +In this case, the MFTF tests are able to read secret data at runtime from all storage options, in this case MFTF use the following precedence: |
| 193 | + |
| 194 | +``` |
| 195 | +.credentials File > HashiCorp Vault > Aws Secret Manager |
| 196 | +``` |
143 | 197 | <!-- {% raw %} --> |
144 | 198 |
|
145 | 199 | ## Use credentials in a test |
@@ -183,3 +237,6 @@ The MFTF tests delivered with Magento application do not use credentials and do |
183 | 237 | [Vault KV2]: https://www.vaultproject.io/docs/secrets/kv/kv-v2.html |
184 | 238 | [`CREDENTIAL_VAULT_ADDRESS`]: configuration.md#credential_vault_address |
185 | 239 | [`CREDENTIAL_VAULT_SECRET_BASE_PATH`]: configuration.md#credential_vault_secret_base_path |
| 240 | +[credential chain]: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html |
| 241 | +[`CREDENTIAL_AWS_SECRET_MANAGER_PROFILE`]: configuration.md#credential_aws_secret_manager_profile |
| 242 | +[`CREDENTIAL_AWS_SECRET_MANAGER_REGION`]: configuration.md#credential_aws_secret_manager_region |
0 commit comments