-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
integ.core-custom-resources.ts
55 lines (47 loc) · 1.75 KB
/
integ.core-custom-resources.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
/*
* Stack verification steps:
* - Deploy with `--no-clean`
* - Verify that the CloudFormation stack outputs have the following values:
* - Ref: "MyPhysicalReflectBack"
* - GetAtt.Attribute1: "foo"
* - GetAtt.Attribute2: 1234
*/
import { App, CfnOutput, CustomResource, CustomResourceProvider, CustomResourceProviderRuntime, Stack, Token } from '@aws-cdk/core';
import { Construct } from 'constructs';
/* eslint-disable @aws-cdk/no-core-construct */
class TestStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
const resourceType = 'Custom::Reflect';
const lengthyResourceType = 'Custom::Given_Resource_Type_Is_Exactly_Sixty_Characters_Long';
const serviceToken = CustomResourceProvider.getOrCreate(this, resourceType, {
codeDirectory: `${__dirname}/core-custom-resource-provider-fixture`,
runtime: CustomResourceProviderRuntime.NODEJS_14_X,
description: 'veni vidi vici',
});
const cr = new CustomResource(this, 'MyResource', {
resourceType,
serviceToken,
properties: {
physicalResourceId: 'MyPhysicalReflectBack',
attributes: {
Attribute1: 'foo',
Attribute2: 1234,
},
},
});
new CustomResource(this, 'MyLengthyTypeResource', {
resourceType: lengthyResourceType,
serviceToken,
properties: {
physicalResourceId: 'MyPhysicalLengthyType',
},
});
new CfnOutput(this, 'Ref', { value: cr.ref });
new CfnOutput(this, 'GetAtt.Attribute1', { value: Token.asString(cr.getAtt('Attribute1')) });
new CfnOutput(this, 'GetAtt.Attribute2', { value: Token.asString(cr.getAtt('Attribute2')) });
}
}
const app = new App();
new TestStack(app, 'custom-resource-test');
app.synth();