11import { describe , it , before , after } from 'node:test' ;
22import { DescribeDBSubnetGroupsCommand , RDSClient } from '@aws-sdk/client-rds' ;
3- import { DescribeKeyCommand , GetKeyRotationStatusCommand , KMSClient } from '@aws-sdk/client-kms' ;
4- import { DescribeSecurityGroupsCommand , EC2Client , IpPermission } from '@aws-sdk/client-ec2' ;
3+ import {
4+ DescribeKeyCommand ,
5+ GetKeyRotationStatusCommand ,
6+ KMSClient ,
7+ } from '@aws-sdk/client-kms' ;
8+ import {
9+ DescribeSecurityGroupsCommand ,
10+ EC2Client ,
11+ IpPermission ,
12+ } from '@aws-sdk/client-ec2' ;
513import * as assert from 'node:assert' ;
614import * as automation from '../automation' ;
715import * as config from './infrastructure/config' ;
816import { DatabaseTestContext } from './test-context' ;
9- import { InlineProgramArgs } from "@pulumi/pulumi/automation" ;
17+ import { IAMClient } from '@aws-sdk/client-iam' ;
18+ import { InlineProgramArgs } from '@pulumi/pulumi/automation' ;
19+ import { testDbWithMonitoring } from './monitoring.test' ;
1020
1121const programArgs : InlineProgramArgs = {
1222 stackName : 'dev' ,
1323 projectName : 'icb-test-database' ,
1424 program : ( ) => import ( './infrastructure' ) ,
1525} ;
1626
17- // TODO: Add tests for monitoring role & encrypted snapshot copy
27+ // TODO: Add tests for encrypted snapshot copy
1828
1929describe ( 'Database component deployment' , ( ) => {
2030 const region = process . env . AWS_REGION ;
@@ -29,8 +39,9 @@ describe('Database component deployment', () => {
2939 rds : new RDSClient ( { region } ) ,
3040 ec2 : new EC2Client ( { region } ) ,
3141 kms : new KMSClient ( { region } ) ,
32- }
33- }
42+ iam : new IAMClient ( { region } ) ,
43+ } ,
44+ } ;
3445
3546 before ( async ( ) => {
3647 ctx . outputs = await automation . deploy ( programArgs ) ;
@@ -51,11 +62,31 @@ describe('Database component deployment', () => {
5162 assert . ok ( database . dbSubnetGroup , 'Subnet group should be defined' ) ;
5263 assert . ok ( database . kms , 'Encryption key should be defined' ) ;
5364 assert . ok ( database . password , 'Password should be defined' ) ;
54- assert . strictEqual ( database . instance . dbName , config . dbName , 'Db name argument should be set correctly' ) ;
55- assert . strictEqual ( database . instance . username , config . username , 'Username argument should be set correctly' ) ;
56- assert . strictEqual ( database . instance . password , config . password , 'Password argument should be set correctly' ) ;
57- assert . strictEqual ( database . instance . applyImmediately , config . applyImmediately , 'Apply immediately argument should be set correctly' ) ;
58- assert . strictEqual ( database . instance . skipFinalSnapshot , config . skipFinalSnapshot , 'Skip final snapshot argument should be set correctly' ) ;
65+ assert . strictEqual (
66+ database . instance . dbName ,
67+ config . dbName ,
68+ 'Db name argument should be set correctly' ,
69+ ) ;
70+ assert . strictEqual (
71+ database . instance . username ,
72+ config . username ,
73+ 'Username argument should be set correctly' ,
74+ ) ;
75+ assert . strictEqual (
76+ database . instance . password ,
77+ config . password ,
78+ 'Password argument should be set correctly' ,
79+ ) ;
80+ assert . strictEqual (
81+ database . instance . applyImmediately ,
82+ config . applyImmediately ,
83+ 'Apply immediately argument should be set correctly' ,
84+ ) ;
85+ assert . strictEqual (
86+ database . instance . skipFinalSnapshot ,
87+ config . skipFinalSnapshot ,
88+ 'Skip final snapshot argument should be set correctly' ,
89+ ) ;
5990 } ) ;
6091
6192 it ( 'should create subnet group in the correct VPC' , async ( ) => {
@@ -133,11 +164,7 @@ describe('Database component deployment', () => {
133164 'ENCRYPT_DECRYPT' ,
134165 'KMS key should be used for encryption/decryption' ,
135166 ) ;
136- assert . strictEqual (
137- KeyMetadata . Enabled ,
138- true ,
139- 'KMS key should be enabled' ,
140- ) ;
167+ assert . strictEqual ( KeyMetadata . Enabled , true , 'KMS key should be enabled' ) ;
141168 assert . strictEqual (
142169 KeyMetadata . MultiRegion ,
143170 false ,
@@ -152,4 +179,6 @@ describe('Database component deployment', () => {
152179 'KMS key rotation should be enabled' ,
153180 ) ;
154181 } ) ;
182+
183+ describe ( 'With monitoring' , ( ) => testDbWithMonitoring ( ctx ) ) ;
155184} ) ;
0 commit comments