Skip to content

Latest commit

 

History

History
 
 

ssm_scenario

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

AWS Systems Management Getting Started Scenario

Introduction

This AWS Systems Manager getting started scenario demonstrates how to interact with the AWS Systems Manager service using an AWS SDK. The scenario covers various operations such as creating a maintenance window, creating an SSM document, sending a command to a managed node, creating an OpsItem, updating an OpsItem, and deleting SSM resources.

Setting up Resources

AWS Systems Manager Agent is Amazon software that runs on Amazon Elastic Compute Cloud (Amazon EC2) instances, edge devices, on-premises servers, and virtual machines (VMs). A Systems Manager Agent makes it possible for Systems Manager to update, manage, and configure these resources. To successfully run this getting started scenario, the EC2 instance must have a Systems Manager Agent. For more information, see Working with SSM Agent.

Service Operations Invoked

The program performs the following tasks:

  1. Creates a Systems Manager maintenance window.
  2. Modifies the maintenance window by changing the schedule.
  3. Creates a Systems Manager document that defines the actions Systems Manager performs on managed nodes.
  4. Sends a command to an EC2 instance using the created Systems Manager document.
  5. Retrieves the time when the specific command was sent to the managed node.
  6. Creates a Systems Manager OpsItem to track and manage an operational issue.
  7. Updates the created OpsItem and gets the status.
  8. Resolves the OpsItem.
  9. Optionally deletes the Systems Manager resources (maintenance window, OpsItem, and document).

Usage

  1. Clone the repository or download the source code.
  2. Open the code in your preferred IDE.
  3. This scenario requires the following variables:
    • instanceId: The ID of the EC2 instance to send the command to.
    • title: The title of the OpsItem to create.
    • source: The source of the OpsItem.
    • category: The category of the OpsItem.
    • severity: The severity of the OpsItem.
  4. Run the SSMScenario class.

The program will guide you through the scenario, prompting you to enter the maintenance window name and the document name. The program will also display the progress and results of the various operations.

Code Explanation

The provided code demonstrates the following key features of the AWS SDK and the AWS Systems Manager service:

  1. Maintenance Window Management: The code uses the SsmClient to create, modify, and delete an SSM maintenance window.
  2. SSM Document Management: The code creates an SSM document that defines the actions Systems Manager performs on managed nodes.
  3. Command Execution: The code sends a command to an EC2 instance using the created SSM document and retrieves the timestamp of the command execution.
  4. OpsItem Management: The code creates, updates, and resolves an SSM OpsItem to track and manage an operational issue.
  5. Error Handling: The code includes exception handling for various SSM-related exceptions.
  6. User Interaction: The code prompts the user for input, such as the maintenance window name and the document name.

Overall, this AWS SDK Systems Manager code example is a resource for developers new to AWS Systems Manager and the AWS SDK. It provides a solid foundation for understanding and building applications that interact with the AWS Systems Manager service.