Skip to content

Commit c3230e2

Browse files
Added support to query secret manager via parameter store (#30)
* Added support for secrets manager * Rollback changes * Updates to README.md * Added information around dynamodb key to include <hyphen> part of the lookup Co-authored-by: Hari Ohm Prasath <[email protected]>
1 parent 4ef7b62 commit c3230e2

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

cache-extension-demo/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ aws dynamodb put-item \
7272
--return-consumed-capacity TOTAL \
7373
--return-item-collection-metrics SIZE
7474
```
75+
> Note: Dynamodb values are stored under the key generated using the format `<table><hyphen><hashkey><hyphen><rangekey>`
7576
7677
## Compile package and dependencies
7778
To run this example, you will need to ensure that your build architecture matches that of the Lambda execution environment by compiling with `GOOS=linux` and `GOARCH=amd64` if you are not running in a Linux environment.
@@ -108,7 +109,8 @@ Add the newly created layer version to a Lambda function.
108109
- Make sure to have a `config.yaml` in the root of the lambda function's directory and updated with the correct region information. You can use the provided `config.yaml` in the the `example/` directory
109110
- Make sure to increase the default timeout to 2 mins and memory to 512 MB
110111

111-
>Note: Make sure to have`'AmazonDynamoDBReadOnlyAccess'` & `'AmazonSSMReadOnlyAccess'` IAM policies assigned to the IAM role associated with the Lambda function
112+
>Note: Make sure to have`'AmazonDynamoDBReadOnlyAccess'` & `'AmazonSSMReadOnlyAccess'` IAM policies assigned to the IAM role associated with the Lambda function.
113+
> If you are caching entries in secrets manager using /aws/reference/secretsmanager/<secret> then make sure to assign `'SecretsManagerReadWrite'` policy to the IAM role
112114
113115
Here is the AWS CLI command that can update the layers on the existing AWS Lambda function
114116

cache-extension-demo/example-function/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports.handler = function(event, context, callback) {
66
const options = {
77
hostname: 'localhost',
88
port: 3000,
9-
path: '/dynamodb/DynamoDbTable-pKey1-sKey1',
9+
path: '/dynamodb?name=DynamoDbTable-pKey1-sKey1',
1010
method: 'GET'
1111
}
1212

cache-extension-demo/img/Sequence.svg

Lines changed: 1 addition & 1 deletion
Loading

cache-extension-demo/img/Sequence.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Extension-->Extension: Initialization complete
66
Extension->DynamoDB: Initialize cache map and fetch all \nrecords listed in config.yaml if \n CACHE_EXTENSION_INIT_STARTUP=true
77
Extension-->Extension: Initialization complete
88
Extension-->Extension: Start a HTTP server
9-
Lambda->Extension: HTTP Get:/parameters/<name> to read from parameters cache
9+
Lambda->Extension: HTTP Get:/parameters?name=<name> to read from parameters cache
1010
Extension-->Lambda: Check whether item exists in cache and not exired?\nIf yes return it or \nread it from parameter store, cache it and return it
11-
Lambda->Extension: HTTP Get:/dynamodb/<table><hashkey><rangekey> to read from dynamodb cache
11+
Lambda->Extension: HTTP Get:/dynamodb?name=<table><hyphen><hashkey><hyphen><rangekey> \nto read from dynamodb cache
1212
Extension-->Lambda: Check whether item exists in cache and not exired?\nIf yes return it or \nread it from Dynamodb, cache it and return it as JSON string

cache-extension-demo/ipc/ipc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ func Start(port string) {
1818
// Method that responds back with the cached values
1919
func startHTTPServer(port string) {
2020
router := mux.NewRouter()
21-
router.HandleFunc("/{cacheType}/{key}",
21+
router.Path("/{cacheType}").Queries("name", "{name}").HandlerFunc(
2222
func(w http.ResponseWriter, r *http.Request) {
2323
vars := mux.Vars(r)
24-
value := extension.RouteCache(vars["cacheType"], vars["key"])
24+
value := extension.RouteCache(vars["cacheType"], vars["name"])
2525

2626
if len(value) != 0 {
2727
_, _ = w.Write([]byte(value))

0 commit comments

Comments
 (0)