lib

package
v0.0.0-...-7340229 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 68 Imported by: 10

Documentation

Index

Constants

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

	EC2AmiAmzn2023 = "amzn2023"
	EC2AmiAmzn2    = "amzn2"

	EC2AmiUbuntuJammy  = "jammy"
	EC2AmiUbuntuFocal  = "focal"
	EC2AmiUbuntuBionic = "bionic"
	EC2AmiUbuntuXenial = "xenial"
	EC2AmiUbuntuTrusty = "trusty"

	EC2AmiDebianBookworm = "bookworm"
	EC2AmiDebianBullseye = "bullseye"
	EC2AmiDebianBuster   = "buster"
	EC2AmiDebianStretch  = "stretch"

	EC2AmiAlpine3160 = "alpine-3.16.0"
	EC2AmiAlpine3182 = "alpine-3.18.2"
	EC2AmiAlpine3183 = "alpine-3.18.3"
	EC2AmiAlpine3184 = "alpine-3.18.4"
)
View Source
const (
	EC2SpotFleetTaggingRole = "aws-ec2-spot-fleet-tagging-role"
)
View Source
const (
	ErrApiNotFound = "ErrApiNotFound"
)
View Source
const (
	ErrPrefixDidntFindExactlyOne = "didn't find exactly one"
)
View Source
const (
	LambdaWebsocketSuffix = lambdaEventRuleNameSeparator + "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",
}

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 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 Atoi

func Atoi(a string) int

func Caller

func Caller(n int) string

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 CloudwatchEnsureAlarm

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

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(infraSetName, tableName string, keys []string, attrs []string) (*dynamodb.CreateTableInput, error)

func DynamoDBItemDeleteAll

func DynamoDBItemDeleteAll(ctx context.Context, tableName string, keyNames []string) 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 DynamoDBWaitForGone

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

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 EC2DeleteKeypair

func EC2DeleteKeypair(ctx context.Context, keypairName string, preview bool) error

func EC2DeleteSg

func EC2DeleteSg(ctx context.Context, vpcName, sgName string, preview bool) error

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 EC2EnsureKeypair

func EC2EnsureKeypair(ctx context.Context, infraSetName, keyName, pubkeyContent string, preview bool) error

func EC2EnsureSg

func EC2EnsureSg(ctx context.Context, input *ec2EnsureSgInput, preview bool) error

func EC2EnsureSgInput

func EC2EnsureSgInput(infraSetName, vpcName, sgName string, rules []string) (*ec2EnsureSgInput, 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, key 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 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 EventsListBuses

func EventsListBuses(ctx context.Context) ([]*cloudwatchevents.EventBus, error)

func EventsListRuleTargets

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

func EventsListRules

func EventsListRules(ctx context.Context, busName *string) ([]*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, profileName string, preview bool) error

func IamDeleteRole

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

func IamDeleteUser

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

func IamEnsureEC2SpotRoles

func IamEnsureEC2SpotRoles(ctx context.Context, preview bool) error

func IamEnsureInstanceProfile

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

func IamEnsureRole

func IamEnsureRole(ctx context.Context, infrasetName, 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 InfraDelete

func InfraDelete(ctx context.Context, infraSet *InfraSet, preview bool) error

func InfraEnsure

func InfraEnsure(ctx context.Context, infraSet *InfraSet, quick string, preview, showEnvVarValues bool) error

func InfraEnsureDynamoDB

func InfraEnsureDynamoDB(ctx context.Context, infraSet *InfraSet, preview bool) error

func InfraEnsureInstanceProfile

func InfraEnsureInstanceProfile(ctx context.Context, infraSet *InfraSet, preview bool) error

func InfraEnsureKeypair

func InfraEnsureKeypair(ctx context.Context, infraSet *InfraSet, preview bool) error

func InfraEnsureLambda

func InfraEnsureLambda(ctx context.Context, infraSet *InfraSet, quick string, preview, showEnvVarValues bool) error

func InfraEnsureS3

func InfraEnsureS3(ctx context.Context, infraSet *InfraSet, preview bool) error

func InfraEnsureSQS

func InfraEnsureSQS(ctx context.Context, infraSet *InfraSet, preview bool) error

func InfraEnsureVpc

func InfraEnsureVpc(ctx context.Context, infraSet *InfraSet, preview bool) error

func InfraListApi

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

func InfraListDynamoDB

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

func InfraListEC2

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

func InfraListEvent

func InfraListEvent(ctx context.Context, triggersChan chan<- *InfraTrigger) (map[string]*InfraEvent, error)

func InfraListInstanceProfile

func InfraListInstanceProfile(ctx context.Context) (map[string]*InfraInstanceProfile, error)

func InfraListKeypair

func InfraListKeypair(ctx context.Context) (map[string]*InfraKeypair, error)

func InfraListLambda

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

func InfraListRole

func InfraListRole(ctx context.Context) (map[string]*InfraRole, error)

func InfraListS3

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

func InfraListSQS

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

func InfraListUser

func InfraListUser(ctx context.Context) (map[string]*InfraUser, 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 LambdaDelete

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

func LambdaDeleteFunction

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

func LambdaEnsureTriggerApi

func LambdaEnsureTriggerApi(ctx context.Context, infraLambda *InfraLambda, preview bool) ([]string, error)

func LambdaEnsureTriggerDynamoDB

func LambdaEnsureTriggerDynamoDB(ctx context.Context, infraLambda *InfraLambda, preview bool) error

func LambdaEnsureTriggerEcr

func LambdaEnsureTriggerEcr(ctx context.Context, infraLambda *InfraLambda, preview bool) ([]string, error)

func LambdaEnsureTriggerS3

func LambdaEnsureTriggerS3(ctx context.Context, infraLambda *InfraLambda, preview bool) ([]string, error)

func LambdaEnsureTriggerSQS

func LambdaEnsureTriggerSQS(ctx context.Context, infraLambda *InfraLambda, preview bool) error

func LambdaEnsureTriggerSchedule

func LambdaEnsureTriggerSchedule(ctx context.Context, infraLambda *InfraLambda, preview bool) ([]string, error)

func LambdaIncludeInZip

func LambdaIncludeInZip(infraLambda *InfraLambda) error

func LambdaListFunctions

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

func LambdaSetConcurrency

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

func LambdaUpdateFunctionCode

func LambdaUpdateFunctionCode(ctx context.Context, infraLambda *InfraLambda, preview bool) error

func LambdaZipBytes

func LambdaZipBytes(infraLambda *InfraLambda) ([]byte, error)

func LambdaZipFile

func LambdaZipFile(name string) string

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, infrasetName, logGroupName 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 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(infraSetName, bucketName 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(infraSetName, queueName 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, name 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 SplitWhiteSpace

func SplitWhiteSpace(s string) []string

func SplitWhiteSpaceN

func SplitWhiteSpaceN(s string, n int) []string

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, infraSetName, vpcName string, preview bool) (string, error)

func VpcID

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

func VpcList

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

func VpcListSubnets

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

func VpcRm

func VpcRm(ctx context.Context, name string, preview bool) 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 CloudwatchAlarm

type CloudwatchAlarm struct {
	ActionsEnabled                     *bool                         `json:",omitempty"`
	AlarmActions                       []*string                     `json:",omitempty"`
	AlarmConfigurationUpdatedTimestamp *time.Time                    `json:",omitempty"`
	AlarmName                          *string                       `json:",omitempty"`
	ComparisonOperator                 *string                       `json:",omitempty"`
	DatapointsToAlarm                  *int64                        `json:",omitempty"`
	Dimensions                         []*cloudwatch.Dimension       `json:",omitempty"`
	EvaluateLowSampleCountPercentile   *string                       `json:",omitempty"`
	EvaluationPeriods                  *int64                        `json:",omitempty"`
	ExtendedStatistic                  *string                       `json:",omitempty"`
	InsufficientDataActions            []*string                     `json:",omitempty"`
	MetricName                         *string                       `json:",omitempty"`
	Metrics                            []*cloudwatch.MetricDataQuery `json:",omitempty"`
	Namespace                          *string                       `json:",omitempty"`
	OKActions                          []*string                     `json:",omitempty"`
	Period                             *int64                        `json:",omitempty"`
	StateValue                         *string                       `json:",omitempty"`
	Statistic                          *string                       `json:",omitempty"`
	Threshold                          *float64                      `json:",omitempty"`
	ThresholdMetricId                  *string                       `json:",omitempty"`
	TreatMissingData                   *string                       `json:",omitempty"`
	Unit                               *string                       `json:",omitempty"`
	// contains filtered or unexported fields
}

func CloudwatchListAlarms

func CloudwatchListAlarms(ctx context.Context) ([]*CloudwatchAlarm, error)

func (*CloudwatchAlarm) FromAlarm

func (a *CloudwatchAlarm) FromAlarm(alarm *cloudwatch.MetricAlarm)

type Debug

type Debug struct {
	// contains filtered or unexported fields
}

func (*Debug) Log

func (d *Debug) Log()

func (*Debug) Println

func (d *Debug) Println(v ...interface{})

type EC2Config

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

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
	IPNotID          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
	Stdout         io.Writer
	Stderr         io.Writer
}

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 {
	Name  *string    `json:",omitempty" yaml:",omitempty"`
	Roles []*IamRole `json:",omitempty" yaml:",omitempty"`
	// contains filtered or unexported fields
}

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" yaml:",omitempty"`
	Id        string              `json:",omitempty" yaml:",omitempty"`
	Statement []IamStatementEntry `json:",omitempty" yaml:",omitempty"`
}

type IamPolicyDocumentCondition

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

type IamRole

type IamRole struct {
	AssumeRolePolicyDocument *IamPolicyDocument               `json:",omitempty" yaml:",omitempty"`
	PermissionsBoundary      *iam.AttachedPermissionsBoundary `json:",omitempty" yaml:",omitempty"`
	RoleLastUsed             *iam.RoleLastUsed                `json:",omitempty" yaml:",omitempty"`
	RoleName                 *string                          `json:",omitempty" yaml:",omitempty"`
	Tags                     []*iam.Tag                       `json:",omitempty" yaml:",omitempty"`
	Allow                    []string                         `json:",omitempty" yaml:",omitempty"`
	Policy                   []string                         `json:",omitempty" yaml:",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" yaml:",omitempty"`
	Effect    string      `json:",omitempty" yaml:",omitempty"`
	Resource  interface{} `json:",omitempty" yaml:",omitempty"`
	Principal interface{} `json:",omitempty" yaml:",omitempty"`
	Action    interface{} `json:",omitempty" yaml:",omitempty"`
}

type IamStatementEntryCondition

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

type IamUser

type IamUser struct {
	UserName *string  `json:",omitempty" yaml:",omitempty"`
	Allows   []string `json:",omitempty" yaml:",omitempty"`
	Policies []string `json:",omitempty" yaml:",omitempty"`
	// contains filtered or unexported fields
}

func IamListUsers

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

func (*IamUser) FromUser

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

type InfraApi

type InfraApi struct {
	Dns         string `json:"dns,omitempty"    yaml:"dns,omitempty"`
	Domain      string `json:"domain,omitempty" yaml:"domain,omitempty"`
	ReadOnlyUrl string `json:"url,omitempty" yaml:"url,omitempty"`
	// contains filtered or unexported fields
}

type InfraDynamoDB

type InfraDynamoDB struct {
	Key         []string                       `json:"key"                    yaml:"key"`
	Attr        []string                       `json:"attr,omitempty"         yaml:"attr,omitempty"`
	GlobalIndex map[string]*InfraDynamoDBIndex `json:"global-index,omitempty" yaml:"global-index,omitempty"`
	LocalIndex  map[string]*InfraDynamoDBIndex `json:"local-index,omitempty"  yaml:"local-index,omitempty"`
	// contains filtered or unexported fields
}

type InfraDynamoDBIndex

type InfraDynamoDBIndex struct {
	Key    []string `json:"key"                  yaml:"key"`
	NonKey []string `json:"non-key,omitempty"    yaml:"non-key,omitempty"`
	Attrs  []string `json:"attr,omitempty"       yaml:"attr,omitempty"`
}

type InfraEC2

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

type InfraEvent

type InfraEvent struct {
	Target string   `json:"target,omitempty" yaml:"target,omitempty"`
	Attr   []string `json:"attr,omitempty"   yaml:"attr,omitempty"`
	// contains filtered or unexported fields
}

type InfraInstanceProfile

type InfraInstanceProfile struct {
	Policy []string `json:"policy,omitempty" yaml:"policy,omitempty"`
	Allow  []string `json:"allow,omitempty"  yaml:"allow,omitempty"`
	// contains filtered or unexported fields
}

type InfraKeypair

type InfraKeypair struct {
	PubkeyContent string `json:"pubkey-content" yaml:"pubkey-content"`
	// contains filtered or unexported fields
}

type InfraLambda

type InfraLambda struct {
	Name       string          `json:"name,omitempty"       yaml:"name,omitempty"`
	Arn        string          `json:"arn,omitempty"        yaml:"arn,omitempty"`
	Entrypoint string          `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"`
	Policy     []string        `json:"policy,omitempty"     yaml:"policy,omitempty"`
	Allow      []string        `json:"allow,omitempty"      yaml:"allow,omitempty"`
	Attr       []string        `json:"attr,omitempty"       yaml:"attr,omitempty"`
	Require    []string        `json:"require,omitempty"    yaml:"require,omitempty"`
	Env        []string        `json:"env,omitempty"        yaml:"env,omitempty"`
	Include    []string        `json:"include,omitempty"    yaml:"include,omitempty"`
	Trigger    []*InfraTrigger `json:"trigger,omitempty"    yaml:"trigger,omitempty"`
	// contains filtered or unexported fields
}

type InfraListOutput

type InfraListOutput struct {
	Account  string               `yaml:"account"`
	Region   string               `yaml:"region"`
	InfraSet map[string]*InfraSet `yaml:"infraset,omitempty"`
}

func InfraList

func InfraList(ctx context.Context, filter string, showEnvVarValues bool) (*InfraListOutput, error)

type InfraRole

type InfraRole struct {
	Allow  []string `json:"allow,omitempty"  yaml:"allow,omitempty"`
	Policy []string `json:"policy,omitempty" yaml:"policy,omitempty"`
	// contains filtered or unexported fields
}

type InfraS3

type InfraS3 struct {
	Attr []string `json:"attr,omitempty" yaml:"attr,omitempty"`
	// contains filtered or unexported fields
}

type InfraSQS

type InfraSQS struct {
	Attr []string `json:"attr,omitempty" yaml:"attr,omitempty"`
	// contains filtered or unexported fields
}

type InfraSecurityGroup

type InfraSecurityGroup struct {
	Rule []string `json:"rule,omitempty" yaml:"rule,omitempty"`
}

type InfraSet

type InfraSet struct {

	// infra set name
	Name string `yaml:"name,omitempty"`

	// lambda
	Lambda map[string]*InfraLambda `yaml:"lambda,omitempty"`

	// stateful infra
	DynamoDB map[string]*InfraDynamoDB `yaml:"dynamodb,omitempty"`
	SQS      map[string]*InfraSQS      `yaml:"sqs,omitempty"`
	S3       map[string]*InfraS3       `yaml:"s3,omitempty"`

	// ec2 infra
	Keypair         map[string]*InfraKeypair         `yaml:"keypair,omitempty"`
	Vpc             map[string]*InfraVpc             `yaml:"vpc,omitempty"`
	InstanceProfile map[string]*InfraInstanceProfile `yaml:"instance-profile,omitempty"`

	// "none" infraset gets a few extra slots for resources not associated with any infraset
	User  map[string]*InfraUser  `yaml:"user,omitempty"`
	Role  map[string]*InfraRole  `yaml:"role,omitempty"`  // any role  not associated with an infraset shows up here
	Api   map[string]*InfraApi   `yaml:"api,omitempty"`   // any api   not associated with an infraset shows up here
	Event map[string]*InfraEvent `yaml:"event,omitempty"` // any event not associated with an infraset shows up here
}

func InfraParse

func InfraParse(yamlPath string) (*InfraSet, error)

type InfraTrigger

type InfraTrigger struct {
	Type string   `json:"type,omitempty" yaml:"type,omitempty"`
	Attr []string `json:"attr,omitempty" yaml:"attr,omitempty"`
	// contains filtered or unexported fields
}

type InfraUser

type InfraUser struct {
	Allow  []string `json:"allow,omitempty"  yaml:"allow,omitempty"`
	Policy []string `json:"policy,omitempty" yaml:"policy,omitempty"`
}

type InfraVpc

type InfraVpc struct {
	SecurityGroup map[string]*InfraSecurityGroup `json:"security-group" yaml:"security-group"`
	ReadOnlyEC2   map[string]*InfraEC2           `json:"ec2,omitempty"  yaml:"ec2,omitempty"`
	// 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(infraLambda *InfraLambda) error

type LambdaUpdateZipFn

type LambdaUpdateZipFn func(infraLambda *InfraLambda) 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