SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 215 Java
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// snippet-start:[ssm.JavaScript.Basics.hello]
import { paginateListDocuments, SSMClient } from "@aws-sdk/client-ssm";
// Call ListDocuments and display the result.
export const main = async () => {
const client = new SSMClient();
const listDocumentsPaginated = [];
console.log(
"Hello, AWS Systems Manager! Let's list some of your documents:\n",
);
try {
// The paginate function is a wrapper around the base command.
const paginator = paginateListDocuments({ client }, { MaxResults: 5 });
for await (const page of paginator) {
listDocumentsPaginated.push(...page.DocumentIdentifiers);
}
} catch (caught) {
console.error(`There was a problem saying hello: ${caught.message}`);
throw caught;
}
for (const { Name, DocumentFormat, CreatedDate } of listDocumentsPaginated) {
console.log(`${Name} - ${DocumentFormat} - ${CreatedDate}`);
}
};
// Call function if run directly.
import { fileURLToPath } from "node:url";
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}
// snippet-end:[ssm.JavaScript.Basics.hello]