@reapit-cdk/replicated-key
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

@reapit-cdk/replicated-key

npm version npm downloads coverage: 99.02%25 Integ Tests: ✔

Creates a KMS key and replicates it to the desired regions. Useful when replicating secrets across regions.

Package Installation:

yarn add --dev @reapit-cdk/replicated-key
# or
npm install @reapit-cdk/replicated-key --save-dev

Usage

import { Stack, App } from 'aws-cdk-lib'
import { ReplicatedKey } from '@reapit-cdk/replicated-key'
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda'

const app = new App()
const stack = new Stack(app, 'stack-name', {
  env: {
    region: 'us-east-1', // region must be specified
  },
})
const key = new ReplicatedKey(stack, 'key', {
  replicaRegions: ['af-south-1', 'cn-north-1'],
})

const lambda = new Function(stack, 'lambda', {
  runtime: Runtime.NODEJS_18_X,
  handler: 'lambda.handler',
  code: Code.fromInline('export const handler = () => {}'),
  environment: {
    usKeyArn: key.getRegionalKey('us-east-1').keyArn,
    afKeyArn: key.getRegionalKey('af-south-1').keyArn,
    cnKeyArn: key.getRegionalKey('cn-north-1').keyArn,
  },
})

key.grantEncryptDecrypt(lambda)

Readme

Keywords

Package Sidebar

Install

npm i @reapit-cdk/replicated-key

Weekly Downloads

29

Version

0.1.2

License

MIT

Unpacked Size

146 kB

Total Files

12

Last publish

Collaborators

  • joshbalfour