summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2021-04-09 14:29:05 +0200
committerRicardo Wurmus <rekado@elephly.net>2021-04-09 14:29:05 +0200
commitbed1a6624e0faac0830346e3bb1ac3581e8bb34b (patch)
tree66264aab1ced0c361ae6ef4419da223b3b7e667f
parentf0a9929761c26e57f5c70b458de514e7499fe4ec (diff)
aws/request: Use parameters for AWS settings.
-rw-r--r--aws/request.scm24
1 files changed, 18 insertions, 6 deletions
diff --git a/aws/request.scm b/aws/request.scm
index feededb..e334e2b 100644
--- a/aws/request.scm
+++ b/aws/request.scm
@@ -31,7 +31,11 @@
#:use-module ((web http) #:select (header-writer declare-header!))
#:use-module (sxml simple)
#:use-module (json)
- #:export (make-operation->request))
+ #:export (%aws-default-region
+ %aws-access-key
+ %aws-secret-access-key
+
+ make-operation->request))
;;; Commentary:
@@ -42,6 +46,16 @@
;;; Code:
+(define %aws-default-region
+ (make-parameter (or (getenv "AWS_DEFAULT_REGION")
+ "us-west-2")))
+
+(define %aws-access-key
+ (make-parameter (getenv "AWS_ACCESS_KEY_ID")))
+
+(define %aws-secret-access-key
+ (make-parameter (getenv "AWS_SECRET_ACCESS_KEY")))
+
(define algorithm "AWS4-HMAC-SHA256")
(define (sign key msg)
@@ -141,14 +155,12 @@ corresponding value in INPUT."
http operation-name
xml-namespace
input)
- (define region
- (or (getenv "AWS_DEFAULT_REGION")
- "us-west-2"))
+ (define region (%aws-default-region))
(define access-key
- (or (getenv "AWS_ACCESS_KEY_ID")
+ (or (%aws-access-key)
(error "No access key available. Set the AWS_ACCESS_KEY_ID environment variable.")))
(define secret-key
- (or (getenv "AWS_SECRET_ACCESS_KEY")
+ (or (%aws-secret-access-key)
(error "No secret access key available. Set the AWS_SECRET_ACCESS_KEY environment variable.")))
(define method
(assoc-ref http "method"))