https://github.com/turnerlabs/cstore-lambda-layer
cStore lambda layer terraform scripts.
https://github.com/turnerlabs/cstore-lambda-layer
aws-parameter-store aws-s3 aws-secrets-manager config configuration cstore lambda layers secrets
Last synced: 4 months ago
JSON representation
cStore lambda layer terraform scripts.
- Host: GitHub
- URL: https://github.com/turnerlabs/cstore-lambda-layer
- Owner: turnerlabs
- Created: 2019-10-31T21:22:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-07T04:12:25.000Z (about 3 years ago)
- Last Synced: 2025-03-27T14:55:40.660Z (over 1 year ago)
- Topics: aws-parameter-store, aws-s3, aws-secrets-manager, config, configuration, cstore, lambda, layers, secrets
- Language: HCL
- Size: 9.09 MB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cStore Lambda Layer
Terraform scripts used to create a lambda layer for [cstore](https://github.com/turnerlabs/cstore). Lambda functions can use the lambda layer to pull configuration into memory avoiding environment variables or configuration files.
### NodeJS ###
Example Usage
```javascript
const cstore = require('cstore');
exports.test = function (event, context) {
let config = cstore.pull({
tags: [process.env.ENV],
format: "json-object",
inject: false
})
Object.keys(config).forEach(function (key) {
console.log(key + "=" + config[key]);
});
}
```
Infrastructure
```bash
$ export AWS_REGION=us-east-1
$ export AWS_PROFILE=aws-profile
```
#### 1. Create cStore Lambda Layer ####
```bash
$ cd nodejs/resources
$ terraform init
$ terraform apply
```
#### 3. Create Example Lambda ####
```bash
$ cd nodejs/example
$ touch terraform.tfvars
```
Add the cstore lambda layer arn from the previous step's output to `terraform.tfvars`.
```
cstore_lambda_layer_arn = "{ARN}"
```
```bash
$ terraform init
$ terraform apply
```
#### 2. Push Example Configuration to SSM Parameter Store ####
```bash
$ cd nodejs/example/lambda
$ cstore push ../.env
```
#### 4. Execute Example Lambda ####
```bash
$ export AWS_DEFAULT_REGION=us-east-1
$ aws lambda invoke --function-name cstore_lambda_example response.json
```