-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.ts
29 lines (28 loc) · 1.04 KB
/
usage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Stack, App } from 'aws-cdk-lib'
import { Function, Runtime, Code } from 'aws-cdk-lib/aws-lambda'
import { ReplicatedKey } from '@reapit-cdk/replicated-key'
import { ReplicatedSecret } from '@reapit-cdk/replicated-secret'
const app = new App()
const stack = new Stack(app, 'stack-name', {
env: {
region: 'us-east-1', // region must be specified
},
})
const replicatedKey = new ReplicatedKey(stack, 'key', {
replicaRegions: ['af-south-1', 'cn-north-1'],
})
const replicatedSecret = new ReplicatedSecret(stack, 'secret', {
replicaRegions: ['af-south-1', 'cn-north-1'],
replicatedKey,
})
const lambda = new Function(stack, 'lambda', {
runtime: Runtime.NODEJS_18_X,
handler: 'lambda.handler',
code: Code.fromInline('export const handler = () => {}'),
environment: {
usSecretArn: replicatedSecret.getRegionalSecret('us-east-1').secretArn,
afSecretArn: replicatedSecret.getRegionalSecret('af-south-1').secretArn,
cnSecretArn: replicatedSecret.getRegionalSecret('cn-north-1').secretArn,
},
})
replicatedSecret.grantWrite(lambda)