ssmrunner

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Provides functions to handle creating and running an SSM document

Provides functions to handle creating and running an SSM document

Index

Constants

View Source
const (
	OutputS3KeyPrefix = `[a-zA-Z0-9]+\/i-[a-zA-Z0-9]+\/[a-zA-Z0-9\.]+\/[a-zA-Z0-9\.]+\/`
	PollInterval      = 30
	S3UrlRegex        = `^https:\/\/s3(\.|\-)?([a-z]+\-[a-z]+\-[0-9])?.amazonaws.com\/([a-zA-Z\-\_0-9]+)\/([a-zA-Z\-\_\/0-9\.\%]+)$`
)
View Source
const (
	StdoutEmptyError = "Stdout is empty"
	StderrEmptyError = "Stderr is empty"
)

Variables

This section is empty.

Functions

func PollExecutedCommands

func PollExecutedCommands(ctx context.Context, awsSess *session.Session, cmds []ExecutedCommand, output chan CommandOutput) error

func StderrEmpty

func StderrEmpty(err error) bool

Given an error message return true if error message relates to Stderr being empty

func StdoutEmpty

func StdoutEmpty(err error) bool

Given an error message return true if error message relates to Stdout being empty

Types

type CommandOutput

type CommandOutput struct {
	Bucket     string   // S3 Bucket the Output is stored in
	Stdout     []string // Full S3 Key for StdOut, empty if none exists
	Stderr     []string // Full S3 Key for Stderr, empty if none exists
	CommandLog string   // Any output provided by SSM
	InstanceID string   // InstanceID the output belongs to
	Status     string   // Status the SSM Run returned with
}

func (*CommandOutput) ReadStderr

func (c *CommandOutput) ReadStderr(session *session.Session) (string, error)

Read a Command Stderr from S3 Bucket and return as a string. Pass AWS Session as input

func (*CommandOutput) ReadStdout

func (c *CommandOutput) ReadStdout(session *session.Session) (string, error)

Read a Command Stdout from S3 Bucket and return as a string. Pass AWS Session as input

type ExecutedCommand

type ExecutedCommand struct {
	CommandID   string
	CommandName string
	CommandOutput
	InstanceID string
}

func (*ExecutedCommand) Cancel

func (e *ExecutedCommand) Cancel()

Cancel the running SSM Command on the instance.

func (*ExecutedCommand) Poll

func (e *ExecutedCommand) Poll(ctx context.Context, awsSess *session.Session, out chan CommandOutput, err chan ExecutionError)

Poll the executedcommand to get the output TODO: Return the output responses in a channel rather than updating the Struct

type ExecutionError

type ExecutionError struct {
	OriginalError error
	InstanceID    string
	CommandID     string
}

func (ExecutionError) Error

func (e ExecutionError) Error() string

type ExecutionErrors

type ExecutionErrors struct {
	Errors []ExecutionError
}

func NewExecutionErrors

func NewExecutionErrors() ExecutionErrors

func (*ExecutionErrors) Add

func (e *ExecutionErrors) Add(err ExecutionError)

func (ExecutionErrors) Error

func (e ExecutionErrors) Error() string

type RunInput

type RunInput struct {
	Instances      []string
	TagKey         string
	TagValue       string
	AutoScaleGroup string
}

type SSMCommand

type SSMCommand struct {
	BucketName string

	Document   string
	Name       string
	Region     string
	Parameters map[string]string

	Session *session.Session
	// contains filtered or unexported fields
}

func (*SSMCommand) Cleanup

func (c *SSMCommand) Cleanup() error

Cleanup environment for SSM Document

func (*SSMCommand) Init

func (c *SSMCommand) Init() error

Initialize the Environment for the SSM document to run

func (*SSMCommand) Run

func (c *SSMCommand) Run(ctx context.Context, input RunInput) ([]ExecutedCommand, error)

Jump to

Keyboard shortcuts

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