awscloud

package
v0.0.0-...-a54ac30 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegionFromInstanceMetadata

func RegionFromInstanceMetadata() (string, error)

func SecureInstanceUserData

func SecureInstanceUserData(cloudWatchGroup, hostname string) string

SecureInstanceUserData returns the cloud-init user data for a secure instance.

Types

type AWS

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

func New

func New(region string, accessKeyID string, accessKey string, sessionToken string) (*AWS, error)

Initialize a new AWS object from individual bits. SessionToken is optional

func NewDefault

func NewDefault(region string) (*AWS, error)

Initialize a new AWS object from defaults. Looks for env variables, shared credential file, and EC2 Instance Roles.

func NewForEndpoint

func NewForEndpoint(endpoint, region, accessKeyID, accessKey, sessionToken, caBundle string, skipSSLVerification bool) (*AWS, error)

Initialize a new AWS object targeting a specific endpoint from individual bits. SessionToken is optional

func NewForEndpointFromFile

func NewForEndpointFromFile(filename, endpoint, region, caBundle string, skipSSLVerification bool) (*AWS, error)

Initializes a new AWS object targeting a specific endpoint with the credentials info found at filename's location. The credential files should match the AWS format, such as: [default] aws_access_key_id = secretString1 aws_secret_access_key = secretString2

If filename is empty the underlying function will look for the "AWS_SHARED_CREDENTIALS_FILE" env variable or will default to $HOME/.aws/credentials.

func NewFromFile

func NewFromFile(filename string, region string) (*AWS, error)

Initializes a new AWS object with the credentials info found at filename's location. The credential files should match the AWS format, such as: [default] aws_access_key_id = secretString1 aws_secret_access_key = secretString2

If filename is empty the underlying function will look for the "AWS_SHARED_CREDENTIALS_FILE" env variable or will default to $HOME/.aws/credentials.

func (*AWS) ASGSetProtectHost

func (a *AWS) ASGSetProtectHost(protect bool) error

func (*AWS) CopyImage

func (a *AWS) CopyImage(name, ami, sourceRegion string) (string, error)

target region is determined by the region configured in the aws session

func (*AWS) DescribeImagesByName

func (a *AWS) DescribeImagesByName(name string) (*ec2.DescribeImagesOutput, error)

func (*AWS) DescribeImagesByTag

func (a *AWS) DescribeImagesByTag(tagKey, tagValue string) ([]ec2types.Image, error)

For service maintenance images are discovered by the "Name:composer-api-*" tag filter. Currently all image names in the service are generated, so they're guaranteed to be unique as well. If users are ever allowed to name their images, an extra tag should be added.

func (*AWS) EC2ForTestsOnly

func (a *AWS) EC2ForTestsOnly() EC2

This is used by the internal/boot test, which access the ec2 apis directly

func (*AWS) MarkS3ObjectAsPublic

func (a *AWS) MarkS3ObjectAsPublic(bucket, objectKey string) error

func (*AWS) Regions

func (a *AWS) Regions() ([]string, error)

func (*AWS) Register

func (a *AWS) Register(name, bucket, key string, shareWith []string, rpmArch string, bootMode *string) (*string, error)

Register is a function that imports a snapshot, waits for the snapshot to fully import, tags the snapshot, cleans up the image in S3, and registers an AMI in AWS. The caller can optionally specify the boot mode of the AMI. If the boot mode is not specified, then the instances launched from this AMI use the default boot mode value of the instance type.

func (*AWS) RemoveSnapshotAndDeregisterImage

func (a *AWS) RemoveSnapshotAndDeregisterImage(image *ec2types.Image) error

func (*AWS) RunSecureInstance

func (a *AWS) RunSecureInstance(iamProfile, keyName, cloudWatchGroup, hostname string) (*SecureInstance, error)

Runs an instance with a security group that only allows traffic to the host. Will replace resources if they already exists.

func (*AWS) S3ObjectPresignedURL

func (a *AWS) S3ObjectPresignedURL(bucket, objectKey string) (string, error)

func (*AWS) ShareImage

func (a *AWS) ShareImage(ami string, userIds []string) error

func (*AWS) TerminateSecureInstance

func (a *AWS) TerminateSecureInstance(si *SecureInstance) error

func (*AWS) Upload

func (a *AWS) Upload(filename, bucket, key string) (*manager.UploadOutput, error)

type EC2

type EC2 interface {
	DescribeRegions(context.Context, *ec2.DescribeRegionsInput, ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error)

	// Security Groups
	AuthorizeSecurityGroupIngress(context.Context, *ec2.AuthorizeSecurityGroupIngressInput, ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupIngressOutput, error)
	CreateSecurityGroup(context.Context, *ec2.CreateSecurityGroupInput, ...func(*ec2.Options)) (*ec2.CreateSecurityGroupOutput, error)
	DeleteSecurityGroup(context.Context, *ec2.DeleteSecurityGroupInput, ...func(*ec2.Options)) (*ec2.DeleteSecurityGroupOutput, error)
	DescribeSecurityGroups(context.Context, *ec2.DescribeSecurityGroupsInput, ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)

	// Subnets
	CreateSubnet(context.Context, *ec2.CreateSubnetInput, ...func(*ec2.Options)) (*ec2.CreateSubnetOutput, error)
	DeleteSubnet(context.Context, *ec2.DeleteSubnetInput, ...func(*ec2.Options)) (*ec2.DeleteSubnetOutput, error)
	DescribeSubnets(context.Context, *ec2.DescribeSubnetsInput, ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)

	// LaunchTemplates
	CreateLaunchTemplate(context.Context, *ec2.CreateLaunchTemplateInput, ...func(*ec2.Options)) (*ec2.CreateLaunchTemplateOutput, error)
	DeleteLaunchTemplate(context.Context, *ec2.DeleteLaunchTemplateInput, ...func(*ec2.Options)) (*ec2.DeleteLaunchTemplateOutput, error)
	DescribeLaunchTemplates(context.Context, *ec2.DescribeLaunchTemplatesInput, ...func(*ec2.Options)) (*ec2.DescribeLaunchTemplatesOutput, error)

	// Instances
	DescribeInstances(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)
	DescribeInstanceStatus(context.Context, *ec2.DescribeInstanceStatusInput, ...func(*ec2.Options)) (*ec2.DescribeInstanceStatusOutput, error)
	RunInstances(context.Context, *ec2.RunInstancesInput, ...func(*ec2.Options)) (*ec2.RunInstancesOutput, error)
	TerminateInstances(context.Context, *ec2.TerminateInstancesInput, ...func(*ec2.Options)) (*ec2.TerminateInstancesOutput, error)

	// Fleets
	CreateFleet(context.Context, *ec2.CreateFleetInput, ...func(*ec2.Options)) (*ec2.CreateFleetOutput, error)
	DeleteFleets(context.Context, *ec2.DeleteFleetsInput, ...func(*ec2.Options)) (*ec2.DeleteFleetsOutput, error)

	// Images
	CopyImage(context.Context, *ec2.CopyImageInput, ...func(*ec2.Options)) (*ec2.CopyImageOutput, error)
	RegisterImage(context.Context, *ec2.RegisterImageInput, ...func(*ec2.Options)) (*ec2.RegisterImageOutput, error)
	DeregisterImage(context.Context, *ec2.DeregisterImageInput, ...func(*ec2.Options)) (*ec2.DeregisterImageOutput, error)
	DescribeImages(context.Context, *ec2.DescribeImagesInput, ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)
	ModifyImageAttribute(context.Context, *ec2.ModifyImageAttributeInput, ...func(*ec2.Options)) (*ec2.ModifyImageAttributeOutput, error)

	// Snapshots
	DeleteSnapshot(context.Context, *ec2.DeleteSnapshotInput, ...func(*ec2.Options)) (*ec2.DeleteSnapshotOutput, error)
	DescribeImportSnapshotTasks(context.Context, *ec2.DescribeImportSnapshotTasksInput, ...func(*ec2.Options)) (*ec2.DescribeImportSnapshotTasksOutput, error)
	ImportSnapshot(context.Context, *ec2.ImportSnapshotInput, ...func(*ec2.Options)) (*ec2.ImportSnapshotOutput, error)
	ModifySnapshotAttribute(context.Context, *ec2.ModifySnapshotAttributeInput, ...func(*ec2.Options)) (*ec2.ModifySnapshotAttributeOutput, error)

	// Tags
	CreateTags(context.Context, *ec2.CreateTagsInput, ...func(*ec2.Options)) (*ec2.CreateTagsOutput, error)
}

type EC2Imds

type EC2Imds interface {
	GetInstanceIdentityDocument(context.Context, *imds.GetInstanceIdentityDocumentInput, ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error)
}

type S3

type S3 interface {
	DeleteObject(context.Context, *s3.DeleteObjectInput, ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
	PutObjectAcl(context.Context, *s3.PutObjectAclInput, ...func(*s3.Options)) (*s3.PutObjectAclOutput, error)
}

type S3Manager

type S3Manager interface {
	Upload(context.Context, *s3.PutObjectInput, ...func(*manager.Uploader)) (*manager.UploadOutput, error)
}

type S3Presign

type S3Presign interface {
	PresignGetObject(context.Context, *s3.GetObjectInput, ...func(*s3.PresignOptions)) (*v4.PresignedHTTPRequest, error)
}

type SecureInstance

type SecureInstance struct {
	FleetID    string
	SGID       string
	LTID       string
	Instance   *ec2types.Instance
	InstanceID string
}

Jump to

Keyboard shortcuts

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