bzp2010 commented on code in PR #11417:
URL: https://github.com/apache/apisix/pull/11417#discussion_r1714741617


##########
apisix/secret/aws.lua:
##########
@@ -0,0 +1,193 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+--- AWS Tools.
+local core = require("apisix.core")
+local http = require("resty.http")
+local aws = require("resty.aws")
+
+local sub = core.string.sub
+local rfind_char = core.string.rfind_char
+local env = core.env
+local type = type
+local unpack = unpack
+
+--- AWS Environment Configuration
+local AWS
+local AWS_ACCESS_KEY_ID
+local AWS_SECRET_ACCESS_KEY
+local AWS_SESSION_TOKEN
+local AWS_REGION
+
+local schema = {
+    type = "object",
+    properties = {
+        access_key_id = {
+            type = "string",
+        },
+        secret_access_key = {
+            type = "string",
+        },
+        session_token = {
+            type = "string",
+        },
+        region = {
+            type = "string",
+        },
+        endpoint_url = core.schema.uri_def,
+    },
+}
+
+local _M = {
+    schema = schema
+}
+
+local function initialize_aws()
+    AWS_ACCESS_KEY_ID = env.fetch_by_uri("$ENV://AWS_ACCESS_KEY_ID")
+    AWS_SECRET_ACCESS_KEY = env.fetch_by_uri("$ENV://AWS_SECRET_ACCESS_KEY")
+    AWS_SESSION_TOKEN = env.fetch_by_uri("$ENV://AWS_SESSION_TOKEN")
+    AWS_REGION = env.fetch_by_uri("$ENV://AWS_REGION")
+    AWS = aws()
+    initialize_aws= nil
+end
+
+local function make_request_to_aws(conf,key)
+    if initialize_aws then
+        initialize_aws()
+    end
+
+    local region = conf.region or AWS_REGION
+    if not region then
+        return nil, "aws secret manager requires region"
+    end
+
+    local access_key_id = env.fetch_by_uri(conf.access_key_id)

Review Comment:
   I support configurations as a single source of credentials because users can 
create multiple instances of the same manager, which can cause misuse. 
Therefore the AWS_SECRET_ACCESS_KEY value should not be read, which is exactly 
what is done now.
   
   Although AWS_SECRET_ACCESS_KEY is a common value used by the AWS CLI.
   
   In short, 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