aws

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInstanceNotFound = errors.New("instance not found")

ErrInstanceNotFound is returned when no matching EC2 instance exists.

Functions

func CommandArgsSSMTunneling

func CommandArgsSSMTunneling(instanceID string, localPort int) ([]string, error)

func CreateDevpodInstanceProfile

func CreateDevpodInstanceProfile(ctx context.Context, provider *AwsProvider) (string, error)

func CreateDevpodSecurityGroup

func CreateDevpodSecurityGroup(
	ctx context.Context,
	provider *AwsProvider,
	vpcID string,
) (string, error)

func Delete

func Delete(ctx context.Context, provider *AwsProvider, machine Machine) error

func DeleteDevpodRoute53Record

func DeleteDevpodRoute53Record(
	ctx context.Context,
	provider *AwsProvider,
	zone route53Zone,
	machine Machine,
) error

DeleteDevpodRoute53Record deletes a Route53 A record for the devsy hostname in the specified zone.

func Describe

func Describe(ctx context.Context, provider *AwsProvider, name string) (string, error)

func GetAMIRootDevice

func GetAMIRootDevice(ctx context.Context, cfg aws.Config, diskImage string) (string, error)

func GetDefaultAMI

func GetDefaultAMI(ctx context.Context, cfg aws.Config, instanceType string) (string, error)

func GetDevpodInstanceProfile

func GetDevpodInstanceProfile(ctx context.Context, provider *AwsProvider) (string, error)

func GetDevpodRoute53Zone

func GetDevpodRoute53Zone(ctx context.Context, provider *AwsProvider) (route53Zone, error)

GetDevpodRoute53Zone retrieves the Route53 zone for the devsy if applicable. A zone name can either be specified in the provider configuration or be detected by looking for a Route53 zone with a tag "devsy" with value "devsy".

func GetDevpodSecurityGroups

func GetDevpodSecurityGroups(
	ctx context.Context,
	provider *AwsProvider,
	vpcID string,
) ([]string, error)

func GetDevpodVPC

func GetDevpodVPC(ctx context.Context, provider *AwsProvider) (string, error)

func GetInjectKeypairScript

func GetInjectKeypairScript(config *options.Options) (string, error)

func GetInstance

func GetInstance(
	ctx context.Context,
	cfg aws.Config,
	name string,
	states []string,
) (types.Instance, error)

func GetInstanceTags

func GetInstanceTags(providerAws *AwsProvider, zone route53Zone) []types.TagSpecification

func GetSubnet

func GetSubnet(ctx context.Context, provider *AwsProvider) (subnetResult, error)

func NewAWSConfig

func NewAWSConfig(
	ctx context.Context,
	log log.Logger,
	options *options.Options,
) (aws.Config, error)

func Start

func Start(ctx context.Context, provider *AwsProvider, instanceID string) error

func Status

func Status(ctx context.Context, provider *AwsProvider, name string) (client.Status, error)

func Stop

func Stop(ctx context.Context, provider *AwsProvider, instanceID string) error

func UpsertDevpodRoute53Record

func UpsertDevpodRoute53Record(
	ctx context.Context,
	provider *AwsProvider,
	record route53Record,
) error

UpsertDevpodRoute53Record creates or updates a Route53 A record for the devsy hostname in the specified zone.

Types

type AwsProvider

type AwsProvider struct {
	Config           *options.Options
	AwsConfig        aws.Config
	Log              log.Logger
	WorkingDirectory string
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(ctx context.Context, withFolder bool, log log.Logger) (*AwsProvider, error)

type Machine

type Machine struct {
	Status                string
	InstanceID            string
	SpotInstanceRequestId string
	PublicIP              string
	PrivateIP             string
	Hostname              string
}

func Create

func Create(
	ctx context.Context,
	cfg aws.Config,
	providerAws *AwsProvider,
) (Machine, error)

func GetDevpodInstance

func GetDevpodInstance(
	ctx context.Context,
	cfg aws.Config,
	name string,
) (Machine, error)

func GetDevpodRunningInstance

func GetDevpodRunningInstance(
	ctx context.Context,
	cfg aws.Config,
	name string,
) (Machine, error)

func GetDevpodStoppedInstance

func GetDevpodStoppedInstance(
	ctx context.Context,
	cfg aws.Config,
	name string,
) (Machine, error)

func GetMachine

func GetMachine(
	ctx context.Context,
	cfg aws.Config,
	name string,
	states []string,
) (Machine, error)

func NewMachineFromInstance

func NewMachineFromInstance(instance types.Instance) Machine

NewMachineFromInstance creates a new Machine struct from an AWS ec2 Instance struct.

func (Machine) Host

func (m Machine) Host() string

type PolicyDocument

type PolicyDocument struct {
	Version   string            `json:"Version"`
	Statement []PolicyStatement `json:"Statement"`
}

PolicyDocument represents an IAM policy document.

func NewDevsyEC2Policy

func NewDevsyEC2Policy() PolicyDocument

NewDevsyEC2Policy returns the policy allowing EC2 instance to describe and stop itself.

func NewEC2AssumeRolePolicy

func NewEC2AssumeRolePolicy() PolicyDocument

NewEC2AssumeRolePolicy returns the trust policy for EC2 to assume the role.

func NewSSMKMSDecryptPolicy

func NewSSMKMSDecryptPolicy(kmsArn string) PolicyDocument

NewSSMKMSDecryptPolicy returns the policy allowing SSM to decrypt with the specified KMS key.

type PolicyPrincipal

type PolicyPrincipal struct {
	Service any `json:"Service,omitempty"` // string or []string
	AWS     any `json:"AWS,omitempty"`     // string or []string
}

PolicyPrincipal represents the principal in a policy statement.

type PolicyStatement

type PolicyStatement struct {
	Sid       string           `json:"Sid,omitempty"`
	Effect    string           `json:"Effect"`
	Principal *PolicyPrincipal `json:"Principal,omitempty"`
	Action    any              `json:"Action"`             // string or []string
	Resource  any              `json:"Resource,omitempty"` // string or []string
	Condition map[string]any   `json:"Condition,omitempty"`
}

PolicyStatement represents a statement in an IAM policy.

Jump to

Keyboard shortcuts

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