awsprovider

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourcePollingInterval = 10 * time.Second
	UpdateQueueSize         = 100
	DefaultStackTimeout     = 30 * time.Minute
	TestStackTimeout        = 30 * time.Second
)
View Source
const (
	EC2InstanceType  = "EC2"
	SpotInstanceType = "Spot"
)

Variables

View Source
var NewCloudFormationClientFunc = func(cfg aws.Config) aws_interface.CloudFormationAPIer {
	return cloudformation.NewFromConfig(cfg)
}

Functions

func CreateSpotInstancesInRegion

func CreateSpotInstancesInRegion(
	ctx context.Context,
	region string,
	orchestrators []string,
	token string,
	instancesPerRegion int,
	config SpotInstanceConfig,
) ([]string, error)

CreateSpotInstancesInRegion creates spot instances in the specified AWS region

func EnsureBootstrapped added in v0.0.20

func EnsureBootstrapped(env BootstrapEnvironment) error

EnsureBootstrapped ensures the environment is bootstrapped

func GetAllStatuses

func GetAllStatuses() map[string]*models.DisplayStatus

GetAllStatuses retrieves all statuses from the allStatuses map

func LoadAWSConfig

func LoadAWSConfig(ctx context.Context, region string) (aws.Config, error)

LoadAWSConfig loads the AWS configuration for the specified region

func NewEC2Client

func NewEC2Client(ctx context.Context) (awsinterfaces.EC2Clienter, error)

NewEC2Client creates a new EC2 client

func NewVpcStack added in v0.0.20

func NewVpcStack(scope constructs.Construct, id string, props *awscdk.StackProps) awscdk.Stack

func UpdateAllStatuses

func UpdateAllStatuses(status *models.DisplayStatus)

UpdateAllStatuses updates the global allStatuses map in a thread-safe manner

Types

type AWSProvider

type AWSProvider struct {
	AccountID       string
	Config          *aws.Config
	Region          string
	ClusterDeployer common_interface.ClusterDeployerer
	UpdateQueue     chan display.UpdateAction
	App             awscdk.App
	Stack           awscdk.Stack
	VPC             awsec2.IVpc

	EC2Client aws_interface.EC2Clienter
	// contains filtered or unexported fields
}

func NewAWSProvider

func NewAWSProvider(accountID, region string) (*AWSProvider, error)

func (*AWSProvider) BootstrapEnvironment added in v0.0.20

func (p *AWSProvider) BootstrapEnvironment(ctx context.Context) error

func (*AWSProvider) CreateInfrastructure added in v0.0.20

func (p *AWSProvider) CreateInfrastructure(ctx context.Context) error

func (*AWSProvider) Destroy added in v0.0.20

func (p *AWSProvider) Destroy(ctx context.Context) error

Destroy modification to clean up bootstrap resources

func (*AWSProvider) DestroyResources

func (p *AWSProvider) DestroyResources(ctx context.Context, vpcID string) error

DestroyResources deletes the specified AWS VPC and associated resources

func (*AWSProvider) FinalizeDeployment added in v0.0.20

func (p *AWSProvider) FinalizeDeployment(ctx context.Context) error

func (*AWSProvider) GetAllAWSRegions

func (p *AWSProvider) GetAllAWSRegions(ctx context.Context) ([]string, error)

func (*AWSProvider) GetClusterDeployer added in v0.0.20

func (p *AWSProvider) GetClusterDeployer() common_interface.ClusterDeployerer

func (*AWSProvider) GetVMExternalIP added in v0.0.20

func (p *AWSProvider) GetVMExternalIP(ctx context.Context, instanceID string) (string, error)

func (*AWSProvider) ListDeployments

func (p *AWSProvider) ListDeployments(ctx context.Context) ([]string, error)

func (*AWSProvider) PrepareDeployment added in v0.0.20

func (p *AWSProvider) PrepareDeployment(ctx context.Context) (*models.Deployment, error)

func (*AWSProvider) PrintDiagnostics added in v0.0.20

func (p *AWSProvider) PrintDiagnostics(ctx context.Context) error

func (*AWSProvider) ProcessMachinesConfig added in v0.0.20

func (p *AWSProvider) ProcessMachinesConfig(
	ctx context.Context,
) (map[string]models.Machiner, map[string]bool, error)

This updates m.Deployment with machines and returns an error if any

func (*AWSProvider) ProvisionBacalhauCluster added in v0.0.20

func (p *AWSProvider) ProvisionBacalhauCluster(ctx context.Context) error

func (*AWSProvider) SetClusterDeployer added in v0.0.20

func (p *AWSProvider) SetClusterDeployer(deployer common_interface.ClusterDeployerer)

func (*AWSProvider) SetEC2Client

func (p *AWSProvider) SetEC2Client(client aws_interface.EC2Clienter)

func (*AWSProvider) StartResourcePolling added in v0.0.20

func (p *AWSProvider) StartResourcePolling(ctx context.Context) error

func (*AWSProvider) TerminateDeployment added in v0.0.20

func (p *AWSProvider) TerminateDeployment(ctx context.Context) error

func (*AWSProvider) ToCloudFormationTemplate added in v0.0.20

func (p *AWSProvider) ToCloudFormationTemplate(
	ctx context.Context,
	stackName string,
) (map[string]interface{}, error)

func (*AWSProvider) ValidateMachineType added in v0.0.20

func (p *AWSProvider) ValidateMachineType(
	ctx context.Context,
	location, instanceType string,
) (bool, error)

type BootstrapEnvironment added in v0.0.20

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

BootstrapEnvironment represents the environment to bootstrap

type BootstrapStack added in v0.0.20

type BootstrapStack struct {
	awscdk.Stack
	// contains filtered or unexported fields
}

BootstrapStack defines the bootstrap stack

func NewBootstrapStack added in v0.0.20

func NewBootstrapStack(
	scope constructs.Construct,
	id string,
	qualifier string,
	props *awscdk.StackProps,
) *BootstrapStack

type EC2Clienter

type EC2Clienter interface {
	DescribeImages(
		ctx context.Context,
		params *ec2.DescribeImagesInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DescribeImagesOutput, error)
	CreateVpc(
		ctx context.Context,
		params *ec2.CreateVpcInput,
		optFns ...func(*ec2.Options),
	) (*ec2.CreateVpcOutput, error)
	CreateSubnet(
		ctx context.Context,
		params *ec2.CreateSubnetInput,
		optFns ...func(*ec2.Options),
	) (*ec2.CreateSubnetOutput, error)
	//CreateSecurityGroup(ctx context.Context, params *ec2.CreateSecurityGroupInput, optFns ...func(*ec2.Options)) (*ec2.CreateSecurityGroupOutput, error)
	//AuthorizeSecurityGroupIngress(ctx context.Context, params *ec2.AuthorizeSecurityGroupIngressInput, optFns ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupIngressOutput, error)
	RunInstances(
		ctx context.Context,
		params *ec2.RunInstancesInput,
		optFns ...func(*ec2.Options),
	) (*ec2.RunInstancesOutput, error)
	DescribeInstances(
		ctx context.Context,
		params *ec2.DescribeInstancesInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DescribeInstancesOutput, error)
	DescribeVpcs(
		ctx context.Context,
		params *ec2.DescribeVpcsInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DescribeVpcsOutput, error)
	DescribeSubnets(
		ctx context.Context,
		params *ec2.DescribeSubnetsInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DescribeSubnetsOutput, error)
	DescribeSecurityGroups(
		ctx context.Context,
		params *ec2.DescribeSecurityGroupsInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DescribeSecurityGroupsOutput, error)
	TerminateInstances(
		ctx context.Context,
		params *ec2.TerminateInstancesInput,
		optFns ...func(*ec2.Options),
	) (*ec2.TerminateInstancesOutput, error)
	DeleteSecurityGroup(
		ctx context.Context,
		params *ec2.DeleteSecurityGroupInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DeleteSecurityGroupOutput, error)
	DeleteSubnet(
		ctx context.Context,
		params *ec2.DeleteSubnetInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DeleteSubnetOutput, error)
	DeleteVpc(
		ctx context.Context,
		params *ec2.DeleteVpcInput,
		optFns ...func(*ec2.Options),
	) (*ec2.DeleteVpcOutput, error)
}

type LiveEC2Client added in v0.0.20

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

func (*LiveEC2Client) AssociateRouteTable added in v0.0.20

func (c *LiveEC2Client) AssociateRouteTable(
	ctx context.Context,
	input *ec2.AssociateRouteTableInput,
	options ...func(*ec2.Options),
) (*ec2.AssociateRouteTableOutput, error)

AssociateRouteTable associates a subnet with a route table

func (*LiveEC2Client) AttachInternetGateway added in v0.0.20

func (c *LiveEC2Client) AttachInternetGateway(
	ctx context.Context,
	input *ec2.AttachInternetGatewayInput,
	options ...func(*ec2.Options),
) (*ec2.AttachInternetGatewayOutput, error)

AttachInternetGateway attaches an Internet Gateway to a VPC

func (*LiveEC2Client) CreateEC2Instance added in v0.0.20

func (c *LiveEC2Client) CreateEC2Instance(
	ctx context.Context,
	input *ec2.RunInstancesInput,
	options ...func(*ec2.Options),
) (*ec2.RunInstancesOutput, error)

CreateEC2Instance creates a new EC2 instance

func (*LiveEC2Client) CreateInternetGateway added in v0.0.20

func (c *LiveEC2Client) CreateInternetGateway(
	ctx context.Context,
	input *ec2.CreateInternetGatewayInput,
	options ...func(*ec2.Options),
) (*ec2.CreateInternetGatewayOutput, error)

CreateInternetGateway creates a new Internet Gateway

func (*LiveEC2Client) CreateRoute added in v0.0.20

func (c *LiveEC2Client) CreateRoute(
	ctx context.Context,
	input *ec2.CreateRouteInput,
	options ...func(*ec2.Options),
) (*ec2.CreateRouteOutput, error)

CreateRoute creates a new route in a route table

func (*LiveEC2Client) CreateRouteTable added in v0.0.20

func (c *LiveEC2Client) CreateRouteTable(
	ctx context.Context,
	input *ec2.CreateRouteTableInput,
	options ...func(*ec2.Options),
) (*ec2.CreateRouteTableOutput, error)

CreateRouteTable creates a new route table

func (*LiveEC2Client) CreateSubnet added in v0.0.20

func (c *LiveEC2Client) CreateSubnet(
	ctx context.Context,
	input *ec2.CreateSubnetInput,
	options ...func(*ec2.Options),
) (*ec2.CreateSubnetOutput, error)

CreateSubnet creates a new subnet in a VPC

func (*LiveEC2Client) CreateVPC added in v0.0.20

func (c *LiveEC2Client) CreateVPC(
	ctx context.Context,
	input *ec2.CreateVpcInput,
	options ...func(*ec2.Options),
) (*ec2.CreateVpcOutput, error)

CreateVPC creates a new VPC

func (*LiveEC2Client) DescribeImages added in v0.0.20

func (c *LiveEC2Client) DescribeImages(
	ctx context.Context,
	input *ec2.DescribeImagesInput,
	options ...func(*ec2.Options),
) (*ec2.DescribeImagesOutput, error)

DescribeImages describes images

func (*LiveEC2Client) DescribeInstances added in v0.0.20

func (c *LiveEC2Client) DescribeInstances(
	ctx context.Context,
	input *ec2.DescribeInstancesInput,
	options ...func(*ec2.Options),
) (*ec2.DescribeInstancesOutput, error)

DescribeEC2Instances describes EC2 instances

func (*LiveEC2Client) DescribeVPCs added in v0.0.20

func (c *LiveEC2Client) DescribeVPCs(
	ctx context.Context,
	input *ec2.DescribeVpcsInput,
	options ...func(*ec2.Options),
) (*ec2.DescribeVpcsOutput, error)

DescribeVPCs describes VPCs

func (*LiveEC2Client) RunInstances added in v0.0.20

func (c *LiveEC2Client) RunInstances(
	ctx context.Context,
	input *ec2.RunInstancesInput,
	options ...func(*ec2.Options),
) (*ec2.RunInstancesOutput, error)

func (*LiveEC2Client) TerminateInstances added in v0.0.20

func (c *LiveEC2Client) TerminateInstances(
	ctx context.Context,
	input *ec2.TerminateInstancesInput,
	options ...func(*ec2.Options),
) (*ec2.TerminateInstancesOutput, error)

TerminateInstances terminates EC2 instances

type ResourceInfo

type ResourceInfo struct {
	ID         string
	Type       string
	Region     string
	Zone       string
	Status     string
	InstanceID string
	PublicIP   string
	PrivateIP  string
}

Status represents the status of an instance

type SpotInstanceConfig

type SpotInstanceConfig struct {
	KeyPairName  string
	InstanceType string
	VPCCIDRBlock string
	VPCTagKey    string
	VPCTagValue  string
}

SpotInstanceConfig holds the configuration for creating spot instances

type Status

type Status struct {
	ID string
	ResourceInfo
}

Jump to

Keyboard shortcuts

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