ssm

package
v1.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 7 Imported by: 1

README

awsutils/ssm

The ssm package is a collection of utility functions designed to simplify common ssm tasks.


Table of contents


Functions

AgentReady(ssmiface.SSMAPI, string, time.Duration)
AgentReady(ssmiface.SSMAPI, string, time.Duration) bool, error

AgentReady checks if an SSM agent is ready on the instance.

Parameters:

svc: AWS SSM service client. instanceID: AWS EC2 instance ID to check. waitTime: Maximum wait time before timing out.

Returns:

bool: True if the agent is ready, false otherwise. error: An error if any issue occurs while checking the agent.


CheckAWSCLIInstalled(ssmiface.SSMAPI, string)
CheckAWSCLIInstalled(ssmiface.SSMAPI, string) bool, error

CheckAWSCLIInstalled checks if AWS CLI is installed on the instance.

Parameters:

svc: AWS SSM service client. instanceID: AWS EC2 instance ID to check.

Returns:

bool: True if AWS CLI is installed, false otherwise. error: An error if any issue occurs while checking the installation.


CreateConnection()
CreateConnection() Connection

CreateConnection establishes a connection with AWS SSM.

Returns:

Connection: Struct with a connected SSM client and session.


DeleteParam(ssmiface.SSMAPI, string)
DeleteParam(ssmiface.SSMAPI, string) error

DeleteParam removes a parameter from AWS SSM.

Parameters:

svc: AWS SSM service client. name: Name of the parameter to delete.

Returns:

error: An error if any issue occurs while deleting the parameter.


GetParam(ssmiface.SSMAPI, string)
GetParam(ssmiface.SSMAPI, string) string, error

GetParam retrieves a parameter from AWS SSM.

Parameters:

svc: AWS SSM service client. name: Name of the parameter.

Returns:

string: Value of the parameter. error: An error if any issue occurs while fetching the parameter.


ListAllParameters(ssmiface.SSMAPI)
ListAllParameters(ssmiface.SSMAPI) []*ssm.ParameterMetadata, error

ListAllParameters retrieves all parameters in the AWS SSM.

Parameters:

svc: AWS SSM service client.

Returns:

([]*ssm.ParameterMetadata): List of all parameters' metadata. error: An error if any issue occurs while fetching the parameters.


PutParam(ssmiface.SSMAPI, string, string, string, bool)
PutParam(ssmiface.SSMAPI, string, string, string, bool) error

PutParam creates or updates a parameter in AWS SSM.

Parameters:

svc: AWS SSM service client. name: Name of the parameter. value: Value of the parameter. paramType: Type of the parameter. overwrite: Flag to overwrite an existing parameter.

Returns:

error: An error if any issue occurs while creating or updating the parameter.


RunCommand(ssmiface.SSMAPI, string, []string)
RunCommand(ssmiface.SSMAPI, string, []string) string, error

RunCommand executes an input command on an AWS instance via SSM.

Parameters:

svc: AWS SSM service client. instanceID: AWS EC2 instance ID where the command should run. command: List of command strings to be run.

Returns:

string: Output of the command execution. error: An error if any issue occurs while executing the command.


Installation

To use the awsutils/ssm package, you first need to install it. Follow the steps below to install via go get.

go get github.com/l50/awsutils/ssm

Usage

After installation, you can import the package in your Go project using the following import statement:

import "github.com/l50/awsutils/ssm"

Tests

To ensure the package is working correctly, run the following command to execute the tests for awsutils/ssm:

go test -v

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentReady

func AgentReady(svc ssmiface.SSMAPI, instanceID string, waitTime time.Duration) (bool, error)

AgentReady checks if an SSM agent is ready on the instance.

**Parameters:**

svc: AWS SSM service client. instanceID: AWS EC2 instance ID to check. waitTime: Maximum wait time before timing out.

**Returns:**

bool: True if the agent is ready, false otherwise. error: An error if any issue occurs while checking the agent.

func CheckAWSCLIInstalled added in v1.1.1

func CheckAWSCLIInstalled(svc ssmiface.SSMAPI, instanceID string) (bool, error)

CheckAWSCLIInstalled checks if AWS CLI is installed on the instance.

**Parameters:**

svc: AWS SSM service client. instanceID: AWS EC2 instance ID to check.

**Returns:**

bool: True if AWS CLI is installed, false otherwise. error: An error if any issue occurs while checking the installation.

func DeleteParam

func DeleteParam(svc ssmiface.SSMAPI, name string) error

DeleteParam removes a parameter from AWS SSM.

**Parameters:**

svc: AWS SSM service client. name: Name of the parameter to delete.

**Returns:**

error: An error if any issue occurs while deleting the parameter.

func GetParam

func GetParam(svc ssmiface.SSMAPI, name string) (string, error)

GetParam retrieves a parameter from AWS SSM.

**Parameters:**

svc: AWS SSM service client. name: Name of the parameter.

**Returns:**

string: Value of the parameter. error: An error if any issue occurs while fetching the parameter.

func ListAllParameters added in v1.1.2

func ListAllParameters(svc ssmiface.SSMAPI) ([]*ssm.ParameterMetadata, error)

ListAllParameters retrieves all parameters in the AWS SSM.

**Parameters:**

svc: AWS SSM service client.

**Returns:**

([]*ssm.ParameterMetadata): List of all parameters' metadata. error: An error if any issue occurs while fetching the parameters.

func PutParam

func PutParam(svc ssmiface.SSMAPI, name string, value string, paramType string, overwrite bool) error

PutParam creates or updates a parameter in AWS SSM.

**Parameters:**

svc: AWS SSM service client. name: Name of the parameter. value: Value of the parameter. paramType: Type of the parameter. overwrite: Flag to overwrite an existing parameter.

**Returns:**

error: An error if any issue occurs while creating or updating the parameter.

func RunCommand

func RunCommand(svc ssmiface.SSMAPI, instanceID string, command []string) (string, error)

RunCommand executes an input command on an AWS instance via SSM.

**Parameters:**

svc: AWS SSM service client. instanceID: AWS EC2 instance ID where the command should run. command: List of command strings to be run.

**Returns:**

string: Output of the command execution. error: An error if any issue occurs while executing the command.

Types

type Connection

type Connection struct {
	Client  ssmiface.SSMAPI
	Session *session.Session
	Params  Params
}

Connection represents the necessary information to maintain an AWS Systems Manager (SSM) connection.

**Attributes:**

Client: Amazon SSM service client interface. Session: AWS session from which the client is derived. Params: Structure with parameters for the SSM service.

func CreateConnection

func CreateConnection() Connection

CreateConnection establishes a connection with AWS SSM.

**Returns:**

Connection: Struct with a connected SSM client and session.

type Params

type Params struct {
	Name      string
	Value     string
	Type      string
	Overwrite bool
}

Params represents parameter options for SSM.

**Attributes:**

Name: Parameter name. Value: Parameter value. Type: Parameter type. Overwrite: Flag to overwrite an existing parameter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL