// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import { fileURLToPath } from "node:url"; // snippet-start:[javascript.v3.support.scenarios.Hello] import { DescribeServicesCommand, SupportClient, } from "@aws-sdk/client-support"; // Change the value of 'region' to your preferred AWS Region. const client = new SupportClient({ region: "us-east-1" }); const getServiceCount = async () => { try { const { services } = await client.send(new DescribeServicesCommand({})); return services.length; } catch (err) { if (err.name === "SubscriptionRequiredException") { throw new Error( "You must be subscribed to the AWS Support plan to use this feature.", ); } throw err; } }; export const main = async () => { try { const count = await getServiceCount(); console.log(`Hello, AWS Support! There are ${count} services available.`); } catch (err) { console.error("Failed to get service count: ", err.message); } }; // snippet-end:[javascript.v3.support.scenarios.Hello] // Invoke main function if this file was run directly. if (process.argv[1] === fileURLToPath(import.meta.url)) { main(); }