-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathdelete-tracker.js
More file actions
37 lines (32 loc) · 1.1 KB
/
delete-tracker.js
File metadata and controls
37 lines (32 loc) · 1.1 KB
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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[location.JavaScript.tracker.deleteTrackerV3]
import { fileURLToPath } from "node:url";
import {
DeleteTrackerCommand,
LocationClient,
ResourceNotFoundException,
} from "@aws-sdk/client-location";
import data from "./inputs.json" with { type: "json" };
const region = "eu-west-1";
export const main = async () => {
const deleteTrackerParams = {
TrackerName: `${data.inputs.trackerName}`,
};
try {
const locationClient = new LocationClient({ region: region });
const command = new DeleteTrackerCommand(deleteTrackerParams);
const response = await locationClient.send(command);
console.log("Tracker deleted.");
} catch (caught) {
if (caught instanceof ResourceNotFoundException) {
console.error(`${data.inputs.trackerName} tracker not found.`);
return;
}
}
};
// snippet-end:[location.JavaScript.tracker.deleteTrackerV3]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}