---
# System prepended metadata

title: MDP in customers-service steps
tags: [mdp, customers-service, howto]

---

# MDP in customers-service steps

## Table of Contents

[TOC]

## Package.json

```
    "debug": "source .env.local && SLS_DEBUG=* node --inspect ./node_modules/.bin/serverless offline start",
    "slsoffline": "source .env.local && SLS_DEBUG=* npx sls offline start",
    "infra:up": "source .env.local && npx babel-node ./setup-local up && npm run slsoffline",
    "infra:down": "source .env.local && npx babel-node ./setup-local down",
    "mdp-network:up": "docker-compose -f ./node_modules/mdp/mdp-network/docker-compose.yml up",
    "mdp-network:down": "docker-compose -f ./node_modules/mdp/mdp-network/docker-compose.yml down"
```

## env.local

```
export AWS_STAGE=local
export AWS_REGION=eu-west-1
export BUILD_VERSION='test'
export BUILD_ID='test'
export BUILD_COMMIT='test'

export billingEngineStreamArn=arn:aws:kinesis:us-east-1:000000000000:stream/billing-engine-local
export usersStreamArn=arn:aws:kinesis:us-east-1:000000000000:stream/users-local


export juniferEnabled=true
export juniferSmartMetersEnabled=true
export juniferPaymentMethodDDVEnabled=true
export juniferPaymentMethodDDFEnabled=true
export juniferPaymentMethodONDEMANDEnabled=true
export juniferEVEnabled=false
export juniferPaymentMethodPAYGEnabled=false
export bankAccountsApiKeySecretId=bankAccountsApiKeySecretId
```


## setup-local.js

```
import {
  serverlessYaml,
  kinesis,
  report,
  secretsmanager
} from 'mdp'

const up = async () => {
  await serverlessYaml.up(`${__dirname}`)

  const bankAccountsApiKeySecret = await secretsmanager.createSecret({
    Name: 'bankAccountsApiKeySecretId',
    SecretString: JSON.stringify({
      key: '6Lh9wAF0UY3kBq3IhVxOQ64bnuVHaSsA92zKrKYF'
    })
  })
  const usersStream = await kinesis.createStream({ StreamName: `users-${process.env.AWS_STAGE}` })
  const billingEngineStream = await kinesis.createStream({ StreamName: `billing-engine-${process.env.AWS_STAGE}` })

  report('CUSTOM PROVISIONER', [
    usersStream,
    billingEngineStream,
    bankAccountsApiKeySecret
  ])
}

const down = async () => {
  await serverlessYaml.down(`${__dirname}`)

  const bankAccountsApiKeySecret = await secretsmanager.deleteSecret({
    SecretId: 'bankAccountsApiKeySecretId'
  })
  const usersStream = await kinesis.deleteStream({ StreamName: `users-${process.env.AWS_STAGE}` })
  const billingEngineStream = await kinesis.deleteStream({ StreamName: `billing-engine-${process.env.AWS_STAGE}` })

  report('CUSTOM DESTROYED', [
    usersStream,
    billingEngineStream,
    bankAccountsApiKeySecret
  ])
}

if (process.argv[2] === 'down') {
  down()
} else {
  up()
}
```

## Steps
1. `npm install git+ssh://git@bitbucket.org/ecotricity/mdp.git#semver:2.0.0 git+ssh://git@bitbucket.org/ecotricity/serverless-offline-mdp.git#semver:2.0.0`
2. Add `serverless-offline-mdp` to the plugins in the serverless yml
2. Provide hardcoded value for secret manager env var that gets passed to lambda.  `bankAccountsApiKeySecretId: bankAccountsApiKeySecretId`
3. `npm run mdp-network:up`
5. `npm run infra:up`
6. `npm run infra:down`
4. `npm run mdp-network:down`


###### tags: `mdp` `customers-service` `howto`
