aws

package
v0.13.15 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package aws allows to interact with resources on Amazon Web Services.

Index

Constants

View Source
const (
	CanonicalAccountId = "099720109477"
	CentOsAccountId    = "679593333241"
	AmazonAccountId    = "amazon"
)

These are commonly used AMI account IDs.

Variables

This section is empty.

Functions

func AddTagsToResource added in v0.9.11

func AddTagsToResource(t *testing.T, region string, resource string, tags map[string]string)

AddTagsToResource adds the tags to the given taggable AWS resource such as EC2, AMI or VPC.

func AddTagsToResourceE added in v0.9.11

func AddTagsToResourceE(t *testing.T, region string, resource string, tags map[string]string) error

AddTagsToResourceE adds the tags to the given taggable AWS resource such as EC2, AMI or VPC.

func AssertS3BucketExists

func AssertS3BucketExists(t *testing.T, region string, name string)

AssertS3BucketExists checks if the given S3 bucket exists in the given region and fail the test if it does not.

func AssertS3BucketExistsE

func AssertS3BucketExistsE(t *testing.T, region string, name string) error

AssertS3BucketExistsE checks if the given S3 bucket exists in the given region and return an error if it does not.

func AssumeRole added in v0.9.3

func AssumeRole(sess *session.Session, roleARN string) *session.Session

AssumeRole mutates the provided session by obtaining new credentials by assuming the role provided in roleARN.

func CreateAwsCredentials

func CreateAwsCredentials(accessKeyID string, secretAccessKey string) *credentials.Credentials

CreateAwsCredentials creates an AWS Credentials configuration with specific AWS credentials.

func CreateAwsCredentialsWithSessionToken

func CreateAwsCredentialsWithSessionToken(accessKeyID, secretAccessKey, sessionToken string) *credentials.Credentials

CreateAwsCredentialsWithSessionToken creates an AWS Credentials configuration with temporary AWS credentials by including a session token (used for authenticating with MFA).

func CreateAwsSessionFromRole added in v0.9.3

func CreateAwsSessionFromRole(region string, roleARN string) (*session.Session, error)

CreateAwsSessionFromRole returns a new AWS session after assuming the role whose ARN is provided in roleARN.

func CreateAwsSessionWithCreds

func CreateAwsSessionWithCreds(region string, accessKeyID string, secretAccessKey string) (*session.Session, error)

CreateAwsSessionWithCreds creates a new AWS session using explicit credentials. This is useful if you want to create an IAM User dynamically and create an AWS session authenticated as the new IAM User.

func CreateAwsSessionWithMfa

func CreateAwsSessionWithMfa(region string, stsClient *sts.STS, mfaDevice *iam.VirtualMFADevice) (*session.Session, error)

CreateAwsSessionWithMfa creates a new AWS session authenticated using an MFA token retrieved using the given STS client and MFA Device.

func CreateMfaDevice

func CreateMfaDevice(t *testing.T, iamClient *iam.IAM, deviceName string) *iam.VirtualMFADevice

CreateMfaDevice creates an MFA device using the given IAM client.

func CreateMfaDeviceE

func CreateMfaDeviceE(t *testing.T, iamClient *iam.IAM, deviceName string) (*iam.VirtualMFADevice, error)

CreateMfaDeviceE creates an MFA device using the given IAM client.

func CreateRandomQueue

func CreateRandomQueue(t *testing.T, awsRegion string, prefix string) string

CreateRandomQueue creates a new SQS queue with a random name that starts with the given prefix and return the queue URL.

func CreateRandomQueueE

func CreateRandomQueueE(t *testing.T, awsRegion string, prefix string) (string, error)

CreateRandomQueueE creates a new SQS queue with a random name that starts with the given prefix and return the queue URL.

func CreateS3Bucket

func CreateS3Bucket(t *testing.T, region string, name string)

CreateS3Bucket creates an S3 bucket in the given region with the given name. Note that S3 bucket names must be globally unique.

func CreateS3BucketE

func CreateS3BucketE(t *testing.T, region string, name string) error

CreateS3BucketE creates an S3 bucket in the given region with the given name. Note that S3 bucket names must be globally unique.

func CreateSnsTopic

func CreateSnsTopic(t *testing.T, region string, snsTopicName string) string

CreateSnsTopic creates an SNS Topic and return the ARN.

func CreateSnsTopicE

func CreateSnsTopicE(t *testing.T, region string, snsTopicName string) (string, error)

CreateSnsTopicE creates an SNS Topic and return the ARN.

func DeleteAmi

func DeleteAmi(t *testing.T, region string, imageID string)

DeleteAmi deletes the given AMI in the given region.

func DeleteAmiAndAllSnapshots added in v0.9.9

func DeleteAmiAndAllSnapshots(t *testing.T, region string, ami string)

DeleteAmiAndAllSnapshots will delete the given AMI along with all EBS snapshots that backed that AMI

func DeleteAmiAndAllSnapshotsE added in v0.9.9

func DeleteAmiAndAllSnapshotsE(t *testing.T, region string, ami string) error

DeleteAmiAndAllSnapshotsE will delete the given AMI along with all EBS snapshots that backed that AMI

func DeleteAmiE

func DeleteAmiE(t *testing.T, region string, imageID string) error

DeleteAmiE deletes the given AMI in the given region.

func DeleteEC2KeyPair

func DeleteEC2KeyPair(t *testing.T, keyPair *Ec2Keypair)

DeleteEC2KeyPair deletes an EC2 key pair.

func DeleteEC2KeyPairE

func DeleteEC2KeyPairE(t *testing.T, keyPair *Ec2Keypair) error

DeleteEC2KeyPairE deletes an EC2 key pair.

func DeleteEbsSnapshot added in v0.9.9

func DeleteEbsSnapshot(t *testing.T, region string, snapshot string)

DeleteEbsSnapshot deletes the given EBS snapshot

func DeleteEbsSnapshotE added in v0.9.9

func DeleteEbsSnapshotE(t *testing.T, region string, snapshot string) error

DeleteEbsSnapshot deletes the given EBS snapshot

func DeleteMessageFromQueue

func DeleteMessageFromQueue(t *testing.T, awsRegion string, queueURL string, receipt string)

DeleteMessageFromQueue deletes the message with the given receipt from the SQS queue with the given URL.

func DeleteMessageFromQueueE

func DeleteMessageFromQueueE(t *testing.T, awsRegion string, queueURL string, receipt string) error

DeleteMessageFromQueueE deletes the message with the given receipt from the SQS queue with the given URL.

func DeleteQueue

func DeleteQueue(t *testing.T, awsRegion string, queueURL string)

DeleteQueue deletes the SQS queue with the given URL.

func DeleteQueueE

func DeleteQueueE(t *testing.T, awsRegion string, queueURL string) error

DeleteQueueE deletes the SQS queue with the given URL.

func DeleteS3Bucket

func DeleteS3Bucket(t *testing.T, region string, name string)

DeleteS3Bucket destroys the S3 bucket in the given region with the given name.

func DeleteS3BucketE

func DeleteS3BucketE(t *testing.T, region string, name string) error

DeleteS3BucketE destroys the S3 bucket in the given region with the given name.

func DeleteSNSTopic

func DeleteSNSTopic(t *testing.T, region string, snsTopicArn string)

DeleteSNSTopic deletes an SNS Topic.

func DeleteSNSTopicE

func DeleteSNSTopicE(t *testing.T, region string, snsTopicArn string) error

DeleteSNSTopicE deletes an SNS Topic.

func EmptyS3Bucket added in v0.9.15

func EmptyS3Bucket(t *testing.T, region string, name string)

EmptyS3BucketE removes the contents of an S3 bucket in the given region with the given name.

func EmptyS3BucketE added in v0.9.15

func EmptyS3BucketE(t *testing.T, region string, name string) error

EmptyS3BucketE removes the contents of an S3 bucket in the given region with the given name.

func EnableMfaDevice

func EnableMfaDevice(t *testing.T, iamClient *iam.IAM, mfaDevice *iam.VirtualMFADevice)

EnableMfaDevice enables a newly created MFA Device by supplying the first two one-time passwords, so that it can be used for future logins by the given IAM User.

func EnableMfaDeviceE

func EnableMfaDeviceE(t *testing.T, iamClient *iam.IAM, mfaDevice *iam.VirtualMFADevice) error

EnableMfaDeviceE enables a newly created MFA Device by supplying the first two one-time passwords, so that it can be used for future logins by the given IAM User.

func FetchContentsOfFileFromAsg added in v0.9.17

func FetchContentsOfFileFromAsg(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, asgName string, useSudo bool, filePath string) map[string]string

FetchContentsOfFileFromAsg looks up the EC2 Instances in the given ASG, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, fetches the contents of the file at the given path (using sudo if useSudo is true), and returns a map from Instance ID to the contents of that file as a string.

func FetchContentsOfFileFromAsgE added in v0.9.17

func FetchContentsOfFileFromAsgE(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, asgName string, useSudo bool, filePath string) (map[string]string, error)

FetchContentsOfFileFromAsgE looks up the EC2 Instances in the given ASG, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, fetches the contents of the file at the given path (using sudo if useSudo is true), and returns a map from Instance ID to the contents of that file as a string.

func FetchContentsOfFileFromInstance added in v0.9.17

func FetchContentsOfFileFromInstance(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, instanceID string, useSudo bool, filePath string) string

FetchContentsOfFileFromInstance looks up the public IP address of the EC2 Instance with the given ID, connects to the Instance via SSH using the given username and Key Pair, fetches the contents of the file at the given path (using sudo if useSudo is true), and returns the contents of that file as a string.

func FetchContentsOfFileFromInstanceE added in v0.9.17

func FetchContentsOfFileFromInstanceE(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, instanceID string, useSudo bool, filePath string) (string, error)

FetchContentsOfFileFromInstanceE looks up the public IP address of the EC2 Instance with the given ID, connects to the Instance via SSH using the given username and Key Pair, fetches the contents of the file at the given path (using sudo if useSudo is true), and returns the contents of that file as a string.

func FetchContentsOfFilesFromAsg added in v0.9.17

func FetchContentsOfFilesFromAsg(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, asgName string, useSudo bool, filePaths ...string) map[string]map[string]string

FetchContentsOfFilesFromAsg looks up the EC2 Instances in the given ASG, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, fetches the contents of the files at the given paths (using sudo if useSudo is true), and returns a map from Instance ID to a map of file path to the contents of that file as a string.

func FetchContentsOfFilesFromAsgE added in v0.9.17

func FetchContentsOfFilesFromAsgE(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, asgName string, useSudo bool, filePaths ...string) (map[string]map[string]string, error)

FetchContentsOfFilesFromAsgE looks up the EC2 Instances in the given ASG, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, fetches the contents of the files at the given paths (using sudo if useSudo is true), and returns a map from Instance ID to a map of file path to the contents of that file as a string.

func FetchContentsOfFilesFromInstance added in v0.9.17

func FetchContentsOfFilesFromInstance(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, instanceID string, useSudo bool, filePaths ...string) map[string]string

FetchContentsOfFilesFromInstance looks up the public IP address of the EC2 Instance with the given ID, connects to the Instance via SSH using the given username and Key Pair, fetches the contents of the files at the given paths (using sudo if useSudo is true), and returns a map from file path to the contents of that file as a string.

func FetchContentsOfFilesFromInstanceE added in v0.9.17

func FetchContentsOfFilesFromInstanceE(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, instanceID string, useSudo bool, filePaths ...string) (map[string]string, error)

FetchContentsOfFilesFromInstanceE looks up the public IP address of the EC2 Instance with the given ID, connects to the Instance via SSH using the given username and Key Pair, fetches the contents of the files at the given paths (using sudo if useSudo is true), and returns a map from file path to the contents of that file as a string.

func FetchFilesFromAsgs added in v0.13.0

func FetchFilesFromAsgs(t *testing.T, awsRegion string, spec RemoteFileSpecification)

FetchFilesFromAsgs looks up the EC2 Instances in all the ASGs given in the RemoteFileSpecification, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, downloads the files matching filenameFilters at the given remoteDirectory (using sudo if useSudo is true), and stores the files locally at localDirectory/<publicip>/<remoteFolderName>

func FetchFilesFromAsgsE added in v0.13.0

func FetchFilesFromAsgsE(t *testing.T, awsRegion string, spec RemoteFileSpecification) error

FetchFilesFromAsgsE looks up the EC2 Instances in all the ASGs given in the RemoteFileSpecification, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, downloads the files matching filenameFilters at the given remoteDirectory (using sudo if useSudo is true), and stores the files locally at localDirectory/<publicip>/<remoteFolderName>

func FetchFilesFromInstance added in v0.13.0

func FetchFilesFromInstance(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, instanceID string, useSudo bool, remoteDirectory string, localDirectory string, filenameFilters []string)

FetchFilesFromInstance looks up the EC2 Instances in the given ASG, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, downloads the files matching filenameFilters at the given remoteDirectory (using sudo if useSudo is true), and stores the files locally at localDirectory/<publicip>/<remoteFolderName>

func FetchFilesFromInstanceE added in v0.13.0

func FetchFilesFromInstanceE(t *testing.T, awsRegion string, sshUserName string, keyPair *Ec2Keypair, instanceID string, useSudo bool, remoteDirectory string, localDirectory string, filenameFilters []string) error

FetchFilesFromInstanceE looks up the EC2 Instances in the given ASG, looks up the public IPs of those EC2 Instances, connects to each Instance via SSH using the given username and Key Pair, downloads the files matching filenameFilters at the given remoteDirectory (using sudo if useSudo is true), and stores the files locally at localDirectory/<publicip>/<remoteFolderName>

func FindS3BucketWithTag

func FindS3BucketWithTag(t *testing.T, awsRegion string, key string, value string) string

FindS3BucketWithTag finds the name of the S3 bucket in the given region with the given tag key=value.

func FindS3BucketWithTagE

func FindS3BucketWithTagE(t *testing.T, awsRegion string, key string, value string) (string, error)

FindS3BucketWithTagE finds the name of the S3 bucket in the given region with the given tag key=value.

func FindVpcName

func FindVpcName(vpc *ec2.Vpc) string

FindVpcName extracts the VPC name from its tags (if any). Fall back to "Default" if it's the default VPC or empty string otherwise.

func GetAccountId

func GetAccountId(t *testing.T) string

GetAccountId gets the Account ID for the currently logged in IAM User.

func GetAccountIdE

func GetAccountIdE(t *testing.T) (string, error)

GetAccountIdE gets the Account ID for the currently logged in IAM User.

func GetAccountsWithLaunchPermissionsForAmi added in v0.13.2

func GetAccountsWithLaunchPermissionsForAmi(t *testing.T, awsRegion string, amiID string) []string

GetAccountsWithLaunchPermissionsForAmi returns list of accounts that the AMI is shared with

func GetAccountsWithLaunchPermissionsForAmiE added in v0.13.2

func GetAccountsWithLaunchPermissionsForAmiE(t *testing.T, awsRegion string, amiID string) ([]string, error)

GetAccountsWithLaunchPermissionsForAmiE returns list of accounts that the AMI is shared with

func GetAcmCertificateArn

func GetAcmCertificateArn(t *testing.T, awsRegion string, certDomainName string) string

GetAcmCertificateArn gets the ACM certificate for the given domain name in the given region.

func GetAcmCertificateArnE added in v0.9.0

func GetAcmCertificateArnE(t *testing.T, awsRegion string, certDomainName string) (string, error)

GetAcmCertificateArnE gets the ACM certificate for the given domain name in the given region.

func GetAddressOfRdsInstance added in v0.10.3

func GetAddressOfRdsInstance(t *testing.T, dbInstanceID string, awsRegion string) string

GetAddressOfRdsInstance gets the address of the given RDS Instance in the given region.

func GetAddressOfRdsInstanceE added in v0.10.3

func GetAddressOfRdsInstanceE(t *testing.T, dbInstanceID string, awsRegion string) (string, error)

GetAddressOfRdsInstanceE gets the address of the given RDS Instance in the given region.

func GetAllAwsRegions

func GetAllAwsRegions(t *testing.T) []string

GetAllAwsRegions gets the list of AWS regions available in this account.

func GetAllAwsRegionsE

func GetAllAwsRegionsE(t *testing.T) ([]string, error)

GetAllAwsRegionsE gets the list of AWS regions available in this account.

func GetAllParametersOfRdsInstance added in v0.10.3

func GetAllParametersOfRdsInstance(t *testing.T, dbInstanceID string, awsRegion string) []*rds.Parameter

GetAllParametersOfRdsInstance gets all the parameters defined in the parameter group for the RDS instance in the given region.

func GetAllParametersOfRdsInstanceE added in v0.10.3

func GetAllParametersOfRdsInstanceE(t *testing.T, dbInstanceID string, awsRegion string) ([]*rds.Parameter, error)

GetAllParametersOfRdsInstanceE gets all the parameters defined in the parameter group for the RDS instance in the given region.

func GetAmazonLinuxAmi

func GetAmazonLinuxAmi(t *testing.T, region string) string

GetAmazonLinuxAmi returns an Amazon Linux AMI HVM, SSD Volume Type public AMI for the given region.

func GetAmazonLinuxAmiE

func GetAmazonLinuxAmiE(t *testing.T, region string) (string, error)

GetAmazonLinuxAmiE returns an Amazon Linux AMI HVM, SSD Volume Type public AMI for the given region.

func GetAmiPubliclyAccessible added in v0.13.2

func GetAmiPubliclyAccessible(t *testing.T, awsRegion string, amiID string) bool

GetAmiPubliclyAccessible returns whether the AMI is publicly accessible or not

func GetAmiPubliclyAccessibleE added in v0.13.2

func GetAmiPubliclyAccessibleE(t *testing.T, awsRegion string, amiID string) (bool, error)

GetAmiPubliclyAccessibleE returns whether the AMI is publicly accessible or not

func GetAvailabilityZones

func GetAvailabilityZones(t *testing.T, region string) []string

GetAvailabilityZones gets the Availability Zones for a given AWS region. Note that for certain regions (e.g. us-east-1), different AWS accounts have access to different availability zones.

func GetAvailabilityZonesE

func GetAvailabilityZonesE(t *testing.T, region string) ([]string, error)

GetAvailabilityZonesE gets the Availability Zones for a given AWS region. Note that for certain regions (e.g. us-east-1), different AWS accounts have access to different availability zones.

func GetCentos7Ami

func GetCentos7Ami(t *testing.T, region string) string

GetCentos7Ami returns a CentOS 7 public AMI from the given region. WARNING: you may have to accept the terms & conditions of this AMI in AWS MarketPlace for your AWS Account before you can successfully launch the AMI.

func GetCentos7AmiE

func GetCentos7AmiE(t *testing.T, region string) (string, error)

GetCentos7AmiE returns a CentOS 7 public AMI from the given region. WARNING: you may have to accept the terms & conditions of this AMI in AWS MarketPlace for your AWS Account before you can successfully launch the AMI.

func GetCloudWatchLogEntries

func GetCloudWatchLogEntries(t *testing.T, awsRegion string, logStreamName string, logGroupName string) []string

GetCloudWatchLogEntries returns the CloudWatch log messages in the given region for the given log stream and log group.

func GetCloudWatchLogEntriesE

func GetCloudWatchLogEntriesE(t *testing.T, awsRegion string, logStreamName string, logGroupName string) ([]string, error)

GetCloudWatchLogEntriesE returns the CloudWatch log messages in the given region for the given log stream and log group.

func GetCmkArn

func GetCmkArn(t *testing.T, region string, cmkID string) string

GetCmkArn gets the ARN of a KMS Customer Master Key (CMK) in the given region with the given ID. The ID can be an alias, such as "alias/my-cmk".

func GetCmkArnE

func GetCmkArnE(t *testing.T, region string, cmkID string) (string, error)

GetCmkArnE gets the ARN of a KMS Customer Master Key (CMK) in the given region with the given ID. The ID can be an alias, such as "alias/my-cmk".

func GetEbsSnapshotsForAmi added in v0.9.9

func GetEbsSnapshotsForAmi(t *testing.T, region string, ami string) []string

GetEbsSnapshotsForAmi retrieves the EBS snapshots which back the given AMI

func GetEbsSnapshotsForAmiE added in v0.9.9

func GetEbsSnapshotsForAmiE(t *testing.T, region string, ami string) ([]string, error)

GetEbsSnapshotsForAmi retrieves the EBS snapshots which back the given AMI

func GetEc2InstanceIdsByTag

func GetEc2InstanceIdsByTag(t *testing.T, region string, tagName string, tagValue string) []string

GetEc2InstanceIdsByTag returns all the IDs of EC2 instances in the given region with the given tag.

func GetEc2InstanceIdsByTagE

func GetEc2InstanceIdsByTagE(t *testing.T, region string, tagName string, tagValue string) ([]string, error)

GetEc2InstanceIdsByTagE returns all the IDs of EC2 instances in the given region with the given tag.

func GetEcsOptimizedAmazonLinuxAmi

func GetEcsOptimizedAmazonLinuxAmi(t *testing.T, region string) string

GetEcsOptimizedAmazonLinuxAmi returns an Amazon ECS-Optimized Amazon Linux AMI for the given region. This AMI is useful for running an ECS cluster.

func GetEcsOptimizedAmazonLinuxAmiE

func GetEcsOptimizedAmazonLinuxAmiE(t *testing.T, region string) (string, error)

GetEcsOptimizedAmazonLinuxAmiE returns an Amazon ECS-Optimized Amazon Linux AMI for the given region. This AMI is useful for running an ECS cluster.

func GetFirstTwoOctets

func GetFirstTwoOctets(cidrBlock string) string

GetFirstTwoOctets gets the first two octets from a CIDR block.

func GetIamCurrentUserArn

func GetIamCurrentUserArn(t *testing.T) string

GetIamCurrentUserArn gets the ARN for the current IAM user.

func GetIamCurrentUserArnE

func GetIamCurrentUserArnE(t *testing.T) (string, error)

GetIamCurrentUserArnE gets the ARN for the current IAM user.

func GetIamCurrentUserName

func GetIamCurrentUserName(t *testing.T) string

GetIamCurrentUserName gets the username for the current IAM user.

func GetIamCurrentUserNameE

func GetIamCurrentUserNameE(t *testing.T) (string, error)

GetIamCurrentUserNameE gets the username for the current IAM user.

func GetInstanceIdsForAsg added in v0.9.0

func GetInstanceIdsForAsg(t *testing.T, asgName string, awsRegion string) []string

GetInstanceIdsForAsg gets the IDs of EC2 Instances in the given ASG.

func GetInstanceIdsForAsgE added in v0.9.0

func GetInstanceIdsForAsgE(t *testing.T, asgName string, awsRegion string) ([]string, error)

GetInstanceIdsForAsgE gets the IDs of EC2 Instances in the given ASG.

func GetLaunchPermissionsForAmiE added in v0.13.2

func GetLaunchPermissionsForAmiE(t *testing.T, awsRegion string, amiID string) ([]*ec2.LaunchPermission, error)

GetLaunchPermissionsForAmiE returns launchPermissions as configured in AWS

func GetMostRecentAmiId

func GetMostRecentAmiId(t *testing.T, region string, ownerId string, filters map[string][]string) string

GetMostRecentAmiId gets the ID of the most recent AMI in the given region that has the given owner and matches the given filters. Each filter should correspond to the name and values of a filter supported by DescribeImagesInput: https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#DescribeImagesInput

func GetMostRecentAmiIdE

func GetMostRecentAmiIdE(t *testing.T, region string, ownerId string, filters map[string][]string) (string, error)

GetMostRecentAmiIdE gets the ID of the most recent AMI in the given region that has the given owner and matches the given filters. Each filter should correspond to the name and values of a filter supported by DescribeImagesInput: https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#DescribeImagesInput

func GetOptionGroupNameOfRdsInstance added in v0.10.3

func GetOptionGroupNameOfRdsInstance(t *testing.T, dbInstanceID string, awsRegion string) string

GetOptionGroupNameOfRdsInstance gets the name of the option group associated with the RDS instance

func GetOptionGroupNameOfRdsInstanceE added in v0.10.3

func GetOptionGroupNameOfRdsInstanceE(t *testing.T, dbInstanceID string, awsRegion string) (string, error)

GetOptionGroupNameOfRdsInstanceE gets the name of the option group associated with the RDS instance

func GetOptionSettingForOfRdsInstance added in v0.10.3

func GetOptionSettingForOfRdsInstance(t *testing.T, optionName string, optionSettingName string, dbInstanceID, awsRegion string) string

GetOptionSettingForOfRdsInstance gets the value of the option name in the option group specified for the RDS instance in the given region.

func GetOptionSettingForOfRdsInstanceE added in v0.10.3

func GetOptionSettingForOfRdsInstanceE(t *testing.T, optionName string, optionSettingName string, dbInstanceID, awsRegion string) (string, error)

GetOptionSettingForOfRdsInstanceE gets the value of the option name in the option group specified for the RDS instance in the given region.

func GetOptionsOfOptionGroup added in v0.10.3

func GetOptionsOfOptionGroup(t *testing.T, optionGroupName string, awsRegion string) []*rds.Option

GetOptionsOfOptionGroup gets the options of the option group specified

func GetOptionsOfOptionGroupE added in v0.10.3

func GetOptionsOfOptionGroupE(t *testing.T, optionGroupName string, awsRegion string) ([]*rds.Option, error)

GetOptionsOfOptionGroupE gets the options of the option group specified

func GetParameterValueForParameterOfRdsInstance added in v0.10.3

func GetParameterValueForParameterOfRdsInstance(t *testing.T, parameterName string, dbInstanceID string, awsRegion string) string

GetParameterValueForParameterOfRdsInstance gets the value of the parameter name specified for the RDS instance in the given region.

func GetParameterValueForParameterOfRdsInstanceE added in v0.10.3

func GetParameterValueForParameterOfRdsInstanceE(t *testing.T, parameterName string, dbInstanceID string, awsRegion string) (string, error)

GetParameterValueForParameterOfRdsInstanceE gets the value of the parameter name specified for the RDS instance in the given region.

func GetPortOfRdsInstance added in v0.10.3

func GetPortOfRdsInstance(t *testing.T, dbInstanceID string, awsRegion string) int64

GetPortOfRdsInstance gets the address of the given RDS Instance in the given region.

func GetPortOfRdsInstanceE added in v0.10.3

func GetPortOfRdsInstanceE(t *testing.T, dbInstanceID string, awsRegion string) (int64, error)

GetPortOfRdsInstanceE gets the address of the given RDS Instance in the given region.

func GetPublicIpOfEc2Instance added in v0.9.0

func GetPublicIpOfEc2Instance(t *testing.T, instanceID string, awsRegion string) string

GetPublicIpOfEc2Instance gets the public IP address of the given EC2 Instance in the given region.

func GetPublicIpOfEc2InstanceE added in v0.9.0

func GetPublicIpOfEc2InstanceE(t *testing.T, instanceID string, awsRegion string) (string, error)

GetPublicIpOfEc2InstanceE gets the public IP address of the given EC2 Instance in the given region.

func GetPublicIpsOfEc2Instances added in v0.9.1

func GetPublicIpsOfEc2Instances(t *testing.T, instanceIDs []string, awsRegion string) map[string]string

GetPublicIpsOfEc2Instances gets the public IP address of the given EC2 Instance in the given region. Returns a map of instance ID to IP address.

func GetPublicIpsOfEc2InstancesE added in v0.9.1

func GetPublicIpsOfEc2InstancesE(t *testing.T, instanceIDs []string, awsRegion string) (map[string]string, error)

GetPublicIpsOfEc2InstancesE gets the public IP address of the given EC2 Instance in the given region. Returns a map of instance ID to IP address.

func GetRandomPrivateCidrBlock

func GetRandomPrivateCidrBlock(routingPrefix int) string

GetRandomPrivateCidrBlock gets a random CIDR block from the range of acceptable private IP addresses per RFC 1918 (https://tools.ietf.org/html/rfc1918#section-3) The routingPrefix refers to the "/28" in 1.2.3.4/28. Note that, as written, this function will return a subset of all valid ranges. Since we will probably use this function mostly for generating random CIDR ranges for VPCs and Subnets, having comprehensive set coverage is not essential.

func GetRandomRegion

func GetRandomRegion(t *testing.T, approvedRegions []string, forbiddenRegions []string) string

GetRandomRegion gets a randomly chosen AWS region. If approvedRegions is not empty, this will be a region from the approvedRegions list; otherwise, this method will fetch the latest list of regions from the AWS APIs and pick one of those. If forbiddenRegions is not empty, this method will make sure the returned region is not in the forbiddenRegions list.

func GetRandomRegionE

func GetRandomRegionE(t *testing.T, approvedRegions []string, forbiddenRegions []string) (string, error)

GetRandomRegionE gets a randomly chosen AWS region. If approvedRegions is not empty, this will be a region from the approvedRegions list; otherwise, this method will fetch the latest list of regions from the AWS APIs and pick one of those. If forbiddenRegions is not empty, this method will make sure the returned region is not in the forbiddenRegions list.

func GetRdsInstanceDetailsE added in v0.10.3

func GetRdsInstanceDetailsE(t *testing.T, dbInstanceID string, awsRegion string) (*rds.DBInstance, error)

GetRdsInstanceDetailsE gets the details of a single DB instance whose identifier is passed.

func GetS3ObjectContents

func GetS3ObjectContents(t *testing.T, awsRegion string, bucket string, key string) string

GetS3ObjectContents fetches the contents of the object in the given bucket with the given key and return it as a string.

func GetS3ObjectContentsE

func GetS3ObjectContentsE(t *testing.T, awsRegion string, bucket string, key string) (string, error)

GetS3ObjectContentsE fetches the contents of the object in the given bucket with the given key and return it as a string.

func GetSyslogForInstance

func GetSyslogForInstance(t *testing.T, instanceID string, awsRegion string) string

(Deprecated) See the FetchContentsOfFileFromInstance method for a more powerful solution.

GetSyslogForInstance gets the syslog for the Instance with the given ID in the given region. This should be available ~1 minute after an Instance boots and is very useful for debugging boot-time issues, such as an error in User Data.

func GetSyslogForInstanceE

func GetSyslogForInstanceE(t *testing.T, instanceID string, region string) (string, error)

(Deprecated) See the FetchContentsOfFileFromInstanceE method for a more powerful solution.

GetSyslogForInstanceE gets the syslog for the Instance with the given ID in the given region. This should be available ~1 minute after an Instance boots and is very useful for debugging boot-time issues, such as an error in User Data.

func GetSyslogForInstancesInAsg

func GetSyslogForInstancesInAsg(t *testing.T, asgName string, awsRegion string) map[string]string

(Deprecated) See the FetchContentsOfFilesFromAsg method for a more powerful solution.

GetSyslogForInstancesInAsg gets the syslog for each of the Instances in the given ASG in the given region. These logs should be available ~1 minute after the Instance boots and are very useful for debugging boot-time issues, such as an error in User Data. Returns a map of Instance Id -> Syslog for that Instance.

func GetSyslogForInstancesInAsgE

func GetSyslogForInstancesInAsgE(t *testing.T, asgName string, awsRegion string) (map[string]string, error)

(Deprecated) See the FetchContentsOfFilesFromAsgE method for a more powerful solution.

GetSyslogForInstancesInAsgE gets the syslog for each of the Instances in the given ASG in the given region. These logs should be available ~1 minute after the Instance boots and are very useful for debugging boot-time issues, such as an error in User Data. Returns a map of Instance Id -> Syslog for that Instance.

func GetTagsForEc2Instance

func GetTagsForEc2Instance(t *testing.T, region string, instanceID string) map[string]string

GetTagsForEc2Instance returns all the tags for the given EC2 Instance.

func GetTagsForEc2InstanceE

func GetTagsForEc2InstanceE(t *testing.T, region string, instanceID string) (map[string]string, error)

GetTagsForEc2InstanceE returns all the tags for the given EC2 Instance.

func GetTimeBasedOneTimePassword

func GetTimeBasedOneTimePassword(mfaDevice *iam.VirtualMFADevice) (string, error)

GetTimeBasedOneTimePassword gets a One-Time Password from the given mfaDevice. Per the RFC 6238 standard, this value will be different every 30 seconds.

func GetUbuntu1404Ami

func GetUbuntu1404Ami(t *testing.T, region string) string

GetUbuntu1404Ami gets the ID of the most recent Ubuntu 14.04 HVM x86_64 EBS GP2 AMI in the given region.

func GetUbuntu1404AmiE

func GetUbuntu1404AmiE(t *testing.T, region string) (string, error)

GetUbuntu1404AmiE gets the ID of the most recent Ubuntu 14.04 HVM x86_64 EBS GP2 AMI in the given region.

func GetUbuntu1604Ami

func GetUbuntu1604Ami(t *testing.T, region string) string

GetUbuntu1604Ami gets the ID of the most recent Ubuntu 16.04 HVM x86_64 EBS GP2 AMI in the given region.

func GetUbuntu1604AmiE

func GetUbuntu1604AmiE(t *testing.T, region string) (string, error)

GetUbuntu1604AmiE gets the ID of the most recent Ubuntu 16.04 HVM x86_64 EBS GP2 AMI in the given region.

func GetWhetherSchemaExistsInRdsMySqlInstance added in v0.10.3

func GetWhetherSchemaExistsInRdsMySqlInstance(t *testing.T, dbUrl string, dbPort int64, dbUsername string, dbPassword string, expectedSchemaName string) bool

GetWhetherSchemaExistsInRdsMySqlInstance checks whether the specified schema/table name exists in the RDS instance

func GetWhetherSchemaExistsInRdsMySqlInstanceE added in v0.10.3

func GetWhetherSchemaExistsInRdsMySqlInstanceE(t *testing.T, dbUrl string, dbPort int64, dbUsername string, dbPassword string, expectedSchemaName string) (bool, error)

GetWhetherSchemaExistsInRdsMySqlInstanceE checks whether the specified schema/table name exists in the RDS instance

func NewAcmClient

func NewAcmClient(t *testing.T, region string) *acm.ACM

NewAcmClient create a new ACM client.

func NewAcmClientE added in v0.9.0

func NewAcmClientE(t *testing.T, awsRegion string) (*acm.ACM, error)

NewAcmClientE creates a new ACM client.

func NewAsgClient added in v0.9.0

func NewAsgClient(t *testing.T, region string) *autoscaling.AutoScaling

NewAsgClient creates an Auto Scaling Group client.

func NewAsgClientE added in v0.9.0

func NewAsgClientE(t *testing.T, region string) (*autoscaling.AutoScaling, error)

NewAsgClientE creates an Auto Scaling Group client.

func NewAuthenticatedSession

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

NewAuthenticatedSession gets an AWS Session, checking that the user has credentials properly configured in their environment.

func NewAuthenticatedSessionFromRole added in v0.9.3

func NewAuthenticatedSessionFromRole(region string, roleARN string) (*session.Session, error)

NewAuthenticatedSessionFromRole returns a new AWS Session after assuming the role whose ARN is provided in roleARN. If the credentials are not properly configured in the underlying environment, an error is returned.

func NewCloudWatchLogsClient

func NewCloudWatchLogsClient(t *testing.T, region string) *cloudwatchlogs.CloudWatchLogs

NewCloudWatchLogsClient creates a new CloudWatch Logs client.

func NewCloudWatchLogsClientE added in v0.9.0

func NewCloudWatchLogsClientE(t *testing.T, region string) (*cloudwatchlogs.CloudWatchLogs, error)

NewCloudWatchLogsClientE creates a new CloudWatch Logs client.

func NewEc2Client

func NewEc2Client(t *testing.T, region string) *ec2.EC2

NewEc2Client creates an EC2 client.

func NewEc2ClientE added in v0.9.0

func NewEc2ClientE(t *testing.T, region string) (*ec2.EC2, error)

NewEc2ClientE creates an EC2 client.

func NewIamClient

func NewIamClient(t *testing.T, region string) *iam.IAM

NewIamClient creates a new IAM client.

func NewIamClientE added in v0.9.0

func NewIamClientE(t *testing.T, region string) (*iam.IAM, error)

NewIamClientE creates a new IAM client.

func NewKmsClient

func NewKmsClient(t *testing.T, region string) *kms.KMS

NewKmsClient creates a KMS client.

func NewKmsClientE added in v0.9.0

func NewKmsClientE(t *testing.T, region string) (*kms.KMS, error)

NewKmsClientE creates a KMS client.

func NewRdsClient added in v0.10.3

func NewRdsClient(t *testing.T, region string) *rds.RDS

NewRdsClient creates an RDS client.

func NewRdsClientE added in v0.10.3

func NewRdsClientE(t *testing.T, region string) (*rds.RDS, error)

NewRdsClientE creates an RDS client.

func NewS3Client

func NewS3Client(t *testing.T, region string) *s3.S3

NewS3Client creates an S3 client.

func NewS3ClientE added in v0.9.0

func NewS3ClientE(t *testing.T, region string) (*s3.S3, error)

NewS3ClientE creates an S3 client.

func NewS3Uploader added in v0.9.15

func NewS3Uploader(t *testing.T, region string) *s3manager.Uploader

NewS3Uploader creates an S3 Uploader.

func NewS3UploaderE added in v0.9.15

func NewS3UploaderE(t *testing.T, region string) (*s3manager.Uploader, error)

NewS3UploaderE creates an S3 Uploader.

func NewSnsClient

func NewSnsClient(t *testing.T, region string) *sns.SNS

NewSnsClient creates a new SNS client.

func NewSnsClientE added in v0.9.0

func NewSnsClientE(t *testing.T, region string) (*sns.SNS, error)

NewSnsClientE creates a new SNS client.

func NewSqsClient

func NewSqsClient(t *testing.T, region string) *sqs.SQS

NewSqsClient creates a new SQS client.

func NewSqsClientE added in v0.9.0

func NewSqsClientE(t *testing.T, region string) (*sqs.SQS, error)

NewSqsClientE creates a new SQS client.

func ReadPasswordPolicyMinPasswordLength

func ReadPasswordPolicyMinPasswordLength(iamClient *iam.IAM) (int, error)

ReadPasswordPolicyMinPasswordLength returns the minimal password length.

func SendMessageToQueue

func SendMessageToQueue(t *testing.T, awsRegion string, queueURL string, message string)

SendMessageToQueue sends the given message to the SQS queue with the given URL.

func SendMessageToQueueE

func SendMessageToQueueE(t *testing.T, awsRegion string, queueURL string, message string) error

SendMessageToQueueE sends the given message to the SQS queue with the given URL.

func TerminateInstance

func TerminateInstance(t *testing.T, region string, instanceID string)

TerminateInstance terminates the EC2 instance with the given ID in the given region.

func TerminateInstanceE

func TerminateInstanceE(t *testing.T, region string, instanceID string) error

TerminateInstanceE terminates the EC2 instance with the given ID in the given region.

Types

type CredentialsError

type CredentialsError struct {
	UnderlyingErr error
}

CredentialsError is an error that occurs because AWS credentials can't be found.

func (CredentialsError) Error

func (err CredentialsError) Error() string

type Ec2Keypair

type Ec2Keypair struct {
	*ssh.KeyPair
	Name   string // The name assigned in AWS to the EC2 Key Pair
	Region string // The AWS region where the EC2 Key Pair lives
}

Ec2Keypair is an EC2 key pair.

func CreateAndImportEC2KeyPair

func CreateAndImportEC2KeyPair(t *testing.T, region string, name string) *Ec2Keypair

CreateAndImportEC2KeyPair generates a public/private KeyPair and import it into EC2 in the given region under the given name.

func CreateAndImportEC2KeyPairE

func CreateAndImportEC2KeyPairE(t *testing.T, region string, name string) (*Ec2Keypair, error)

CreateAndImportEC2KeyPairE generates a public/private KeyPair and import it into EC2 in the given region under the given name.

func ImportEC2KeyPair

func ImportEC2KeyPair(t *testing.T, region string, name string, keyPair *ssh.KeyPair) *Ec2Keypair

ImportEC2KeyPair creates a Key Pair in EC2 by importing an existing public key.

func ImportEC2KeyPairE

func ImportEC2KeyPairE(t *testing.T, region string, name string, keyPair *ssh.KeyPair) (*Ec2Keypair, error)

ImportEC2KeyPairE creates a Key Pair in EC2 by importing an existing public key.

type IpForEc2InstanceNotFound added in v0.9.0

type IpForEc2InstanceNotFound struct {
	InstanceId string
	AwsRegion  string
}

IpForEc2InstanceNotFound is an error that occurs when the IP for an EC2 instance is not found.

func (IpForEc2InstanceNotFound) Error added in v0.9.0

func (err IpForEc2InstanceNotFound) Error() string

type NoImagesFound

type NoImagesFound struct {
	Region  string
	OwnerId string
	Filters map[string][]string
}

NoImagesFound is an error that occurs if no images were found.

func (NoImagesFound) Error

func (err NoImagesFound) Error() string

type OptionGroupOptionSettingForDbInstanceNotFound added in v0.10.3

type OptionGroupOptionSettingForDbInstanceNotFound struct {
	OptionName        string
	OptionSettingName string
	DbInstanceID      string
	AwsRegion         string
}

OptionGroupOptionSettingForDbInstanceNotFound is an error that occurs when the option setting specified is not found in the option group of the DB instance

func (OptionGroupOptionSettingForDbInstanceNotFound) Error added in v0.10.3

type ParameterForDbInstanceNotFound added in v0.10.3

type ParameterForDbInstanceNotFound struct {
	ParameterName string
	DbInstanceID  string
	AwsRegion     string
}

ParameterForDbInstanceNotFound is an error that occurs when the parameter group specified is not found for the DB instance

func (ParameterForDbInstanceNotFound) Error added in v0.10.3

type QueueMessageResponse

type QueueMessageResponse struct {
	ReceiptHandle string
	MessageBody   string
	Error         error
}

QueueMessageResponse contains a queue message.

func WaitForQueueMessage

func WaitForQueueMessage(t *testing.T, awsRegion string, queueURL string, timeout int) QueueMessageResponse

WaitForQueueMessage waits to receive a message from on the queueURL. Since the API only allows us to wait a max 20 seconds for a new message to arrive, we must loop TIMEOUT/20 number of times to be able to wait for a total of TIMEOUT seconds

type ReceiveMessageTimeout

type ReceiveMessageTimeout struct {
	QueueUrl   string
	TimeoutSec int
}

ReceiveMessageTimeout is an error that occurs if receiving a message times out.

func (ReceiveMessageTimeout) Error

func (err ReceiveMessageTimeout) Error() string

type RemoteFileSpecification added in v0.13.0

type RemoteFileSpecification struct {
	AsgNames               []string            //ASGs where our instances will be
	RemotePathToFileFilter map[string][]string //A map of the files to fetch, where the keys are directories on the remote host and the values are filters for what files to fetch from the directory. The filters support bash-style wildcards.
	UseSudo                bool
	SshUser                string
	KeyPair                *Ec2Keypair
	LocalDestinationDir    string //base path where to store downloaded artifacts locally. The final path of each resource will include the ip of the host and the name of the immediate parent folder.
}

type Subnet

type Subnet struct {
	Id               string // The ID of the Subnet
	AvailabilityZone string // The Availability Zone the subnet is in
}

Subnet is a subnet in an availability zone.

func GetSubnetsForVpc

func GetSubnetsForVpc(t *testing.T, vpcID string, region string) []Subnet

GetSubnetsForVpc gets the subnets in the specified VPC.

func GetSubnetsForVpcE

func GetSubnetsForVpcE(t *testing.T, vpcID string, region string) ([]Subnet, error)

GetSubnetsForVpcE gets the subnets in the specified VPC.

type Vpc

type Vpc struct {
	Id      string   // The ID of the VPC
	Name    string   // The name of the VPC
	Subnets []Subnet // A list of subnets in the VPC
}

Vpc is an Amazon Virtual Private Cloud.

func GetDefaultVpc

func GetDefaultVpc(t *testing.T, region string) *Vpc

GetDefaultVpc fetches information about the default VPC in the given region.

func GetDefaultVpcE

func GetDefaultVpcE(t *testing.T, region string) (*Vpc, error)

GetDefaultVpcE fetches information about the default VPC in the given region.

Jump to

Keyboard shortcuts

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