Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit 1ac0694

Browse files
jxpearce-godaddySilas Boyd-Wickizer
authored and
Silas Boyd-Wickizer
committed
chore(localstack): add support for running with localstack (#85)
1 parent ffb6c5a commit 1ac0694

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

README.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The conversion is completely transparent to `Pods` that can access `Secrets` nor
1616

1717
![Architecture](architecture.png)
1818

19-
1. `ExternalSecrets` are added in the cluster (e.g., `kubectly apply -f external-secret-example.yml`)
19+
1. `ExternalSecrets` are added in the cluster (e.g., `kubectl apply -f external-secret-example.yml`)
2020
1. Controller fetches `ExternalSecrets` using the Kubernetes API
2121
1. Controller uses `ExternalSecrets` to fetch secret data from external providers (e.g, AWS Secrets Manager)
2222
1. Controller upsert `Secrets`
@@ -172,3 +172,31 @@ minikube start
172172
173173
npm run nodemon
174174
```
175+
176+
### Development with localstack
177+
178+
[Localstack](https://github.com/localstack/localstack) mocks AWS services locally so you can test without connecting to AWS.
179+
180+
Run localstack in a seperate terminal window
181+
182+
```sh
183+
npm run localstack
184+
```
185+
186+
Start minikube as above
187+
188+
```sh
189+
minikube start
190+
```
191+
192+
Run the daemon with localstack
193+
194+
```sh
195+
npm run local
196+
```
197+
198+
Add secrets using the AWS cli (example)
199+
200+
```sh
201+
aws --endpoint-url=http://localhost:4584 secretsmanager create-secret --name hello-service/password --secret-string "1234"
202+
```

config/aws-config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict'
2+
3+
/* eslint-disable no-process-env */
4+
5+
const localstack = process.env.LOCALSTACK || 0
6+
7+
const secretsManagerConfig = localstack ? { endpoint: 'http://localhost:4584', region: 'us-west-2' } : {}
8+
const systemManagerConfig = localstack ? { endpoint: 'http://localhost:4583', region: 'us-west-2' } : {}
9+
10+
module.exports = {
11+
secretsManagerConfig,
12+
systemManagerConfig
13+
}

config/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const kube = require('kubernetes-client')
55
const KubeRequest = require('kubernetes-client/backends/request')
66
const pino = require('pino')
77

8+
const awsConfig = require('./aws-config')
89
const envConfig = require('./environment')
910
const CustomResourceManager = require('../lib/custom-resource-manager')
1011
const customResourceManifest = require('../custom-resource-manifest.json')
@@ -31,9 +32,9 @@ const customResourceManager = new CustomResourceManager({
3132
logger
3233
})
3334

34-
const secretsManagerClient = new AWS.SecretsManager()
35+
const secretsManagerClient = new AWS.SecretsManager(awsConfig.secretsManagerConfig)
3536
const secretsManagerBackend = new SecretsManagerBackend({ client: secretsManagerClient, logger })
36-
const systemManagerClient = new AWS.SSM()
37+
const systemManagerClient = new AWS.SSM(awsConfig.systemManagerConfig)
3738
const systemManagerBackend = new SystemManagerBackend({ client: systemManagerClient, logger })
3839
const backends = {
3940
secretsManager: secretsManagerBackend,

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"scripts": {
77
"coverage": "nyc ./node_modules/mocha/bin/_mocha --recursive lib",
88
"lint": "eslint --fix --ignore-pattern /coverage/ ./",
9+
"local": "LOCALSTACK=1 nodemon",
10+
"localstack": "docker run -it -p 4583:4583 -p 4584:4584 -p 9999:8080 -e DEBUG=1 --rm localstack/localstack:0.9.4",
911
"release": "standard-version --tag-prefix='' && ./release.sh",
1012
"start": "./bin/daemon.js",
1113
"nodemon": "nodemon ./bin/daemon.js",

0 commit comments

Comments
 (0)