What is @aws-sdk/client-ssm?
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.
What are @aws-sdk/client-ssm's main functionalities?
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));
Other packages similar to @aws-sdk/client-ssm
aws-sdk
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
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.
azure-sdk-for-js
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.