1
- import '@aws-cdk/assert-internal/jest' ;
2
- import { arrayWith } from '@aws-cdk/assert-internal' ;
1
+ import { Match , Template } from '@aws-cdk/assertions' ;
3
2
import * as autoscaling from '@aws-cdk/aws-autoscaling' ;
4
3
import * as ec2 from '@aws-cdk/aws-ec2' ;
5
4
import * as iam from '@aws-cdk/aws-iam' ;
@@ -27,7 +26,7 @@ describe('given an AutoScalingGroup and no role', () => {
27
26
} ) ;
28
27
29
28
afterEach ( ( ) => {
30
- expect ( stack ) . toHaveResource ( 'AWS::IAM::Role' , {
29
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Role' , {
31
30
AssumeRolePolicyDocument : {
32
31
Version : '2012-10-17' ,
33
32
Statement : [
@@ -54,8 +53,8 @@ describe('given an AutoScalingGroup and no role', () => {
54
53
} ) ;
55
54
56
55
// THEN
57
- expect ( stack ) . toHaveResource ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { 'Fn::GetAtt' : [ 'Queue4A7E3555' , 'Arn' ] } } ) ;
58
- expect ( stack ) . toHaveResource ( 'AWS::IAM::Policy' , {
56
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { 'Fn::GetAtt' : [ 'Queue4A7E3555' , 'Arn' ] } } ) ;
57
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Policy' , {
59
58
PolicyDocument : {
60
59
Statement : [
61
60
{
@@ -95,8 +94,8 @@ describe('given an AutoScalingGroup and no role', () => {
95
94
} ) ;
96
95
97
96
// THEN
98
- expect ( stack ) . toHaveResource ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'TopicBFC7AF6E' } } ) ;
99
- expect ( stack ) . toHaveResource ( 'AWS::IAM::Policy' , {
97
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'TopicBFC7AF6E' } } ) ;
98
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Policy' , {
100
99
PolicyDocument : {
101
100
Statement : [
102
101
{
@@ -133,13 +132,13 @@ describe('given an AutoScalingGroup and no role', () => {
133
132
} ) ;
134
133
135
134
// THEN
136
- expect ( stack ) . toHaveResource ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'ASGLifecycleHookTransTopic9B0D4842' } } ) ;
137
- expect ( stack ) . toHaveResource ( 'AWS::SNS::Subscription' , {
135
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'ASGLifecycleHookTransTopic9B0D4842' } } ) ;
136
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::SNS::Subscription' , {
138
137
Protocol : 'lambda' ,
139
138
TopicArn : { Ref : 'ASGLifecycleHookTransTopic9B0D4842' } ,
140
139
Endpoint : { 'Fn::GetAtt' : [ 'Fn9270CBC0' , 'Arn' ] } ,
141
140
} ) ;
142
- expect ( stack ) . toHaveResource ( 'AWS::IAM::Policy' , {
141
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Policy' , {
143
142
PolicyDocument : {
144
143
Statement : [
145
144
{
@@ -177,17 +176,17 @@ describe('given an AutoScalingGroup and no role', () => {
177
176
} ) ;
178
177
179
178
// THEN
180
- expect ( stack ) . toHaveResourceLike ( 'AWS::SNS::Topic' , {
179
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::SNS::Topic' , {
181
180
KmsMasterKeyId : {
182
181
'Fn::GetAtt' : [
183
182
'keyFEDD6EC0' ,
184
183
'Arn' ,
185
184
] ,
186
185
} ,
187
186
} ) ;
188
- expect ( stack ) . toHaveResourceLike ( 'AWS::IAM::Policy' , {
187
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Policy' , {
189
188
PolicyDocument : {
190
- Statement : arrayWith (
189
+ Statement : Match . arrayWith ( [
191
190
{
192
191
Effect : 'Allow' ,
193
192
Action : [
@@ -201,7 +200,7 @@ describe('given an AutoScalingGroup and no role', () => {
201
200
] ,
202
201
} ,
203
202
} ,
204
- ) ,
203
+ ] ) ,
205
204
} ,
206
205
} ) ;
207
206
} ) ;
@@ -223,7 +222,7 @@ describe('given an AutoScalingGroup and a role', () => {
223
222
} ) ;
224
223
225
224
afterEach ( ( ) => {
226
- expect ( stack ) . toHaveResource ( 'AWS::IAM::Role' , {
225
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Role' , {
227
226
AssumeRolePolicyDocument : {
228
227
Version : '2012-10-17' ,
229
228
Statement : [
@@ -253,7 +252,7 @@ describe('given an AutoScalingGroup and a role', () => {
253
252
} ) ;
254
253
255
254
// THEN
256
- expect ( stack ) . toHaveResource ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { 'Fn::GetAtt' : [ 'Queue4A7E3555' , 'Arn' ] } } ) ;
255
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { 'Fn::GetAtt' : [ 'Queue4A7E3555' , 'Arn' ] } } ) ;
257
256
} ) ;
258
257
259
258
test ( 'can use topic as hook target with a role' , ( ) => {
@@ -271,8 +270,8 @@ describe('given an AutoScalingGroup and a role', () => {
271
270
} ) ;
272
271
273
272
// THEN
274
- expect ( stack ) . toHaveResource ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'TopicBFC7AF6E' } } ) ;
275
- expect ( stack ) . toHaveResource ( 'AWS::IAM::Policy' , {
273
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'TopicBFC7AF6E' } } ) ;
274
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Policy' , {
276
275
PolicyDocument : {
277
276
Statement : [
278
277
{
@@ -313,13 +312,13 @@ describe('given an AutoScalingGroup and a role', () => {
313
312
} ) ;
314
313
315
314
// THEN
316
- expect ( stack ) . toHaveResource ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'ASGLifecycleHookTransTopic9B0D4842' } } ) ;
317
- expect ( stack ) . toHaveResource ( 'AWS::SNS::Subscription' , {
315
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::AutoScaling::LifecycleHook' , { NotificationTargetARN : { Ref : 'ASGLifecycleHookTransTopic9B0D4842' } } ) ;
316
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::SNS::Subscription' , {
318
317
Protocol : 'lambda' ,
319
318
TopicArn : { Ref : 'ASGLifecycleHookTransTopic9B0D4842' } ,
320
319
Endpoint : { 'Fn::GetAtt' : [ 'Fn9270CBC0' , 'Arn' ] } ,
321
320
} ) ;
322
- expect ( stack ) . toHaveResource ( 'AWS::IAM::Policy' , {
321
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::IAM::Policy' , {
323
322
PolicyDocument : {
324
323
Statement : [
325
324
{
0 commit comments