aws

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEnvPrefix           = "VMCLARITY_AWS"
	DefaultScannerInstanceType = "t2.large"
	DefaultBlockDeviceName     = "xvdh"
)
View Source
const (
	DefaultRetryAfter     = 5 * time.Second
	RetryServerErrorAfter = time.Minute

	InstanceReadynessAfter         = 5 * time.Minute
	SnapshotReadynessAfter         = 5 * time.Minute
	VolumeReadynessAfter           = 5 * time.Minute
	VolumeAttachmentReadynessAfter = 2 * time.Minute

	AWSUnauthorizedOperation = "UnauthorizedOperation"
)
View Source
const (
	EC2TagKeyOwner         = "Owner"
	EC2TagKeyName          = "Name"
	EC2TagValueNamePattern = "vmclarity-scanner-%s"
	EC2TagValueOwner       = "VMClarity"
	EC2TagKeyScanID        = "VMClarity.ScanID"
	EC2TagKeyAssetScanID   = "VMClarity.AssetScanID"
	EC2TagKeyAssetID       = "VMClarity.AssetID"
	EC2TagKeyAssetVolumeID = "VMClarity.AssetVolumeID"

	EC2SnapshotDescription = "Volume snapshot created by VMClarity for scanning"
)
View Source
const (
	VpcIDFilterName           = "vpc-id"
	SecurityGroupIDFilterName = "instance.group-id"
	InstanceStateFilterName   = "instance-state-name"
	SnapshotIDFilterName      = "snapshot-id"
)
View Source
const LocationSeparator = "/"

Variables

This section is empty.

Functions

func EC2FiltersFromEC2Tags

func EC2FiltersFromEC2Tags(tags []ec2types.Tag) []ec2types.Filter

func EC2FiltersFromTags

func EC2FiltersFromTags(tags []models.Tag) []ec2types.Filter

func EC2TagsFromScanMetadata

func EC2TagsFromScanMetadata(meta provider.ScanMetadata) []ec2types.Tag

func WrapError

func WrapError(err error) error

Types

type Config

type Config struct {
	// Region where the Scanner instance needs to be created
	ScannerRegion string `mapstructure:"scanner_region"`
	// SubnetID where the Scanner instance needs to be created
	SubnetID string `mapstructure:"subnet_id"`
	// SecurityGroupID which needs to be attached to the Scanner instance
	SecurityGroupID string `mapstructure:"security_group_id"`
	// KeyPairName is the name of the SSH KeyPair to use for Scanner instance launch
	KeyPairName string `mapstructure:"keypair_name"`
	// ScannerImage is the AMI image used for creating Scanner instance
	ScannerImage string `mapstructure:"scanner_ami_id"`
	// ScannerInstanceType is the instance type used for Scanner instance
	ScannerInstanceType string `mapstructure:"scanner_instance_type"`
	// BlockDeviceName contains the block device name used for attaching Scanner volume to the Scanner instance
	BlockDeviceName string `mapstructure:"block_device_name"`
}

func NewConfig

func NewConfig() (*Config, error)

func (*Config) Validate

func (c *Config) Validate() error

type FatalError

type FatalError = provider.FatalError

type Instance

type Instance struct {
	ID                  string
	Region              string
	VpcID               string
	SecurityGroups      []models.SecurityGroup
	AvailabilityZone    string
	Image               string
	InstanceType        string
	Platform            string
	Tags                []models.Tag
	LaunchTime          time.Time
	RootDeviceName      string
	RootVolumeSizeGB    int32
	RootVolumeEncrypted models.RootVolumeEncrypted
	Volumes             []Volume

	Metadata provider.ScanMetadata
	// contains filtered or unexported fields
}

func (*Instance) AttachVolume

func (i *Instance) AttachVolume(ctx context.Context, volume *Volume, deviceName string) error

nolint:cyclop

func (*Instance) Delete

func (i *Instance) Delete(ctx context.Context) error

func (*Instance) IsReady

func (i *Instance) IsReady(ctx context.Context) (bool, error)

func (*Instance) Location

func (i *Instance) Location() string

func (*Instance) RootVolume

func (i *Instance) RootVolume() *Volume

type Location

type Location struct {
	Region string
	Vpc    string
}

func NewLocation

func NewLocation(l string) (*Location, error)

NOTE: pattern <region>/<vpc>.

func (Location) String

func (l Location) String() string

type Provider

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

func New

func New(ctx context.Context) (*Provider, error)

func (*Provider) DiscoverAssets

func (p *Provider) DiscoverAssets(ctx context.Context) provider.AssetDiscoverer

nolint:cyclop

func (*Provider) Estimate

func (p *Provider) Estimate(ctx context.Context, assetScanStats models.AssetScanStats, asset *models.Asset, assetScanTemplate *models.AssetScanTemplate) (*models.Estimation, error)

func (*Provider) GetInstances

func (p *Provider) GetInstances(ctx context.Context, filters []ec2types.Filter, regionID string) ([]Instance, error)

func (*Provider) Kind

func (p *Provider) Kind() models.CloudProvider

func (*Provider) ListAllRegions

func (p *Provider) ListAllRegions(ctx context.Context) ([]Region, error)

func (*Provider) RemoveAssetScan

func (p *Provider) RemoveAssetScan(ctx context.Context, config *provider.ScanJobConfig) error

RemoveAssetScan removes all the cloud resources associated with a Scan defined by config parameter. The operation is idempotent, therefore it is safe to call it multiple times. nolint:cyclop,gocognit

func (*Provider) RunAssetScan

func (p *Provider) RunAssetScan(ctx context.Context, config *provider.ScanJobConfig) error

nolint:cyclop,gocognit,maintidx

type Region

type Region struct {
	Name string
	VPCs []VPC
}

type RetryableError

type RetryableError = provider.RetryableError

type ScanScope

type ScanScope struct {
	AllRegions  bool
	Regions     []Region
	ScanStopped bool
	// Only assets that have these tags will be selected for scanning within the selected scan scope.
	// Multiple tags will be treated as an AND operator.
	TagSelector []models.Tag
	// Assets that have these tags will be excluded from the scan, even if they match the tag selector.
	// Multiple tags will be treated as an AND operator.
	ExcludeTags []models.Tag
}

type Snapshot

type Snapshot struct {
	ID       string
	Region   string
	Metadata provider.ScanMetadata
	VolumeID string
	// contains filtered or unexported fields
}

func (*Snapshot) Copy

func (s *Snapshot) Copy(ctx context.Context, region string) (*Snapshot, error)

func (*Snapshot) CreateVolume

func (s *Snapshot) CreateVolume(ctx context.Context, az string) (*Volume, error)

func (*Snapshot) Delete

func (s *Snapshot) Delete(ctx context.Context) error

func (*Snapshot) IsReady

func (s *Snapshot) IsReady(ctx context.Context) (bool, error)

type VPC

type VPC struct {
	ID             string
	SecurityGroups []models.SecurityGroup
}

type Volume

type Volume struct {
	ID     string
	Region string

	BlockDeviceName string
	Metadata        provider.ScanMetadata
	// contains filtered or unexported fields
}

func (*Volume) CreateSnapshot

func (v *Volume) CreateSnapshot(ctx context.Context) (*Snapshot, error)

func (*Volume) Delete

func (v *Volume) Delete(ctx context.Context) error

func (*Volume) IsAttached

func (v *Volume) IsAttached(ctx context.Context) (bool, error)

func (*Volume) IsReady

func (v *Volume) IsReady(ctx context.Context) (bool, error)

func (*Volume) WaitForReady

func (v *Volume) WaitForReady(ctx context.Context, timeout time.Duration, interval time.Duration) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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