Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e7020a0

Browse files
committedJul 6, 2023
update integ tests to diff assets and snapshots
1 parent 153f5a9 commit e7020a0

File tree

1,364 files changed

+376124
-45377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,364 files changed

+376124
-45377
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
const aws = require('aws-sdk');
3+
const { ACM, waitUntilCertificateValidated } = require('@aws-sdk/client-acm');
4+
const { Route53, waitUntilResourceRecordSetsChanged } = require('@aws-sdk/client-route-53');
45

56
const defaultSleep = function (ms) {
67
return new Promise(resolve => setTimeout(resolve, ms));
@@ -74,12 +75,12 @@ let report = function (event, context, responseStatus, physicalResourceId, respo
7475
*/
7576
const addTags = async function(certificateArn, region, tags) {
7677
const result = Array.from(Object.entries(tags)).map(([Key, Value]) => ({ Key, Value }))
77-
const acm = new aws.ACM({ region });
78+
const acm = new ACM({ region });
7879

7980
await acm.addTagsToCertificate({
8081
CertificateArn: certificateArn,
8182
Tags: result,
82-
}).promise();
83+
});
8384
}
8485

8586
/**
@@ -96,12 +97,8 @@ const addTags = async function(certificateArn, region, tags) {
9697
*/
9798
const requestCertificate = async function (requestId, domainName, subjectAlternativeNames, certificateTransparencyLoggingPreference, hostedZoneId, region, route53Endpoint) {
9899
const crypto = require('crypto');
99-
const acm = new aws.ACM({ region });
100-
const route53 = route53Endpoint ? new aws.Route53({ endpoint: route53Endpoint }) : new aws.Route53();
101-
if (waiter) {
102-
// Used by the test suite, since waiters aren't mockable yet
103-
route53.waitFor = acm.waitFor = waiter;
104-
}
100+
const acm = new ACM({ region });
101+
const route53 = route53Endpoint ? new Route53({ endpoint: route53Endpoint }) : new Route53();
105102

106103
console.log(`Requesting certificate for ${domainName}`);
107104

@@ -113,7 +110,7 @@ const requestCertificate = async function (requestId, domainName, subjectAlterna
113110
},
114111
IdempotencyToken: crypto.createHash('sha256').update(requestId).digest('hex').slice(0, 32),
115112
ValidationMethod: 'DNS'
116-
}).promise();
113+
});
117114

118115
console.log(`Certificate ARN: ${reqCertResponse.CertificateArn}`);
119116

@@ -123,7 +120,7 @@ const requestCertificate = async function (requestId, domainName, subjectAlterna
123120
for (let attempt = 0; attempt < maxAttempts && !records.length; attempt++) {
124121
const { Certificate } = await acm.describeCertificate({
125122
CertificateArn: reqCertResponse.CertificateArn
126-
}).promise();
123+
});
127124

128125
records = getDomainValidationRecords(Certificate);
129126
if (!records.length) {
@@ -143,14 +140,13 @@ const requestCertificate = async function (requestId, domainName, subjectAlterna
143140
await commitRoute53Records(route53, records, hostedZoneId);
144141

145142
console.log('Waiting for validation...');
146-
await acm.waitFor('certificateValidated', {
147-
// Wait up to 9 minutes and 30 seconds
148-
$waiter: {
149-
delay: 30,
150-
maxAttempts: 19
151-
},
143+
await waitUntilCertificateValidated({
144+
client: acm,
145+
maxAttempts: 19,
146+
delay: 30,
147+
}, {
152148
CertificateArn: reqCertResponse.CertificateArn
153-
}).promise();
149+
})
154150

155151
return reqCertResponse.CertificateArn;
156152
};
@@ -162,12 +158,8 @@ const requestCertificate = async function (requestId, domainName, subjectAlterna
162158
* @param {string} arn The certificate ARN
163159
*/
164160
const deleteCertificate = async function (arn, region, hostedZoneId, route53Endpoint, cleanupRecords) {
165-
const acm = new aws.ACM({ region });
166-
const route53 = route53Endpoint ? new aws.Route53({ endpoint: route53Endpoint }) : new aws.Route53();
167-
if (waiter) {
168-
// Used by the test suite, since waiters aren't mockable yet
169-
route53.waitFor = acm.waitFor = waiter;
170-
}
161+
const acm = new ACM({ region });
162+
const route53 = route53Endpoint ? new Route53({ endpoint: route53Endpoint }) : new Route53();
171163

172164
try {
173165
console.log(`Waiting for certificate ${arn} to become unused`);
@@ -177,7 +169,7 @@ const deleteCertificate = async function (arn, region, hostedZoneId, route53Endp
177169
for (let attempt = 0; attempt < maxAttempts; attempt++) {
178170
const { Certificate } = await acm.describeCertificate({
179171
CertificateArn: arn
180-
}).promise();
172+
});
181173

182174
if (cleanupRecords) {
183175
records = getDomainValidationRecords(Certificate);
@@ -206,7 +198,7 @@ const deleteCertificate = async function (arn, region, hostedZoneId, route53Endp
206198

207199
await acm.deleteCertificate({
208200
CertificateArn: arn
209-
}).promise();
201+
});
210202

211203
if (cleanupRecords) {
212204
console.log(`Deleting ${records.length} DNS records from zone ${hostedZoneId}:`);
@@ -268,17 +260,16 @@ async function commitRoute53Records(route53, records, hostedZoneId, action = 'UP
268260
}),
269261
},
270262
HostedZoneId: hostedZoneId
271-
}).promise();
263+
});
272264

273265
console.log('Waiting for DNS records to commit...');
274-
await route53.waitFor('resourceRecordSetsChanged', {
275-
// Wait up to 5 minutes
276-
$waiter: {
277-
delay: 30,
278-
maxAttempts: 10
279-
},
280-
Id: changeBatch.ChangeInfo.Id
281-
}).promise();
266+
await waitUntilResourceRecordSetsChanged({
267+
client: route53,
268+
delay: 30,
269+
maxAttempts: 10,
270+
}, {
271+
Id: changeBatch.ChangeInfo.Id,
272+
});
282273
}
283274

284275
/**
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"31.0.0"}
1+
{"version":"32.0.0"}

0 commit comments

Comments
 (0)