infrastructure

package
v0.0.0-...-b723b64 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceTypeArchArm64 = "arm64"
	InstanceTypeArchX8664 = "x86_64"
)
View Source
const (
	UbuntuAMIRootUser         = "ubuntu"
	UbuntuAMINamePatternAmd64 = "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"
	UbuntuAMINamePatternArm64 = "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-arm64-server-*"
)
View Source
const DynamoDBRecodeConfigTableName = "recode-configuration-dynamodb-table"
View Source
const (
	InstanceRootDeviceSizeGb = 16
)

Variables

View Source
var (
	ErrNoRecodeConfigFound       = errors.New("ErrNoRecodeConfigFound")
	ErrMultipleRecodeConfigFound = errors.New("ErrMultipleRecodeConfigFound")
)
View Source
var (
	ErrInvalidInstanceType     = errors.New("ErrInvalidInstanceType")
	ErrInvalidInstanceTypeArch = errors.New("ErrInvalidInstanceTypeArch")

	SupportedInstanceTypeArchs = []string{
		string(InstanceTypeArchArm64),
		string(InstanceTypeArchX8664),
	}
)
View Source
var (
	ErrInstanceNotFound = errors.New("ErrInstanceNotFound")
)
View Source
var (
	ErrRecodeConfigTableAlreadyExists = errors.New("ErrRecodeConfigTableAlreadyExists")
)

Functions

func AssociateRouteTable

func AssociateRouteTable(
	ec2Client *ec2.Client,
	subnetID string,
	routeTableID string,
) error

func AttachInternetGatewayToVPC

func AttachInternetGatewayToVPC(
	ec2Client *ec2.Client,
	internetGatewayId string,
	VPCID string,
) error

func CreateDynamoDBTableForRecodeConfig

func CreateDynamoDBTableForRecodeConfig(
	dynamoDBClient *dynamodb.Client,
) error

func DetachInternetGatewayFromVPC

func DetachInternetGatewayFromVPC(
	ec2Client *ec2.Client,
	internetGatewayId string,
	VPCID string,
) error

func LookupRecodeConfigInDynamoDBTable

func LookupRecodeConfigInDynamoDBTable(
	dynamoDBClient *dynamodb.Client,
) (returnedConfigJSON string, returnedError error)

func RemoveDynamoDBTableForRecodeConfig

func RemoveDynamoDBTableForRecodeConfig(
	dynamoDBClient *dynamodb.Client,
) error

func RemoveInternetGateway

func RemoveInternetGateway(
	ec2Client *ec2.Client,
	internetGatewayId string,
) error

func RemoveKeyPair

func RemoveKeyPair(
	ec2Client *ec2.Client,
	keyPairID string,
) error

func RemoveNetworkInterface

func RemoveNetworkInterface(
	ec2Client *ec2.Client,
	networkInterfaceID string,
) error

func RemoveRouteTable

func RemoveRouteTable(
	ec2Client *ec2.Client,
	routeTableID string,
) error

func RemoveSecurityGroup

func RemoveSecurityGroup(
	ec2Client *ec2.Client,
	securityGroupID string,
) error

func RemoveSubnet

func RemoveSubnet(
	ec2Client *ec2.Client,
	subnetID string,
) error

func RemoveVPC

func RemoveVPC(
	ec2Client *ec2.Client,
	VPCID string,
) error

func StartInstance

func StartInstance(
	ec2Client *ec2.Client,
	instance *Instance,
) error

func StopInstance

func StopInstance(
	ec2Client *ec2.Client,
	instance *Instance,
) error

func TerminateInstance

func TerminateInstance(
	ec2Client *ec2.Client,
	instanceID string,
) error

func UpdateRecodeConfigInDynamoDBTable

func UpdateRecodeConfigInDynamoDBTable(
	dynamoDBClient *dynamodb.Client,
	configID string,
	configJSON string,
) error

func WaitForSSHAvailableInInstance

func WaitForSSHAvailableInInstance(
	ec2Client *ec2.Client,
	instancePublicIPAddress string,
	instanceSSHPort string,
) (returnedError error)

Types

type AMI

type AMI struct {
	ID             string `json:"id"`
	RootUser       string `json:"root_user"`
	RootDeviceName string `json:"root_device_name"`
}

func LookupUbuntuAMIForArch

func LookupUbuntuAMIForArch(
	ec2Client *ec2.Client,
	arch InstanceTypeArch,
) (returnedAMI *AMI, returnedError error)

type AttachVolumeResp

type AttachVolumeResp struct {
	Err error
}

func AttachVolume

func AttachVolume(
	ec2Client *ec2.Client,
	instanceID string,
	volumeID string,
	deviceName string,
) (resp AttachVolumeResp)

type CreateSnapshotForVolumeResp

type CreateSnapshotForVolumeResp struct {
	Err        error
	SnapshotID string
}

func CreateSnapshotForVolume

func CreateSnapshotForVolume(
	ec2Client *ec2.Client,
	name string,
	volumeID string,
) (resp CreateSnapshotForVolumeResp)

type CreateVolumeFromSnapshotResp

type CreateVolumeFromSnapshotResp struct {
	Err      error
	VolumeID string
}

func CreateVolumeFromSnapshot

func CreateVolumeFromSnapshot(
	ec2Client *ec2.Client,
	name string,
	availabilityZone string,
	snapshotID string,
) (resp CreateVolumeFromSnapshotResp)

type DetachVolumeResp

type DetachVolumeResp struct {
	Err error
}

func DetachVolume

func DetachVolume(
	ec2Client *ec2.Client,
	instanceID string,
	volumeID string,
	deviceName string,
) (resp DetachVolumeResp)

type DynamoDBRecodeConfigTableRecord

type DynamoDBRecodeConfigTableRecord struct {
	ID         string
	ConfigJSON string
}

type InitInstanceScriptResults

type InitInstanceScriptResults struct {
	ExitCode    string                      `json:"exit_code"`
	SSHHostKeys []entities.DevEnvSSHHostKey `json:"ssh_host_keys"`
}

func LookupInitInstanceScriptResults

func LookupInitInstanceScriptResults(
	ec2Client *ec2.Client,
	instancePublicIPAddress string,
	instanceSSHPort string,
	instanceLoginUser string,
	sshPrivateKeyContent string,
) (returnedInitScriptResults *InitInstanceScriptResults, returnedError error)

type Instance

type Instance struct {
	ID                string                     `json:"id"`
	Type              string                     `json:"type"`
	PublicIPAddress   string                     `json:"public_ip_address"`
	PublicHostname    string                     `json:"public_hostname"`
	Volumes           []InstanceVolume           `json:"volumes"`
	InitScriptResults *InitInstanceScriptResults `json:"init_script_results"`
}

func CreateInstance

func CreateInstance(
	ec2Client *ec2.Client,
	name string,
	AMIID string,
	rootDeviceName string,
	instanceType string,
	networkInterfaceID string,
	keyName string,
) (returnedInstance *Instance, returnedError error)

type InstanceTypeArch

type InstanceTypeArch string

type InstanceTypeInfos

type InstanceTypeInfos struct {
	Type string           `json:"type"`
	Arch InstanceTypeArch `json:"arch"`
}

func LookupInstanceTypeInfos

func LookupInstanceTypeInfos(
	ec2Client *ec2.Client,
	instanceType string,
) (returnedInstanceTypeInfos *InstanceTypeInfos, returnedError error)

type InstanceVolume

type InstanceVolume struct {
	ID           string `json:"id"`
	DeviceName   string `json:"device_name"`
	SnapshotID   string `json:"snapshot_id"`
	IsRootVolume bool   `json:"is_root_volume"`
}

type InternetGateway

type InternetGateway struct {
	ID              string `json:"id"`
	IsAttachedToVPC bool   `json:"is_attached_to_vpc"`
}

func CreateInternetGateway

func CreateInternetGateway(
	ec2Client *ec2.Client,
	name string,
) (returnedIG *InternetGateway, returnedError error)

type KeyPair

type KeyPair struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	PEMContent string `json:"pem_content"`
}

func CreateKeyPair

func CreateKeyPair(
	ec2Client *ec2.Client,
	keyPairName string,
) (returnedKeyPair *KeyPair, returnedError error)

type NetworkInterface

type NetworkInterface struct {
	ID string `json:"id"`
}

func CreateNetworkInterface

func CreateNetworkInterface(
	ec2Client *ec2.Client,
	name string,
	description string,
	subnetID string,
	securityGroupIDs []string,
) (returnedNetworkInterface *NetworkInterface, returnedError error)

type RawInitInstanceScriptResults

type RawInitInstanceScriptResults struct {
	ExitCode    string `json:"exit_code"`
	SSHHostKeys string `json:"ssh_host_keys"`
}

type RemoveVolumeResp

type RemoveVolumeResp struct {
	Err error
}

func RemoveVolume

func RemoveVolume(
	ec2Client *ec2.Client,
	volumeID string,
) (resp RemoveVolumeResp)

type RemoveVolumeSnapshotResp

type RemoveVolumeSnapshotResp struct {
	Err error
}

func RemoveVolumeSnapshot

func RemoveVolumeSnapshot(
	ec2Client *ec2.Client,
	snapshotID string,
) (resp RemoveVolumeSnapshotResp)

type Route

type Route struct{}

func CreateRoute

func CreateRoute(
	ec2Client *ec2.Client,
	internetGatewayID string,
	routeTableID string,
) (returnedRoute *Route, returnedError error)

type RouteTable

type RouteTable struct {
	ID                   string `json:"id"`
	IsAssociatedToSubnet bool   `json:"is_associated_to_subnet"`
}

func CreateRouteTable

func CreateRouteTable(
	ec2Client *ec2.Client,
	name string,
	VPCID string,
) (returnedRouteTable *RouteTable, returnedError error)

type SecurityGroup

type SecurityGroup struct {
	ID string `json:"id"`
}

func CreateSecurityGroup

func CreateSecurityGroup(
	ec2Client *ec2.Client,
	name string,
	description string,
	VPCID string,
	ingressPorts []types.IpPermission,
) (returnedSecurityGroup *SecurityGroup, returnedError error)

type StartInstanceResp

type StartInstanceResp struct {
	Err      error
	Instance types.Instance
}

type Subnet

type Subnet struct {
	ID               string `json:"id"`
	AvailabilityZone string `json:"availability_zone"`
}

func CreateSubnet

func CreateSubnet(
	ec2Client *ec2.Client,
	name string,
	cidrBlock string,
	VPCID string,
) (returnedSubnet *Subnet, returnedError error)

type VPC

type VPC struct {
	ID string `json:"id"`
}

func CreateVPC

func CreateVPC(
	ec2Client *ec2.Client,
	VPCName string,
	CIDRBlock string,
) (returnedVPC *VPC, returnedError error)

Jump to

Keyboard shortcuts

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