aws

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

AWS session facilities. Allow using https proxy for requests

Index

Constants

View Source
const (
	// Waiter type "create".
	StackWaiterTypeCreate = "create"

	// Waiter type "update".
	StackWaiterTypeUpdate = "update"

	// Waiter type "delete".
	StackWaiterTypeDelete = "delete"
)
View Source
const (
	// Environment variable names
	// https proxy. This allows using
	// https proxy other than bash's http proxy
	ENV_HTTPS_PROXY = "CF_HTTPS_PROXY"
)

Variables

View Source
var (
	// TO-DO:
	// Investigate region picking up from env
	AWSSess = session.Must(
		session.NewSessionWithOptions(
			session.Options{
				Config: aws.Config{
					HTTPClient: GetHttpClient(),
				},
				SharedConfigState: session.SharedConfigEnable,
			},
		),
	)
)

Functions

func AWSErrDetail

func AWSErrDetail(err error) (string, string, awserr.Error)

Fetch AWS immediate error code and message

func GetHttpClient

func GetHttpClient() *http.Client

Get http client for aws calls

func GetSessionWithProfile added in v1.1.0

func GetSessionWithProfile(profile string) *session.Session

Return a session by given a profile name

func S3Url

func S3Url(bucket string, parts ...string) (string, error)

Create valid AWS s3 bucket url

Types

type CfS3

type CfS3 struct {
	Client   s3iface.S3API
	Uploader *s3manager.Uploader
}

S3 wrapper

func NewS3

func NewS3(s3api s3iface.S3API) *CfS3

S3 wrapper constructor

func (*CfS3) CreateBucket

func (c *CfS3) CreateBucket(input *s3.CreateBucketInput) (*s3.CreateBucketOutput, error)

Wrapper function for creatinng S3 bucket.

func (*CfS3) IfBucketExist

func (c *CfS3) IfBucketExist(bucket string) (bool, error)

Check if bucket exist

func (*CfS3) Upload

func (c *CfS3) Upload(bucket, keyName string, body []byte, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)

Upload to S3 using s3manager uploader

type Stack

type Stack struct {
	Client cloudformationiface.CloudFormationAPI
}

Stack struct. Provide API testing stub

func NewStack

Stack constructor

func (*Stack) CreateStack

func (s *Stack) CreateStack(name string, params map[string]string, tags map[string]string, tpl []byte, url string) (*cf.CreateStackOutput, error)

Create a stack

func (*Stack) DeleteStack

func (s *Stack) DeleteStack(stackName string, retainResc ...string) (*cf.DeleteStackOutput, error)

Delete a stack

func (*Stack) DescribeStack

func (s *Stack) DescribeStack(stackName string) (*cf.Stack, error)

Describe a stack by a given name

func (*Stack) DescribeStackDriftDetectionStatus

func (s *Stack) DescribeStackDriftDetectionStatus(id string) (*cf.DescribeStackDriftDetectionStatusOutput, error)

Get current drift detection process status

func (*Stack) DescribeStackResourceDrifts

func (s *Stack) DescribeStackResourceDrifts(stackName string, status ...string) ([]*cf.StackResourceDrift, error)

Detailing the stack drift at resources

func (*Stack) DescribeStacks

func (s *Stack) DescribeStacks() ([]*cf.Stack, error)

Describe all stacks

func (*Stack) DetectStackDrift

func (s *Stack) DetectStackDrift(stackName string, resourceIds ...string) (string, error)

Kick off a stack drift detection process. Returns a detection process Id to be used for status query

func (*Stack) Exist

func (s *Stack) Exist(stackName string) bool

If stack exists

func (*Stack) GetStackEvents

func (s *Stack) GetStackEvents(stackName string, timestamp time.Time) ([]*cf.StackEvent, error)

Get stack events. When given zero timestamp, it returns all events for the stack. Event result is ordered in an chronic ascending order.

func (*Stack) GetStackResources added in v1.1.0

func (s *Stack) GetStackResources(stackName string) ([]*cf.StackResource, error)

Get stack resources

func (*Stack) ListStacks

func (s *Stack) ListStacks(format string, statusFilter ...string) ([]*cf.StackSummary, error)

List all stacks. Aggregate all pages and output only one array

func (*Stack) ParamSlice

func (s *Stack) ParamSlice(params map[string]string) []*cf.Parameter

Convert params from map to Parameter slice

func (*Stack) PollStackEvents

func (s *Stack) PollStackEvents(stackName, waiterType string) error

Poll stack events and print them out in console.

func (*Stack) TagSlice

func (s *Stack) TagSlice(tags map[string]string) []*cf.Tag

Convert tags from map to Tag slice

func (*Stack) UpdateStack

func (s *Stack) UpdateStack(name string, params map[string]string, tags map[string]string, tpl []byte, url string) (*cf.UpdateStackOutput, error)

Update stack

func (*Stack) ValidateTemplate

func (s *Stack) ValidateTemplate(tpl []byte, url string) (*cf.ValidateTemplateOutput, error)

Validate cloudformation template

url must be in AWS s3 URL. See https://docs.aws.amazon.com/sdk-for-go/api/service/cloudformation/#ValidateTemplateInput

type Sts added in v1.1.0

type Sts struct {
	Client stsiface.STSAPI
}

Sts wrapper

func NewSts added in v1.1.0

func NewSts(stsapi stsiface.STSAPI) *Sts

Sts wrapper constructor

func (*Sts) GetCallerId added in v1.1.0

func (s *Sts) GetCallerId() (*sts.GetCallerIdentityOutput, error)

Fetach API caller identity

Jump to

Keyboard shortcuts

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