lib

package
v0.0.0-...-7a8751e Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 64 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EC2ArchAmd64 = "x86_64"
	EC2ArchArm64 = "arm64"

	EC2AmiLambda = "lambda"
	EC2AmiAmzn   = "amzn"
	EC2AmiArch   = "arch"
	EC2AmiAlpine = "alpine"

	EC2AmiUbuntuFocal  = "focal"
	EC2AmiUbuntuBionic = "bionic"
	EC2AmiUbuntuXenial = "xenial"
	EC2AmiUbuntuTrusty = "trusty"
)
View Source
const (
	ErrPrefixDidntFindExactlyOne = "didn't find exactly one"
)
View Source
const (
	LambdaWebsocketSuffix = "-websocket"
)

Variables

View Source
var (
	Red     = color(31)
	Green   = color(32)
	Yellow  = color(33)
	Blue    = color(34)
	Magenta = color(35)
	Cyan    = color(36)
	White   = color(37)
)
View Source
var Args = make(map[string]ArgsStruct)
View Source
var Commands = make(map[string]func())
View Source
var Logger = &LoggerStruct{
	Print: func(args ...interface{}) {
		fmt.Fprint(os.Stderr, args...)
	},
	Flush:    func() {},
	disabled: strings.ToLower(os.Getenv("LOGGING") + " ")[:1] == "n",
}
View Source
var PrettyStyle = &pretty.Style{
	Key:    [2]string{"\033[31m", "\033[0m"},
	String: [2]string{"\033[32m", "\033[0m"},
	Number: [2]string{"\033[33m", "\033[0m"},
	True:   [2]string{"\033[34m", "\033[0m"},
	False:  [2]string{"\033[35m", "\033[0m"},
	Null:   [2]string{"\033[36m", "\033[0m"},
	Escape: [2]string{"\033[37m", "\033[0m"},
	Append: func(dst []byte, c byte) []byte {
		hexp := func(p byte) byte {
			switch {
			case p < 10:
				return p + '0'
			default:
				return (p - 10) + 'a'
			}
		}
		if c < ' ' && (c != '\r' && c != '\n' && c != '\t' && c != '\v') {
			dst = append(dst, "\\u00"...)
			dst = append(dst, hexp((c>>4)&0xF))
			return append(dst, hexp((c)&0xF))
		}
		return append(dst, c)
	},
}

Functions

func AcmClient

func AcmClient() *acm.ACM

func AcmClientExplicit

func AcmClientExplicit(accessKeyID, accessKeySecret, region string) *acm.ACM

func AcmListCertificates

func AcmListCertificates(ctx context.Context) ([]*acm.CertificateSummary, error)

func Api

func Api(ctx context.Context, name string) (*apigatewayv2.Api, error)

func ApiClient

func ApiClient() *apigatewayv2.ApiGatewayV2

func ApiClientExplicit

func ApiClientExplicit(accessKeyID, accessKeySecret, region string) *apigatewayv2.ApiGatewayV2

func ApiList

func ApiList(ctx context.Context) ([]*apigatewayv2.Api, error)

func ApiListDomains

func ApiListDomains(ctx context.Context) ([]*apigatewayv2.DomainName, error)

func ApiUrl

func ApiUrl(ctx context.Context, name string) (string, error)

func ApiUrlDomain

func ApiUrlDomain(ctx context.Context, name string) (string, error)

func ApiWebsocketClose

func ApiWebsocketClose(ctx context.Context, domain, connectionID string) error

func ApiWebsocketSend

func ApiWebsocketSend(ctx context.Context, domain, connectionID string, data []byte) error

func ArnToInfraName

func ArnToInfraName(arn string) string

func Assert

func Assert(cond bool, format string, a ...interface{})

func Atoi

func Atoi(a string) int

func Chunk

func Chunk(xs []string, chunkSize int) [][]string

func CloudwatchClient

func CloudwatchClient() *cloudwatch.CloudWatch

func CloudwatchClientExplicit

func CloudwatchClientExplicit(accessKeyID, accessKeySecret, region string) *cloudwatch.CloudWatch

func CloudwatchGetMetricData

func CloudwatchGetMetricData(ctx context.Context, period int, stat string, fromTime, toTime *time.Time, namespace string, metrics []string, dimension string) ([]*cloudwatch.MetricDataResult, error)

func CloudwatchListMetrics

func CloudwatchListMetrics(ctx context.Context, namespace, metric *string) ([]*cloudwatch.Metric, error)

func CodeCommitClient

func CodeCommitClient() *codecommit.CodeCommit

func CodeCommitClientExplicit

func CodeCommitClientExplicit(accessKeyID, accessKeySecret, region string) *codecommit.CodeCommit

func CodeCommitListRepos

func CodeCommitListRepos(ctx context.Context) ([]*codecommit.RepositoryNameIdPair, error)

func Contains

func Contains(parts []string, part string) bool

func CostExplorerClient

func CostExplorerClient() *costexplorer.CostExplorer

func CostExplorerClientExplicit

func CostExplorerClientExplicit(accessKeyID, accessKeySecret, region string) *costexplorer.CostExplorer

func DropLinesWithAny

func DropLinesWithAny(s string, tokens ...string) string

func DynamoDBArn

func DynamoDBArn(ctx context.Context, tableName string) (string, error)

func DynamoDBClient

func DynamoDBClient() *dynamodb.DynamoDB

func DynamoDBClientExplicit

func DynamoDBClientExplicit(accessKeyID, accessKeySecret, region string) *dynamodb.DynamoDB

func DynamoDBDeleteTable

func DynamoDBDeleteTable(ctx context.Context, tableName string, preview bool) error

func DynamoDBEnsure

func DynamoDBEnsure(ctx context.Context, input *dynamodb.CreateTableInput, preview bool) error

func DynamoDBEnsureInput

func DynamoDBEnsureInput(name string, keys []string, attrs []string) (*dynamodb.CreateTableInput, error)

func DynamoDBListTables

func DynamoDBListTables(ctx context.Context) ([]string, error)

func DynamoDBListTags

func DynamoDBListTags(ctx context.Context, tableName string) ([]*dynamodb.Tag, error)

func DynamoDBStreamArn

func DynamoDBStreamArn(ctx context.Context, tableName string) (string, error)

func DynamoDBStreamArnToTableName

func DynamoDBStreamArnToTableName(arn string) string

func DynamoDBWaitForReady

func DynamoDBWaitForReady(ctx context.Context, tableName string) error

func EC2AmiBase

func EC2AmiBase(ctx context.Context, name, arch string) (amiID string, sshUser string, err error)

func EC2AmiUser

func EC2AmiUser(ctx context.Context, amiID string) (string, error)

func EC2Client

func EC2Client() *ec2.EC2

func EC2ClientExplicit

func EC2ClientExplicit(accessKeyID, accessKeySecret, region string) *ec2.EC2

func EC2DescribeInstances

func EC2DescribeInstances(ctx context.Context, instanceIDs []string) ([]*ec2.Instance, error)

func EC2DescribeSpotFleet

func EC2DescribeSpotFleet(ctx context.Context, spotFleetRequestId *string) (*ec2.SpotFleetRequestConfig, error)

func EC2DescribeSpotFleetActiveInstances

func EC2DescribeSpotFleetActiveInstances(ctx context.Context, spotFleetRequestId *string) ([]*ec2.ActiveInstance, error)

func EC2EnsureSg

func EC2EnsureSg(ctx context.Context, input *EC2EnsureSgInput) error

func EC2FinalizeSpotFleet

func EC2FinalizeSpotFleet(ctx context.Context, spotFleetRequestId *string) error

func EC2GetTag

func EC2GetTag(tags []*ec2.Tag, key string, defaultValue string) string

func EC2GoSsh

func EC2GoSsh(ctx context.Context, input *EC2GoSshInput) ([]*ec2GoSshResult, error)

func EC2Kind

func EC2Kind(instance *ec2.Instance) string

func EC2ListInstances

func EC2ListInstances(ctx context.Context, selectors []string, state string) ([]*ec2.Instance, error)

func EC2ListSgs

func EC2ListSgs(ctx context.Context) ([]*ec2.SecurityGroup, error)

func EC2Name

func EC2Name(tags []*ec2.Tag) string

func EC2NameColored

func EC2NameColored(instance *ec2.Instance) string

func EC2NewAmi

func EC2NewAmi(ctx context.Context, input *EC2NewAmiInput) (string, error)

func EC2NewInstances

func EC2NewInstances(ctx context.Context, config *EC2Config) ([]*ec2.Instance, error)

func EC2RequestSpotFleet

func EC2RequestSpotFleet(ctx context.Context, spotStrategy string, config *EC2Config) ([]*ec2.Instance, error)

func EC2Rsync

func EC2Rsync(ctx context.Context, input *EC2RsyncInput) ([]*ec2SshResult, error)

func EC2Scp

func EC2Scp(ctx context.Context, input *EC2ScpInput) ([]*ec2SshResult, error)

func EC2SecurityGroups

func EC2SecurityGroups(sgs []*ec2.GroupIdentifier) string

func EC2SgID

func EC2SgID(ctx context.Context, vpcName, sgName string) (string, error)

func EC2Ssh

func EC2Ssh(ctx context.Context, input *EC2SshInput) ([]*ec2SshResult, error)

func EC2SshLogin

func EC2SshLogin(instance *ec2.Instance, user string) error

func EC2Tags

func EC2Tags(tags []*ec2.Tag) string

func EC2TagsAll

func EC2TagsAll(tags []*ec2.Tag) string

func EC2TeardownSpotFleet

func EC2TeardownSpotFleet(ctx context.Context, spotFleetRequestId *string) error

func EC2WaitGoSsh

func EC2WaitGoSsh(ctx context.Context, input *EC2WaitGoSshInput) ([]string, error)

func EC2WaitSpotFleet

func EC2WaitSpotFleet(ctx context.Context, spotFleetRequestId *string, num int) error

func EC2WaitSsh

func EC2WaitSsh(ctx context.Context, input *EC2WaitSshInput) ([]string, error)

func EC2WaitState

func EC2WaitState(ctx context.Context, instanceIDs []string, state string) error

func EC2ZonesWithInstance

func EC2ZonesWithInstance(ctx context.Context, instanceType string) (zones []string, err error)

func ECSClient

func ECSClient() *ecs.ECS

func ECSClientExplicit

func ECSClientExplicit(accessKeyID, accessKeySecret, region string) *ecs.ECS

func EcrClient

func EcrClient() *ecr.ECR

func EcrClientExplicit

func EcrClientExplicit(accessKeyID, accessKeySecret, region string) *ecr.ECR

func EcrDescribeRepos

func EcrDescribeRepos(ctx context.Context) ([]*ecr.Repository, error)

func EcrEnsure

func EcrEnsure(ctx context.Context, name string, preview bool) error

func EcrUrl

func EcrUrl(ctx context.Context) (string, error)

func EventsClient

func EventsClient() *cloudwatchevents.CloudWatchEvents

func EventsClientExplicit

func EventsClientExplicit(accessKeyID, accessKeySecret, region string) *cloudwatchevents.CloudWatchEvents

func EventsListRuleTargets

func EventsListRuleTargets(ctx context.Context, ruleName string) ([]*cloudwatchevents.Target, error)

func EventsListRules

func EventsListRules(ctx context.Context) ([]*cloudwatchevents.Rule, error)

func Exists

func Exists(path string) bool

func FromUnixMilli

func FromUnixMilli(msec int64) time.Time

func IamClient

func IamClient() *iam.IAM

func IamClientExplicit

func IamClientExplicit(accessKeyID, accessKeySecret, region string) *iam.IAM

func IamDeleteInstanceProfile

func IamDeleteInstanceProfile(ctx context.Context, name string, preview bool) error

func IamDeleteRole

func IamDeleteRole(ctx context.Context, name string, preview bool) error

func IamDeleteRoleAllows

func IamDeleteRoleAllows(ctx context.Context, name string, preview bool) error

func IamDeleteRolePolicies

func IamDeleteRolePolicies(ctx context.Context, name string, preview bool) error

func IamDeleteUser

func IamDeleteUser(ctx context.Context, name string, preview bool) error

func IamEnsureEC2SpotRoles

func IamEnsureEC2SpotRoles(ctx context.Context) error

func IamEnsureInstanceProfile

func IamEnsureInstanceProfile(ctx context.Context, name string, policies, allows []string, preview bool) error

func IamEnsureRole

func IamEnsureRole(ctx context.Context, roleName, principalName string, preview bool) error

func IamEnsureRoleAllows

func IamEnsureRoleAllows(ctx context.Context, roleName string, allows []string, preview bool) error

func IamEnsureRolePolicies

func IamEnsureRolePolicies(ctx context.Context, roleName string, policyNames []string, preview bool) error

func IamEnsureUserAllows

func IamEnsureUserAllows(ctx context.Context, username string, allows []string, preview bool) error

func IamEnsureUserApi

func IamEnsureUserApi(ctx context.Context, username string, preview bool) (*iam.AccessKey, error)

func IamEnsureUserLogin

func IamEnsureUserLogin(ctx context.Context, username, password string, preview bool) error

func IamEnsureUserPolicies

func IamEnsureUserPolicies(ctx context.Context, username string, policyNames []string, preview bool) error

func IamGetSSHPublicKey

func IamGetSSHPublicKey(ctx context.Context, keyID string) (*iam.SSHPublicKey, error)

func IamInstanceProfileArn

func IamInstanceProfileArn(ctx context.Context, profileName string) (string, error)

func IamListPolicies

func IamListPolicies(ctx context.Context) ([]*iam.Policy, error)

func IamListRolePolicies

func IamListRolePolicies(ctx context.Context, roleName string) ([]*iam.AttachedPolicy, error)

func IamListSSHPublicKeys

func IamListSSHPublicKeys(ctx context.Context) ([]*iam.SSHPublicKeyMetadata, error)

func IamListUserPolicies

func IamListUserPolicies(ctx context.Context, username string) ([]*iam.Policy, error)

func IamPolicyArn

func IamPolicyArn(ctx context.Context, policyName string) (string, error)

func IamResetUserLoginTempPassword

func IamResetUserLoginTempPassword(ctx context.Context, username, password string) error

func IamRoleArn

func IamRoleArn(ctx context.Context, principalName, roleName string) (string, error)

func InfraEnsureDynamoDB

func InfraEnsureDynamoDB(ctx context.Context, dbs []string, preview bool) error

func InfraEnsureS3

func InfraEnsureS3(ctx context.Context, buckets []string, preview bool) error

func InfraEnsureSqs

func InfraEnsureSqs(ctx context.Context, queues []string, preview bool) error

func InfraListApi

func InfraListApi(ctx context.Context, triggersChan chan<- InfraLambdaTrigger) (map[string]InfraApi, error)

func InfraListCloudwatch

func InfraListCloudwatch(ctx context.Context, triggersChan chan<- InfraLambdaTrigger) (map[string]string, error)

func InfraListDynamoDB

func InfraListDynamoDB(ctx context.Context) (map[string]InfraDynamoDB, error)

func InfraListEC2

func InfraListEC2(ctx context.Context) (map[string]InfraEC2, error)

func InfraListLambda

func InfraListLambda(ctx context.Context, triggersChan <-chan InfraLambdaTrigger, filter string) (map[string]InfraLambda, error)

func InfraListS3

func InfraListS3(ctx context.Context, triggersChan chan<- InfraLambdaTrigger) (map[string]InfraS3, error)

func InfraListSQS

func InfraListSQS(ctx context.Context) (map[string]InfraSQS, error)

func InfraListVpc

func InfraListVpc(ctx context.Context) (map[string]InfraVpc, error)

func IsDigit

func IsDigit(s string) bool

func Json

func Json(i interface{}) string

func LambdaApiUri

func LambdaApiUri(ctx context.Context, lambdaName string) (string, error)

func LambdaApiUriToLambdaName

func LambdaApiUriToLambdaName(apiUri string) string

func LambdaArn

func LambdaArn(ctx context.Context, name string) (string, error)

func LambdaArnToLambdaName

func LambdaArnToLambdaName(arn string) string

func LambdaClient

func LambdaClient() *lambda.Lambda

func LambdaClientExplicit

func LambdaClientExplicit(accessKeyID, accessKeySecret, region string) *lambda.Lambda

func LambdaDeleteFunction

func LambdaDeleteFunction(ctx context.Context, name string, preview bool) error

func LambdaEnsure

func LambdaEnsure(ctx context.Context, pth string, quick, preview bool) error

func LambdaEnsureTriggerApi

func LambdaEnsureTriggerApi(ctx context.Context, name string, meta *LambdaMetadata, preview bool) ([]string, error)

func LambdaEnsureTriggerCloudwatch

func LambdaEnsureTriggerCloudwatch(ctx context.Context, name, arnLambda string, meta *LambdaMetadata, preview bool) ([]string, error)

func LambdaEnsureTriggerDynamoDB

func LambdaEnsureTriggerDynamoDB(ctx context.Context, name, arnLambda string, meta *LambdaMetadata, preview bool) error

func LambdaEnsureTriggerEcr

func LambdaEnsureTriggerEcr(ctx context.Context, name, arnLambda string, meta *LambdaMetadata, preview bool) ([]string, error)

func LambdaEnsureTriggerS3

func LambdaEnsureTriggerS3(ctx context.Context, name, arnLambda string, meta *LambdaMetadata, preview bool) ([]string, error)

func LambdaEnsureTriggerSQS

func LambdaEnsureTriggerSQS(ctx context.Context, name, arnLambda string, meta *LambdaMetadata, preview bool) error

func LambdaIncludeInZip

func LambdaIncludeInZip(pth string, includes []string, preview bool) error

func LambdaListFunctions

func LambdaListFunctions(ctx context.Context) ([]*lambda.FunctionConfiguration, error)

func LambdaName

func LambdaName(pth string) (string, error)

func LambdaSetConcurrency

func LambdaSetConcurrency(ctx context.Context, name string, concurrency int, preview bool) error

func LambdaUpdateFunctionZip

func LambdaUpdateFunctionZip(ctx context.Context, name, pth string, preview bool) error

func LambdaZipBytes

func LambdaZipBytes(path string) ([]byte, error)

func LambdaZipFile

func LambdaZipFile(path string) (string, error)

func Last

func Last(parts []string) string

func LogsClient

func LogsClient() *cloudwatchlogs.CloudWatchLogs

func LogsClientExplicit

func LogsClientExplicit(accessKeyID, accessKeySecret, region string) *cloudwatchlogs.CloudWatchLogs

func LogsDeleteGroup

func LogsDeleteGroup(ctx context.Context, name string, preview bool) error

func LogsEnsureGroup

func LogsEnsureGroup(ctx context.Context, name string, ttlDays int, preview bool) error

func LogsListLogGroups

func LogsListLogGroups(ctx context.Context) ([]*cloudwatchlogs.LogGroup, error)

func LogsMostRecentStreams

func LogsMostRecentStreams(ctx context.Context, name string) ([]*cloudwatchlogs.LogStream, error)

func LogsStreams

func LogsStreams(ctx context.Context, name string) ([]*cloudwatchlogs.LogStream, error)

func LogsTail

func LogsTail(ctx context.Context, name string, minAge time.Time, callback func(timestamp time.Time, line string)) error

func Max

func Max(i, j int) int

func NowUnixMilli

func NowUnixMilli() int64

func OrganizationsClient

func OrganizationsClient() *organizations.Organizations

func OrganizationsClientExplicit

func OrganizationsClientExplicit(accessKeyID, accessKeySecret, region string) *organizations.Organizations

func OrganizationsEnsure

func OrganizationsEnsure(ctx context.Context, name, email string, preview bool) (string, error)

func Panic1

func Panic1(err error)

func Panic2

func Panic2(x interface{}, e error) interface{}

func Pformat

func Pformat(i interface{}) string

func PformatAlways

func PformatAlways(i interface{}) string

func PreviewString

func PreviewString(preview bool) string

func PromptProceed

func PromptProceed(prompt string) error

func Region

func Region() string

func Retry

func Retry(ctx context.Context, fn func() error) error

func RetryAttempts

func RetryAttempts(ctx context.Context, attempts int, fn func() error) error

6 attempts = 5 seconds total delay 7 attempts = 10 seconds total delay 8 attempts = 20 seconds total delay 9 attempts = 40 seconds total delay 10 attempts = 80 seconds total delay 11 attempts = 160 seconds total delay 12 attempts = 320 seconds total delay

func Route53Client

func Route53Client() *route53.Route53

func Route53ClientExplicit

func Route53ClientExplicit(accessKeyID, accessKeySecret, region string) *route53.Route53

func Route53DeleteRecord

func Route53DeleteRecord(ctx context.Context, input *route53EnsureRecordInput, preview bool) error

func Route53DeleteZone

func Route53DeleteZone(ctx context.Context, name string, preview bool) error

func Route53EnsureRecord

func Route53EnsureRecord(ctx context.Context, input *route53EnsureRecordInput, preview bool) error

func Route53EnsureRecordInput

func Route53EnsureRecordInput(zoneName, recordName string, attrs []string) (*route53EnsureRecordInput, error)

func Route53EnsureZone

func Route53EnsureZone(ctx context.Context, name string, preview bool) error

func Route53ListRecords

func Route53ListRecords(ctx context.Context, zoneId string) ([]*route53.ResourceRecordSet, error)

func Route53ListZones

func Route53ListZones(ctx context.Context) ([]*route53.HostedZone, error)

func Route53ZoneID

func Route53ZoneID(ctx context.Context, name string) (string, error)

func S3BucketRegion

func S3BucketRegion(bucket string) (string, error)

func S3Client

func S3Client() *s3.S3

func S3ClientBucketRegion

func S3ClientBucketRegion(bucket string) (*s3.S3, error)

func S3ClientBucketRegionMust

func S3ClientBucketRegionMust(bucket string) *s3.S3

func S3ClientExplicit

func S3ClientExplicit(accessKeyID, accessKeySecret, region string) *s3.S3

func S3ClientRegion

func S3ClientRegion(region string) (*s3.S3, error)

func S3ClientRegionMust

func S3ClientRegionMust(region string) *s3.S3

func S3DeleteBucket

func S3DeleteBucket(ctx context.Context, bucket string, preview bool) error

func S3Ensure

func S3Ensure(ctx context.Context, input *s3EnsureInput, preview bool) error

func S3EnsureInput

func S3EnsureInput(name string, attrs []string) (*s3EnsureInput, error)

func S3PresignGet

func S3PresignGet(bucket, key, byterange string, expire time.Duration) string

func S3PresignPut

func S3PresignPut(bucket, key string, expire time.Duration) string

func SNSArn

func SNSArn(ctx context.Context, name string) (string, error)

func SNSClient

func SNSClient() *sns.SNS

func SNSClientExplicit

func SNSClientExplicit(accessKeyID, accessKeySecret, region string) *sns.SNS

func SNSEnsure

func SNSEnsure(ctx context.Context, name string, preview bool) error

func SNSListSubscriptions

func SNSListSubscriptions(ctx context.Context, topicArn string) ([]*sns.Subscription, error)

func SQSArn

func SQSArn(ctx context.Context, name string) (string, error)

func SQSArnToName

func SQSArnToName(arn string) string

func SQSClient

func SQSClient() *sqs.SQS

func SQSClientExplicit

func SQSClientExplicit(accessKeyID, accessKeySecret, region string) *sqs.SQS

func SQSDeleteQueue

func SQSDeleteQueue(ctx context.Context, name string, preview bool) error

func SQSEnsure

func SQSEnsure(ctx context.Context, input *sqsEnsureInput, preview bool) error

func SQSEnsureInput

func SQSEnsureInput(name string, attrs []string) (*sqsEnsureInput, error)

func SQSListQueueUrls

func SQSListQueueUrls(ctx context.Context) ([]string, error)

func SQSListQueues

func SQSListQueues(ctx context.Context) ([]string, error)

func SQSQueueUrl

func SQSQueueUrl(ctx context.Context, queueName string) (string, error)

func SQSUrlToName

func SQSUrlToName(url string) string

func STSClient

func STSClient() *sts.STS

func STSClientExplicit

func STSClientExplicit(accessKeyID, accessKeySecret, region string) *sts.STS

func Session

func Session() *session.Session

func SessionExplicit

func SessionExplicit(accessKeyID, accessKeySecret, region string) *session.Session

func SessionRegion

func SessionRegion(region string) (*session.Session, error)

func SignalHandler

func SignalHandler(cancel func())

func SplitOnce

func SplitOnce(s string, sep string) (head, tail string, err error)

func SplitTwice

func SplitTwice(s string, sep string) (head, mid, tail string, err error)

func SshKeygenEd25519

func SshKeygenEd25519() (string, string, error)

func SshKeygenRsa

func SshKeygenRsa() (string, string, error)

func StringOr

func StringOr(s *string, d string) string

func StringSlice

func StringSlice(xs []*string) []string

func StsAccount

func StsAccount(ctx context.Context) (string, error)

func StsArn

func StsArn(ctx context.Context) (string, error)

func StsUser

func StsUser(ctx context.Context) (string, error)

func ToUnixMilli

func ToUnixMilli(t time.Time) int64

func VpcEnsure

func VpcEnsure(ctx context.Context, name string, xx int) (string, error)

func VpcID

func VpcID(ctx context.Context, name string) (string, error)

func VpcList

func VpcList(ctx context.Context) ([]*ec2.Vpc, error)

func VpcRm

func VpcRm(ctx context.Context, name string) error

func VpcSubnets

func VpcSubnets(ctx context.Context, vpcID string) ([]*ec2.Subnet, error)

func Zones

func Zones(ctx context.Context) ([]*ec2.AvailabilityZone, error)

Types

type ArgsStruct

type ArgsStruct interface {
	Description() string
}

type EC2Config

type EC2Config struct {
	NumInstances   int
	Name           string
	SgID           string
	AmiID          string
	UserName       string // instance ssh username
	Key            string
	InstanceType   string
	SubnetIds      []string
	Gigs           int
	Throughput     int
	Iops           int
	Init           string
	Tags           []EC2Tag
	Profile        string
	SecondsTimeout int
}

type EC2EnsureSgInput

type EC2EnsureSgInput struct {
	VpcName string
	SgName  string
	Rules   []EC2SgRule
	Preview bool
}

type EC2GoSshInput

type EC2GoSshInput struct {
	NoTTY          bool
	TargetAddrs    []string
	Cmd            string
	TimeoutSeconds int
	MaxConcurrency int
	User           string
	Stdout         io.Writer
	Stderr         io.Writer
	Stdin          string
	RsaPrivKey     string
	Ed25519PrivKey string
}

type EC2NewAmiInput

type EC2NewAmiInput struct {
	Selectors []string
	Wait      bool
}

type EC2RsyncInput

type EC2RsyncInput struct {
	Source           string
	Destination      string
	Instances        []*ec2.Instance
	TimeoutSeconds   int
	MaxConcurrency   int
	User             string
	PrivateIP        bool
	Key              string
	PrintLock        sync.RWMutex
	AccumulateResult bool
}

type EC2ScpInput

type EC2ScpInput struct {
	Source           string
	Destination      string
	Instances        []*ec2.Instance
	TimeoutSeconds   int
	MaxConcurrency   int
	User             string
	PrivateIP        bool
	Key              string
	PrintLock        sync.RWMutex
	AccumulateResult bool
}

type EC2SgRule

type EC2SgRule struct {
	Proto  string `json:"proto"`
	Port   int    `json:"port"`
	Source string `json:"source"`
}

func EC2SgRules

func EC2SgRules(p *ec2.IpPermission) ([]EC2SgRule, error)

func (EC2SgRule) String

func (r EC2SgRule) String() string

type EC2SshInput

type EC2SshInput struct {
	Instances        []*ec2.Instance
	Cmd              string
	TimeoutSeconds   int
	MaxConcurrency   int
	User             string
	Stdin            string
	PrivateIP        bool
	Key              string
	AccumulateResult bool
	PrintLock        sync.RWMutex
	NoPrint          bool
}

type EC2Tag

type EC2Tag struct {
	Name  string
	Value string
}

type EC2WaitGoSshInput

type EC2WaitGoSshInput struct {
	Selectors      []string
	MaxWaitSeconds int
	User           string
	MaxConcurrency int
	RsaPrivKey     string
	Ed25519PrivKey string
}

type EC2WaitSshInput

type EC2WaitSshInput struct {
	Selectors      []string
	MaxWaitSeconds int
	PrivateIP      bool
	User           string
	Key            string
	MaxConcurrency int
}

type IamAllow

type IamAllow struct {
	Action   string
	Resource string
}

func IamListRoleAllows

func IamListRoleAllows(ctx context.Context, roleName string) ([]*IamAllow, error)

func IamListUserAllows

func IamListUserAllows(ctx context.Context, username string) ([]*IamAllow, error)

func (*IamAllow) String

func (a *IamAllow) String() string

type IamInstanceProfile

type IamInstanceProfile struct {
	Arn                 *string    `json:",omitempty"`
	CreateDate          *time.Time `json:",omitempty"`
	InstanceProfileId   *string    `json:",omitempty"`
	InstanceProfileName *string    `json:",omitempty"`
	Path                *string    `json:",omitempty"`
	Roles               []*IamRole `json:",omitempty"`
	Tags                []*iam.Tag `json:",omitempty"`
}

func IamListInstanceProfiles

func IamListInstanceProfiles(ctx context.Context, pathPrefix *string) ([]*IamInstanceProfile, error)

func (*IamInstanceProfile) FromProfile

func (p *IamInstanceProfile) FromProfile(ctx context.Context, profile *iam.InstanceProfile) error

type IamPolicy

type IamPolicy struct {
	Arn                           *string            `json:",omitempty"`
	AttachmentCount               *int64             `json:",omitempty"`
	CreateDate                    *time.Time         `json:",omitempty"`
	DefaultVersionId              *string            `json:",omitempty"`
	Description                   *string            `json:",omitempty"`
	IsAttachable                  *bool              `json:",omitempty"`
	Path                          *string            `json:",omitempty"`
	PermissionsBoundaryUsageCount *int64             `json:",omitempty"`
	PolicyId                      *string            `json:",omitempty"`
	PolicyName                    *string            `json:",omitempty"`
	Tags                          []*iam.Tag         `json:",omitempty"`
	UpdateDate                    *time.Time         `json:",omitempty"`
	PolicyDocument                *IamPolicyDocument `json:",omitempty"`
}

func (*IamPolicy) FromPolicy

func (p *IamPolicy) FromPolicy(ctx context.Context, policy *iam.Policy, resolveDocument bool) error

type IamPolicyDocument

type IamPolicyDocument struct {
	Version   string              `json:",omitempty"`
	Id        string              `json:",omitempty"`
	Statement []IamStatementEntry `json:",omitempty"`
}

type IamPolicyDocumentCondition

type IamPolicyDocumentCondition struct {
	Version   string
	Id        string
	Statement []IamStatementEntryCondition
}

type IamRole

type IamRole struct {
	Arn                      *string                          `json:",omitempty"`
	AssumeRolePolicyDocument *IamPolicyDocument               `json:",omitempty"`
	CreateDate               *time.Time                       `json:",omitempty"`
	Description              *string                          `json:",omitempty"`
	MaxSessionDuration       *int64                           `json:",omitempty"`
	Path                     *string                          `json:",omitempty"`
	PermissionsBoundary      *iam.AttachedPermissionsBoundary `json:",omitempty"`
	RoleId                   *string                          `json:",omitempty"`
	RoleLastUsed             *iam.RoleLastUsed                `json:",omitempty"`
	RoleName                 *string                          `json:",omitempty"`
	Tags                     []*iam.Tag                       `json:",omitempty"`
	Allows                   []string                         `json:",omitempty"`
	Policies                 []string                         `json:",omitempty"`
	// contains filtered or unexported fields
}

func IamListRoles

func IamListRoles(ctx context.Context, pathPrefix *string) ([]*IamRole, error)

func (*IamRole) FromRole

func (r *IamRole) FromRole(ctx context.Context, role *iam.Role) error

type IamStatementEntry

type IamStatementEntry struct {
	Sid       string      `json:",omitempty"`
	Effect    string      `json:",omitempty"`
	Resource  interface{} `json:",omitempty"`
	Principal interface{} `json:",omitempty"`
	Action    interface{} `json:",omitempty"`
}

type IamStatementEntryCondition

type IamStatementEntryCondition struct {
	Sid       string      `json:",omitempty"`
	Effect    string      `json:",omitempty"`
	Resource  interface{} `json:",omitempty"`
	Principal interface{} `json:",omitempty"`
	Action    interface{} `json:",omitempty"`
	Condition interface{} `json:",omitempty"`
}

type IamUser

type IamUser struct {
	Arn                 *string                          `json:",omitempty"`
	CreateDate          *time.Time                       `json:",omitempty"`
	PasswordLastUsed    *time.Time                       `json:",omitempty"`
	Path                *string                          `json:",omitempty"`
	PermissionsBoundary *iam.AttachedPermissionsBoundary `json:",omitempty"`
	Tags                []*iam.Tag                       `json:",omitempty"`
	UserId              *string                          `json:",omitempty"`
	UserName            *string                          `json:",omitempty"`
	Allows              []string                         `json:",omitempty"`
	Policies            []string                         `json:",omitempty"`
}

func IamListUsers

func IamListUsers(ctx context.Context) ([]*IamUser, error)

func (*IamUser) FromUser

func (u *IamUser) FromUser(ctx context.Context, user *iam.User) error

type Infra

type Infra struct {
	Account  string                   `json:"account"`
	Region   string                   `json:"region"`
	Api      map[string]InfraApi      `json:"api,omitempty"`
	DynamoDB map[string]InfraDynamoDB `json:"dynamodb,omitempty"`
	Vpc      map[string]InfraVpc      `json:"vpc,omitempty"`
	EC2      map[string]InfraEC2      `json:"ec2,omitempty"`
	Lambda   map[string]InfraLambda   `json:"lambda,omitempty"`
	SQS      map[string]InfraSQS      `json:"sqs,omitempty"`
	S3       map[string]InfraS3       `json:"s3,omitempty"`
}

func InfraList

func InfraList(ctx context.Context, filter string) (*Infra, error)

type InfraApi

type InfraApi struct {
	Dns    string `json:"dns,omitempty"`
	Domain string `json:"domain,omitempty"`
}

type InfraDynamoDB

type InfraDynamoDB struct {
	Keys  []string `json:"keys,omitempty"`
	Attrs []string `json:"attrs,omitempty"`
}

type InfraEC2

type InfraEC2 struct {
	Attrs []string `json:"attrs,omitempty"`
	Count int      `json:"count,omitempty"`
	// contains filtered or unexported fields
}

type InfraLambda

type InfraLambda struct {
	Policies []string `json:"policies,omitempty"`
	Allows   []string `json:"allows,omitempty"`
	Triggers []string `json:"triggers,omitempty"`
	Attrs    []string `json:"attrs,omitempty"`
}

type InfraLambdaTrigger

type InfraLambdaTrigger struct {
	LambdaName   string
	TriggerType  string
	TriggerAttrs []string
}

type InfraS3

type InfraS3 struct {
	Attrs []string `json:"attrs,omitempty"`
}

type InfraSQS

type InfraSQS struct {
	Attrs []string `json:"attrs,omitempty"`
}

type InfraVpc

type InfraVpc struct {
	Sgs map[string][]string `json:"sgs"`
	// contains filtered or unexported fields
}

type Kind

type Kind string
const (
	KindTags             Kind = "tags"
	KindDnsName          Kind = "dns-name"
	KindVpcId            Kind = "vpc-id"
	KindSubnetID         Kind = "subnet-id"
	KindSecurityGroupID  Kind = "instance.group-id"
	KindPrivateDnsName   Kind = "private-dns-name"
	KindIPAddress        Kind = "ip-address"
	KindPrivateIPAddress Kind = "private-ip-address"
	KindInstanceID       Kind = "instance-id"
)

type LambdaCreateZipFn

type LambdaCreateZipFn func(pth string, requires []string, preview bool) error

type LambdaMetadata

type LambdaMetadata struct {
	S3       []string `json:"s3,omitempty"`
	DynamoDB []string `json:"dynamodb,omitempty"`
	Sqs      []string `json:"sqs,omitempty"`
	Policy   []string `json:"policy,omitempty"`
	Allow    []string `json:"allow,omitempty"`
	Include  []string `json:"include,omitempty"`
	Trigger  []string `json:"trigger,omitempty"`
	Require  []string `json:"require,omitempty"`
	Attr     []string `json:"attr,omitempty"`
	Env      []string `json:"env,omitempty"`
}

func LambdaGetMetadata

func LambdaGetMetadata(lines []string) (*LambdaMetadata, error)

func LambdaParseFile

func LambdaParseFile(path string) (*LambdaMetadata, error)

type LambdaUpdateZipFn

type LambdaUpdateZipFn func(pth string, preview bool) error

type LoggerStruct

type LoggerStruct struct {
	Print func(args ...interface{})
	Flush func()
	// contains filtered or unexported fields
}

func (*LoggerStruct) Fatal

func (l *LoggerStruct) Fatal(v ...interface{})

func (*LoggerStruct) Fatalf

func (l *LoggerStruct) Fatalf(format string, v ...interface{})

func (*LoggerStruct) Printf

func (l *LoggerStruct) Printf(format string, v ...interface{})

func (*LoggerStruct) Println

func (l *LoggerStruct) Println(v ...interface{})

type S3BucketDescription

type S3BucketDescription struct {
	Metrics       *s3.MetricsConfiguration
	Versioning    bool
	Acl           *s3.GetBucketAclOutput
	Cors          []*s3.CORSRule
	Encryption    *s3.ServerSideEncryptionConfiguration
	Lifecycle     []*s3.LifecycleRule
	Region        string
	Logging       *s3.LoggingEnabled
	Notifications *s3.NotificationConfiguration
	Policy        *IamPolicyDocument
	Replication   *s3.ReplicationConfiguration
}

func S3GetBucketDescription

func S3GetBucketDescription(ctx context.Context, bucket string) (*S3BucketDescription, error)

type SQSNumMessageOutput

type SQSNumMessageOutput struct {
	Messages           int
	MessagesNotVisible int
	MessagesDelayed    int
}

func SQSNumMessages

func SQSNumMessages(ctx context.Context, queueUrl string) (*SQSNumMessageOutput, error)

Jump to

Keyboard shortcuts

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