-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage.ts
37 lines (29 loc) · 955 Bytes
/
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
30
31
32
33
34
35
36
37
import { CfnOutput, Stack, App } from 'aws-cdk-lib'
import { CrossRegionStackExport } from '@reapit-cdk/cross-region-stack-export'
import { Bucket } from 'aws-cdk-lib/aws-s3'
const app = new App()
const euStack = new Stack(app, 'stack-eu', {
env: {
account: '11111111',
region: 'eu-west-1',
},
})
const exporter = new CrossRegionStackExport(euStack, 'exporter')
exporter.setValue('thing', 'avalue')
const bucket = new Bucket(euStack, 'bucket')
exporter.setValue('bucketArn', bucket.bucketArn)
const usStack = new Stack(app, 'stack-us', {
env: {
account: '2222222222',
region: 'us-east-1',
},
})
const importer = exporter.getImporter(usStack, 'eu-importer')
const euThing = importer.getValue('thing')
const euBucket = Bucket.fromBucketArn(usStack, 'eu-bucket', importer.getValue('bucketArn'))
new CfnOutput(usStack, 'euThing', {
value: euThing,
})
new CfnOutput(usStack, 'euBucketName', {
value: euBucket.bucketName,
})