forked from aws/aws-cdk
/
integ.core-cross-stack-string-list-references.ts
72 lines (59 loc) · 1.99 KB
/
integ.core-cross-stack-string-list-references.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as ssm from '@aws-cdk/aws-ssm';
import { App, CfnParameter, Stack, StackProps } from '@aws-cdk/core';
import { IntegTest } from '@aws-cdk/integ-tests';
import { Construct } from 'constructs';
import { InterfaceVpcEndpoint, InterfaceVpcEndpointAwsService, Vpc } from '../lib';
// GIVEN
const app = new App({
treeMetadata: false,
});
class ProducerStack extends Stack {
public stringListGetAtt: string[];
public stringListRef: CfnParameter;
public manualExport: string[];
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const vpc = new Vpc(this, 'vpc');
this.stringListGetAtt = new InterfaceVpcEndpoint(this, 'endpoint', {
vpc,
service: InterfaceVpcEndpointAwsService.SECRETS_MANAGER,
}).vpcEndpointDnsEntries;
this.stringListRef = new CfnParameter(this, 'stringListParam', {
default: 'BLAT,BLAH',
type: 'List<String>',
});
this.manualExport = this.exportListValue(['string1', 'string2'], {
name: 'ManualExport',
});
}
}
export interface consumerDeployProps extends StackProps {
stringListGetAtt: string[],
stringListRef: CfnParameter,
manualStringList: string[]
}
class ConsumerStack extends Stack {
constructor(scope: Construct, id: string, props: consumerDeployProps) {
super(scope, id, props);
new ssm.StringListParameter(this, 'GetAtt', {
stringListValue: props.stringListGetAtt,
});
new ssm.StringListParameter(this, 'Ref', {
stringListValue: props.stringListRef.valueAsList,
});
new ssm.StringListParameter(this, 'Manual', {
stringListValue: props.manualStringList,
});
}
}
const producer = new ProducerStack(app, 'producer');
const consumer = new ConsumerStack(app, 'consumer', {
stringListGetAtt: producer.stringListGetAtt,
stringListRef: producer.stringListRef,
manualStringList: producer.manualExport,
});
// THEN
new IntegTest(app, 'cross-region-references', {
testCases: [producer, consumer],
stackUpdateWorkflow: false,
});