-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathses_verifydomainidentity.js
44 lines (37 loc) · 1.54 KB
/
ses_verifydomainidentity.js
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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/*
ABOUT THIS NODE.JS EXAMPLE: This example works with the AWS SDK for JavaScript version 3 (v3),
which is available at https://github.com/aws/aws-sdk-js-v3. This example is in the 'AWS SDK for JavaScript v3 Developer Guide' at
https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/ses-examples-managing-identities.html.
Purpose:
ses_verifydomainidentity.js demonstrates how to add a domain to the list of Amazon SES identities and attempts to verify it.
Running the code:
node ses_verifydomainidentity.js
*/
// snippet-start:[ses.JavaScript.identities.verifyDomainIdentityV3]
import { VerifyDomainIdentityCommand } from "@aws-sdk/client-ses";
import {
getUniqueName,
postfix,
} from "@aws-doc-sdk-examples/lib/utils/util-string.js";
import { sesClient } from "./libs/sesClient.js";
/**
* You must have access to the domain's DNS settings to complete the
* domain verification process.
*/
const DOMAIN_NAME = postfix(getUniqueName("Domain"), ".example.com");
const createVerifyDomainIdentityCommand = () => {
return new VerifyDomainIdentityCommand({ Domain: DOMAIN_NAME });
};
const run = async () => {
const VerifyDomainIdentityCommand = createVerifyDomainIdentityCommand();
try {
return await sesClient.send(VerifyDomainIdentityCommand);
} catch (err) {
console.log("Failed to verify domain.", err);
return err;
}
};
// snippet-end:[ses.JavaScript.identities.verifyDomainIdentityV3]
export { run, DOMAIN_NAME };