@@ -9,6 +9,10 @@ const log = require('log').get('serverless');
9
9
const awsRequest = require ( '@serverless/test/aws-request' ) ;
10
10
const fsp = require ( 'fs' ) . promises ;
11
11
const path = require ( 'path' ) ;
12
+ const CloudFormationService = require ( 'aws-sdk' ) . CloudFormation ;
13
+ const SecretsManagerService = require ( 'aws-sdk' ) . SecretsManager ;
14
+ const KafkaService = require ( 'aws-sdk' ) . Kafka ;
15
+
12
16
const {
13
17
SHARED_INFRA_TESTS_CLOUDFORMATION_STACK ,
14
18
SHARED_INFRA_TESTS_ACTIVE_MQ_CREDENTIALS_NAME ,
@@ -22,7 +26,7 @@ const ensureActiveMQCredentialsSecret = async () => {
22
26
} ;
23
27
log . notice ( 'Creating SecretsManager ActiveMQ Credentials secret...' ) ;
24
28
try {
25
- await awsRequest ( 'SecretsManager' , 'createSecret' , {
29
+ await awsRequest ( SecretsManagerService , 'createSecret' , {
26
30
Name : SHARED_INFRA_TESTS_ACTIVE_MQ_CREDENTIALS_NAME ,
27
31
SecretString : JSON . stringify ( ssmMqCredentials ) ,
28
32
} ) ;
@@ -40,7 +44,7 @@ const ensureRabbitMQCredentialsSecret = async () => {
40
44
} ;
41
45
log . notice ( 'Creating SecretsManager RabbitMQ Credentials secret...' ) ;
42
46
try {
43
- await awsRequest ( 'SecretsManager' , 'createSecret' , {
47
+ await awsRequest ( SecretsManagerService , 'createSecret' , {
44
48
Name : SHARED_INFRA_TESTS_RABBITMQ_CREDENTIALS_NAME ,
45
49
SecretString : JSON . stringify ( ssmMqCredentials ) ,
46
50
} ) ;
@@ -67,7 +71,7 @@ async function handleInfrastructureCreation() {
67
71
const clusterConfName = 'integration-tests-msk-cluster-configuration' ;
68
72
69
73
log . notice ( 'Creating MSK Cluster configuration...' ) ;
70
- const clusterConfResponse = await awsRequest ( 'Kafka' , 'createConfiguration' , {
74
+ const clusterConfResponse = await awsRequest ( KafkaService , 'createConfiguration' , {
71
75
Name : clusterConfName ,
72
76
ServerProperties : kafkaServerProperties ,
73
77
KafkaVersions : [ '2.2.1' ] ,
@@ -77,7 +81,7 @@ async function handleInfrastructureCreation() {
77
81
const clusterConfigurationRevision = clusterConfResponse . LatestRevision . Revision . toString ( ) ;
78
82
79
83
log . notice ( 'Deploying integration tests CloudFormation stack...' ) ;
80
- await awsRequest ( 'CloudFormation' , 'createStack' , {
84
+ await awsRequest ( CloudFormationService , 'createStack' , {
81
85
StackName : SHARED_INFRA_TESTS_CLOUDFORMATION_STACK ,
82
86
TemplateBody : cfnTemplate ,
83
87
Parameters : [
@@ -108,7 +112,7 @@ async function handleInfrastructureCreation() {
108
112
] ,
109
113
} ) ;
110
114
111
- await awsRequest ( 'CloudFormation' , 'waitFor' , 'stackCreateComplete' , {
115
+ await awsRequest ( CloudFormationService , 'waitFor' , 'stackCreateComplete' , {
112
116
StackName : SHARED_INFRA_TESTS_CLOUDFORMATION_STACK ,
113
117
} ) ;
114
118
log . notice ( 'Deployed integration tests CloudFormation stack!' ) ;
@@ -123,7 +127,7 @@ async function handleInfrastructureUpdate() {
123
127
const cfnTemplate = await fsp . readFile ( path . join ( __dirname , 'cloudformation.yml' ) , 'utf8' ) ;
124
128
125
129
try {
126
- await awsRequest ( 'CloudFormation' , 'updateStack' , {
130
+ await awsRequest ( CloudFormationService , 'updateStack' , {
127
131
StackName : SHARED_INFRA_TESTS_CLOUDFORMATION_STACK ,
128
132
TemplateBody : cfnTemplate ,
129
133
Parameters : [
@@ -161,7 +165,7 @@ async function handleInfrastructureUpdate() {
161
165
throw e ;
162
166
}
163
167
164
- await awsRequest ( 'CloudFormation' , 'waitFor' , 'stackUpdateComplete' , {
168
+ await awsRequest ( CloudFormationService , 'waitFor' , 'stackUpdateComplete' , {
165
169
StackName : SHARED_INFRA_TESTS_CLOUDFORMATION_STACK ,
166
170
} ) ;
167
171
log . notice ( 'Updated integration tests CloudFormation stack!' ) ;
@@ -206,7 +210,7 @@ async function handleInfrastructureUpdate() {
206
210
207
211
log . notice ( 'Checking if integration tests CloudFormation stack already exists...' ) ;
208
212
try {
209
- describeResponse = await awsRequest ( 'CloudFormation' , 'describeStacks' , {
213
+ describeResponse = await awsRequest ( CloudFormationService , 'describeStacks' , {
210
214
StackName : SHARED_INFRA_TESTS_CLOUDFORMATION_STACK ,
211
215
} ) ;
212
216
log . notice ( 'Integration tests CloudFormation stack already exists' ) ;
0 commit comments