HuanXin-Chen commented on code in PR #11417:
URL: https://github.com/apache/apisix/pull/11417#discussion_r1720741334


##########
docs/en/latest/terminology/secret.md:
##########
@@ -190,3 +191,105 @@ curl http://127.0.0.1:9180/apisix/admin/consumers \
 ```
 
 Through the above two steps, when the user request hits the `key-auth` plugin, 
the real value of the key in the Vault will be obtained through the APISIX 
Secret component.
+
+## Use AWS Secrets Manager to manage secrets
+
+Managing secrets with AWS Secrets Manager is a secure and convenient way to 
store and manage sensitive information. This method allows you to save secret 
information in AWS Secrets Manager and reference these secrets in a specific 
format when configuring APISIX plugins.
+
+APISIX currently supports two access methods: [long-term credential 
access](https://docs.aws.amazon.com/zh_cn/sdkref/latest/guide/access-iam-users.html)
 and [short-term credential 
access](https://docs.aws.amazon.com/zh_cn/sdkref/latest/guide/access-temp-idc.html).

Review Comment:
   fixed



##########
docs/en/latest/terminology/secret.md:
##########
@@ -190,3 +191,105 @@ curl http://127.0.0.1:9180/apisix/admin/consumers \
 ```
 
 Through the above two steps, when the user request hits the `key-auth` plugin, 
the real value of the key in the Vault will be obtained through the APISIX 
Secret component.
+
+## Use AWS Secrets Manager to manage secrets
+
+Managing secrets with AWS Secrets Manager is a secure and convenient way to 
store and manage sensitive information. This method allows you to save secret 
information in AWS Secrets Manager and reference these secrets in a specific 
format when configuring APISIX plugins.
+
+APISIX currently supports two access methods: [long-term credential 
access](https://docs.aws.amazon.com/zh_cn/sdkref/latest/guide/access-iam-users.html)
 and [short-term credential 
access](https://docs.aws.amazon.com/zh_cn/sdkref/latest/guide/access-temp-idc.html).
+
+### Usage
+
+```
+$secret://$manager/$id/$secret_name/$key
+```
+
+- manager: secrets management service, could be the HashiCorp Vault, AWS, etc.
+- id: APISIX Secrets resource ID, which needs to be consistent with the one 
specified when adding the APISIX Secrets resource
+- secret_name: the secret name in the secrets management service
+- key: get the value of a property when the value of the secret is a JSON 
string
+
+### Required Parameters
+
+| Name | Required | Default Value | Description |
+| --- | --- | --- | --- |
+| access_key_id | Yes |  | AWS Access Key ID |
+| secret_access_key | Yes |  | AWS Secret Access Key |
+| session_token | No |  | Temporary access credential information |
+| region | No | us-east-1 | AWS Region |
+| endpoint_url | No | https://secretsmanager.{region}.amazonaws.com | AWS 
Secret Manager URL |
+
+### Example: use in key-auth plugin
+
+Here, we use the key-auth plugin as an example to demonstrate how to manage 
secrets through AWS Secrets Manager.
+
+Step 1: Create the corresponding key in the aws secrets manager.Here, 
[localstack](https://www.localstack.cloud/) is used for simulation, and you can 
use the following command:

Review Comment:
   fixed



##########
docs/en/latest/terminology/secret.md:
##########
@@ -190,3 +191,105 @@ curl http://127.0.0.1:9180/apisix/admin/consumers \
 ```
 
 Through the above two steps, when the user request hits the `key-auth` plugin, 
the real value of the key in the Vault will be obtained through the APISIX 
Secret component.
+
+## Use AWS Secrets Manager to manage secrets
+
+Managing secrets with AWS Secrets Manager is a secure and convenient way to 
store and manage sensitive information. This method allows you to save secret 
information in AWS Secrets Manager and reference these secrets in a specific 
format when configuring APISIX plugins.
+
+APISIX currently supports two access methods: [long-term credential 
access](https://docs.aws.amazon.com/zh_cn/sdkref/latest/guide/access-iam-users.html)
 and [short-term credential 
access](https://docs.aws.amazon.com/zh_cn/sdkref/latest/guide/access-temp-idc.html).
+
+### Usage
+
+```
+$secret://$manager/$id/$secret_name/$key
+```
+
+- manager: secrets management service, could be the HashiCorp Vault, AWS, etc.
+- id: APISIX Secrets resource ID, which needs to be consistent with the one 
specified when adding the APISIX Secrets resource
+- secret_name: the secret name in the secrets management service
+- key: get the value of a property when the value of the secret is a JSON 
string
+
+### Required Parameters
+
+| Name | Required | Default Value | Description |
+| --- | --- | --- | --- |
+| access_key_id | Yes |  | AWS Access Key ID |
+| secret_access_key | Yes |  | AWS Secret Access Key |
+| session_token | No |  | Temporary access credential information |
+| region | No | us-east-1 | AWS Region |
+| endpoint_url | No | https://secretsmanager.{region}.amazonaws.com | AWS 
Secret Manager URL |
+
+### Example: use in key-auth plugin
+
+Here, we use the key-auth plugin as an example to demonstrate how to manage 
secrets through AWS Secrets Manager.
+
+Step 1: Create the corresponding key in the aws secrets manager.Here, 
[localstack](https://www.localstack.cloud/) is used for simulation, and you can 
use the following command:
+
+```shell
+docker exec -i localstack sh -c "awslocal secretsmanager create-secret --name 
jack --description 'APISIX Secret' --secret-string '{\"auth-key\":\"value\"}'"
+```
+
+Step 2: Add APISIX Secrets resources through the Admin API, configure the 
connection information such as the address of AWS Secrets Manager:
+
+You can store the critical key information in environment variables to ensure 
the configuration information is secure, and reference it where it is used:
+
+```shell
+export AWS_ACCESS_KEY_ID=<access_key_id>
+export AWS_SECRET_ACCESS_KEY=<secrets_access_key>
+export AWS_SESSION_TOKEN=<token>
+export AWS_REGION=<aws-region>
+```
+
+Alternatively, you can also specify all the information directly in the 
configuration:
+
+```shell
+curl http://127.0.0.1:9180/apisix/admin/secrets/aws/1 \
+-H "X-API-KEY: $admin_key" -X PUT -d '
+{
+    "endpoint_url": "http://127.0.0.1:4566";,
+    "region": "us-east-1",
+    "access_key_id": "access",
+    "secret_access_key": "secret",
+    "session_token": "token"
+}'
+```
+
+If you use APISIX Standalone mode, you can add the following configuration in 
`apisix.yaml` configuration file:
+
+```yaml
+secrets:
+  - id: aws/1
+    endpoint_url: http://127.0.0.1:4566
+    region: us-east-1
+    access_key_id: access
+    secret_access_key: secret
+    session_token: token
+```
+
+Step 3: Reference the APISIX Secrets resource in the `key-auth` plugin and 
fill in the key information:
+
+```shell
+curl http://127.0.0.1:9180/apisix/admin/consumers \
+-H "X-API-KEY: $admin_key" -X PUT -d '
+{
+    "username": "jack",
+    "plugins": {
+        "key-auth": {
+            "key": "$secret://aws/1/jack/auth-key"
+        }
+    }
+}'
+```
+
+Through the above two steps, when the user request hits the `key-auth` plugin, 
the real value of the key in the Vault will be obtained through the APISIX 
Secret component.
+
+### Verification
+
+You can verify this with the following command:
+
+```shell
+#Replace the following your_route with the actual route path.
+curl -i http://127.0.0.1:9080/your_route -H 'apikey: value'
+```
+
+This will verify whether the key-auth plugin is correctly using the key from 
AWS Secrets Manager.

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to