Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@aws-sdk/client-ssm
Advanced tools
AWS SDK for JavaScript Ssm Client for Node.js, Browser and React Native
The @aws-sdk/client-ssm package is a client library for the AWS Systems Manager (SSM) service. It allows developers to interact with the SSM service programmatically to manage configuration and automation tasks. The package provides methods to send commands, manage parameters, and configure instances and applications.
Managing Parameters
This feature allows you to create and manage parameters in the AWS Systems Manager Parameter Store. The code sample demonstrates how to put a new parameter into the Parameter Store.
const { SSMClient, PutParameterCommand } = require('@aws-sdk/client-ssm');
const client = new SSMClient({ region: 'us-west-2' });
const command = new PutParameterCommand({
Name: 'parameterName',
Value: 'parameterValue',
Type: 'String'
});
client.send(command).then((data) => console.log(data)).catch((error) => console.error(error));
Sending Commands
This feature enables you to send commands to instances for execution. The code sample shows how to send a simple shell script command to an EC2 instance.
const { SSMClient, SendCommandCommand } = require('@aws-sdk/client-ssm');
const client = new SSMClient({ region: 'us-west-2' });
const command = new SendCommandCommand({
InstanceIds: ['i-1234567890abcdef0'],
DocumentName: 'AWS-RunShellScript',
Parameters: { 'commands': ['echo "Hello World"'] }
});
client.send(command).then((data) => console.log(data.CommandId)).catch((error) => console.error(error));
Getting Command Invocation Results
This feature is used to retrieve the results of a command execution on a particular instance. The code sample demonstrates how to get the result of a command invocation.
const { SSMClient, GetCommandInvocationCommand } = require('@aws-sdk/client-ssm');
const client = new SSMClient({ region: 'us-west-2' });
const command = new GetCommandInvocationCommand({
CommandId: 'commandId',
InstanceId: 'i-1234567890abcdef0'
});
client.send(command).then((data) => console.log(data)).catch((error) => console.error(error));
The 'aws-sdk' package is the older version of the AWS SDK for JavaScript. It provides similar functionalities to interact with AWS services, including SSM. However, @aws-sdk/client-ssm is part of the newer AWS SDK v3, which is modular and allows for importing only the specific clients needed, potentially reducing bundle sizes.
Boto3 is the AWS SDK for Python, which provides similar functionalities for interacting with AWS services, including SSM. While it serves the same purpose, it is designed for Python developers and cannot be used in a Node.js environment.
The Azure SDK for JavaScript is similar in concept to @aws-sdk/client-ssm but for Microsoft Azure services. It allows developers to manage and interact with Azure resources. It is not directly comparable in terms of functionality because it targets a different cloud provider.
AWS SDK for JavaScript SSM Client for Node.js, Browser and React Native.
Amazon Web Services Systems Manager is the operations hub for your Amazon Web Services applications and resources and a secure end-to-end management solution for hybrid cloud environments that enables safe and secure operations at scale.
This reference is intended to be used with the Amazon Web Services Systems Manager User Guide. To get started, see Setting up Amazon Web Services Systems Manager.
Related resources
For information about each of the capabilities that comprise Systems Manager, see Systems Manager capabilities in the Amazon Web Services Systems Manager User Guide.
For details about predefined runbooks for Automation, a capability of Amazon Web Services Systems Manager, see the Systems Manager Automation runbook reference .
For information about AppConfig, a capability of Systems Manager, see the AppConfig User Guide and the AppConfig API Reference .
For information about Incident Manager, a capability of Systems Manager, see the Systems Manager Incident Manager User Guide and the Systems Manager Incident Manager API Reference .
To install this package, simply type add or install @aws-sdk/client-ssm using your favorite package manager:
npm install @aws-sdk/client-ssm
yarn add @aws-sdk/client-ssm
pnpm add @aws-sdk/client-ssm
The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the SSMClient
and
the commands you need, for example ListAssociationsCommand
:
// ES5 example
const { SSMClient, ListAssociationsCommand } = require("@aws-sdk/client-ssm");
// ES6+ example
import { SSMClient, ListAssociationsCommand } from "@aws-sdk/client-ssm";
To send a request, you:
send
operation on client with command object as input.destroy()
to close open connections.// a client can be shared by different commands.
const client = new SSMClient({ region: "REGION" });
const params = {
/** input parameters */
};
const command = new ListAssociationsCommand(params);
We recommend using await operator to wait for the promise returned by send operation as follows:
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
Async-await is clean, concise, intuitive, easy to debug and has better error handling as compared to using Promise chains or callbacks.
You can also use Promise chaining to execute send operation.
client.send(command).then(
(data) => {
// process data.
},
(error) => {
// error handling.
}
);
Promises can also be called using .catch()
and .finally()
as follows:
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
We do not recommend using callbacks because of callback hell, but they are supported by the send operation.
// callbacks.
client.send(command, (err, data) => {
// process err and data.
});
The client can also send requests using v2 compatible style. However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post on modular packages in AWS SDK for JavaScript
import * as AWS from "@aws-sdk/client-ssm";
const client = new AWS.SSM({ region: "REGION" });
// async/await.
try {
const data = await client.listAssociations(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listAssociations(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks.
client.listAssociations(params, (err, data) => {
// process err and data.
});
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
// process data.
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
/**
* The keys within exceptions are also parsed.
* You can access them by specifying exception names:
* if (error.name === 'SomeServiceException') {
* const value = error.specialKeyInException;
* }
*/
}
Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
aws-sdk-js
on AWS Developer Blog.aws-sdk-js
.To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-ssm
package is updated.
To contribute to client you can check our generate clients scripts.
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.
3.686.0 (2024-11-06)
FAQs
AWS SDK for JavaScript Ssm Client for Node.js, Browser and React Native
We found that @aws-sdk/client-ssm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.