common

package
Version: v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MPL-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateFuncs = template.FuncMap{
	"clean_ami_name": templateCleanAMIName,
}

Functions

func DecodeAuthZMessages added in v1.3.1

func DecodeAuthZMessages(sess *session.Session)

DecodeAuthZMessages enables automatic decoding of any encoded authorization messages

func SSHHost added in v0.8.0

func SSHHost(e ec2Describer, sshInterface string) func(multistep.StateBag) (string, error)

SSHHost returns a function that can be given to the SSH communicator for determining the SSH address based on the instance DNS name.

func WaitForImageToBeImported added in v1.2.5

func WaitForImageToBeImported(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeImportImageTasksInput, opts ...request.WaiterOption) error

func WaitForVolumeToBeAttached added in v1.2.5

func WaitForVolumeToBeAttached(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeVolumesInput, opts ...request.WaiterOption) error

func WaitForVolumeToBeDetached added in v1.2.5

func WaitForVolumeToBeDetached(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeVolumesInput, opts ...request.WaiterOption) error

func WaitUntilAMIAvailable added in v1.2.5

func WaitUntilAMIAvailable(ctx aws.Context, conn *ec2.EC2, imageId string) error

func WaitUntilImageImported added in v1.2.5

func WaitUntilImageImported(ctx aws.Context, conn *ec2.EC2, taskID string) error

func WaitUntilInstanceTerminated added in v1.2.5

func WaitUntilInstanceTerminated(ctx aws.Context, conn *ec2.EC2, instanceId string) error

func WaitUntilSnapshotDone added in v1.2.5

func WaitUntilSnapshotDone(ctx aws.Context, conn *ec2.EC2, snapshotID string) error

func WaitUntilSpotRequestFulfilled added in v1.2.5

func WaitUntilSpotRequestFulfilled(ctx aws.Context, conn *ec2.EC2, spotRequestId string) error

This function works for both requesting and cancelling spot instances.

func WaitUntilVolumeAttached added in v1.2.5

func WaitUntilVolumeAttached(ctx aws.Context, conn *ec2.EC2, volumeId string) error

func WaitUntilVolumeAvailable added in v1.2.5

func WaitUntilVolumeAvailable(ctx aws.Context, conn *ec2.EC2, volumeId string) error

func WaitUntilVolumeDetached added in v1.2.5

func WaitUntilVolumeDetached(ctx aws.Context, conn *ec2.EC2, volumeId string) error

Types

type AMIBlockDevices added in v0.11.0

type AMIBlockDevices struct {
	AMIMappings []BlockDevice `mapstructure:"ami_block_device_mappings"`
}

func (*AMIBlockDevices) BuildAMIDevices added in v0.11.0

func (b *AMIBlockDevices) BuildAMIDevices() []*ec2.BlockDeviceMapping

type AMIConfig added in v0.3.0

type AMIConfig struct {
	AMIName                 string            `mapstructure:"ami_name"`
	AMIDescription          string            `mapstructure:"ami_description"`
	AMIVirtType             string            `mapstructure:"ami_virtualization_type"`
	AMIUsers                []string          `mapstructure:"ami_users"`
	AMIGroups               []string          `mapstructure:"ami_groups"`
	AMIProductCodes         []string          `mapstructure:"ami_product_codes"`
	AMIRegions              []string          `mapstructure:"ami_regions"`
	AMISkipRegionValidation bool              `mapstructure:"skip_region_validation"`
	AMITags                 TagMap            `mapstructure:"tags"`
	AMIENASupport           *bool             `mapstructure:"ena_support"`
	AMISriovNetSupport      bool              `mapstructure:"sriov_support"`
	AMIForceDeregister      bool              `mapstructure:"force_deregister"`
	AMIForceDeleteSnapshot  bool              `mapstructure:"force_delete_snapshot"`
	AMIEncryptBootVolume    bool              `mapstructure:"encrypt_boot"`
	AMIKmsKeyId             string            `mapstructure:"kms_key_id"`
	AMIRegionKMSKeyIDs      map[string]string `mapstructure:"region_kms_key_ids"`
	SnapshotTags            TagMap            `mapstructure:"snapshot_tags"`
	SnapshotUsers           []string          `mapstructure:"snapshot_users"`
	SnapshotGroups          []string          `mapstructure:"snapshot_groups"`
}

AMIConfig is for common configuration related to creating AMIs.

func (*AMIConfig) Prepare added in v0.3.0

func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context) []error

type AccessConfig

type AccessConfig struct {
	AccessKey            string `mapstructure:"access_key"`
	CustomEndpointEc2    string `mapstructure:"custom_endpoint_ec2"`
	DecodeAuthZMessages  bool   `mapstructure:"decode_authorization_messages"`
	MFACode              string `mapstructure:"mfa_code"`
	ProfileName          string `mapstructure:"profile"`
	RawRegion            string `mapstructure:"region"`
	SecretKey            string `mapstructure:"secret_key"`
	SkipValidation       bool   `mapstructure:"skip_region_validation"`
	SkipMetadataApiCheck bool   `mapstructure:"skip_metadata_api_check"`
	Token                string `mapstructure:"token"`
	// contains filtered or unexported fields
}

AccessConfig is for common configuration related to AWS access

func (*AccessConfig) IsChinaCloud added in v1.2.0

func (c *AccessConfig) IsChinaCloud() bool

func (*AccessConfig) IsGovCloud added in v1.2.0

func (c *AccessConfig) IsGovCloud() bool

func (*AccessConfig) NewEC2Connection added in v1.3.2

func (c *AccessConfig) NewEC2Connection() (ec2iface.EC2API, error)

func (*AccessConfig) Prepare

func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error

func (*AccessConfig) Session added in v1.0.1

func (c *AccessConfig) Session() (*session.Session, error)

Config returns a valid aws.Config object for access to AWS services, or an error if the authentication and region couldn't be resolved

func (*AccessConfig) SessionRegion added in v1.2.0

func (c *AccessConfig) SessionRegion() string

func (*AccessConfig) ValidateRegion added in v1.3.2

func (c *AccessConfig) ValidateRegion(regions ...string) error

ValidateRegion returns true if the supplied region is a valid AWS region and false if it's not.

type AmiFilterOptions added in v0.12.0

type AmiFilterOptions struct {
	Filters    map[*string]*string
	Owners     []*string
	MostRecent bool `mapstructure:"most_recent"`
}

func (*AmiFilterOptions) Empty added in v0.12.0

func (d *AmiFilterOptions) Empty() bool

func (*AmiFilterOptions) NoOwner added in v1.3.0

func (d *AmiFilterOptions) NoOwner() bool

type Artifact

type Artifact struct {
	// A map of regions to AMI IDs.
	Amis map[string]string

	// BuilderId is the unique ID for the builder that created this AMI
	BuilderIdValue string

	// EC2 connection for performing API stuff.
	Session *session.Session
}

Artifact is an artifact implementation that contains built AMIs.

func (*Artifact) BuilderId

func (a *Artifact) BuilderId() string

func (*Artifact) Destroy

func (a *Artifact) Destroy() error

func (*Artifact) Files

func (*Artifact) Files() []string

func (*Artifact) Id

func (a *Artifact) Id() string

func (*Artifact) State added in v0.7.2

func (a *Artifact) State(name string) interface{}

func (*Artifact) String

func (a *Artifact) String() string

type BlockDevice added in v0.3.2

type BlockDevice struct {
	DeleteOnTermination bool   `mapstructure:"delete_on_termination"`
	DeviceName          string `mapstructure:"device_name"`
	Encrypted           bool   `mapstructure:"encrypted"`
	IOPS                int64  `mapstructure:"iops"`
	NoDevice            bool   `mapstructure:"no_device"`
	SnapshotId          string `mapstructure:"snapshot_id"`
	VirtualName         string `mapstructure:"virtual_name"`
	VolumeType          string `mapstructure:"volume_type"`
	VolumeSize          int64  `mapstructure:"volume_size"`
	KmsKeyId            string `mapstructure:"kms_key_id"`
}

BlockDevice

func (*BlockDevice) Prepare added in v1.2.0

func (b *BlockDevice) Prepare(ctx *interpolate.Context) error

type BlockDevices added in v0.3.2

type BlockDevices struct {
	AMIBlockDevices    `mapstructure:",squash"`
	LaunchBlockDevices `mapstructure:",squash"`
}

func (*BlockDevices) Prepare added in v0.7.0

func (b *BlockDevices) Prepare(ctx *interpolate.Context) (errs []error)

type BuildInfoTemplate added in v0.12.3

type BuildInfoTemplate struct {
	BuildRegion   string
	SourceAMI     string
	SourceAMIName string
	SourceAMITags map[string]string
}

type EC2Tags added in v1.2.0

type EC2Tags []*ec2.Tag

func (EC2Tags) Report added in v1.2.0

func (t EC2Tags) Report(ui packer.Ui)

type LaunchBlockDevices added in v0.11.0

type LaunchBlockDevices struct {
	LaunchMappings []BlockDevice `mapstructure:"launch_block_device_mappings"`
}

func (*LaunchBlockDevices) BuildLaunchDevices added in v0.11.0

func (b *LaunchBlockDevices) BuildLaunchDevices() []*ec2.BlockDeviceMapping

type RunConfig

type RunConfig struct {
	AssociatePublicIpAddress          bool                       `mapstructure:"associate_public_ip_address"`
	AvailabilityZone                  string                     `mapstructure:"availability_zone"`
	BlockDurationMinutes              int64                      `mapstructure:"block_duration_minutes"`
	DisableStopInstance               bool                       `mapstructure:"disable_stop_instance"`
	EbsOptimized                      bool                       `mapstructure:"ebs_optimized"`
	EnableT2Unlimited                 bool                       `mapstructure:"enable_t2_unlimited"`
	IamInstanceProfile                string                     `mapstructure:"iam_instance_profile"`
	InstanceInitiatedShutdownBehavior string                     `mapstructure:"shutdown_behavior"`
	InstanceType                      string                     `mapstructure:"instance_type"`
	SecurityGroupFilter               SecurityGroupFilterOptions `mapstructure:"security_group_filter"`
	RunTags                           map[string]string          `mapstructure:"run_tags"`
	SecurityGroupId                   string                     `mapstructure:"security_group_id"`
	SecurityGroupIds                  []string                   `mapstructure:"security_group_ids"`
	SourceAmi                         string                     `mapstructure:"source_ami"`
	SourceAmiFilter                   AmiFilterOptions           `mapstructure:"source_ami_filter"`
	SpotPrice                         string                     `mapstructure:"spot_price"`
	SpotPriceAutoProduct              string                     `mapstructure:"spot_price_auto_product"`
	SpotTags                          map[string]string          `mapstructure:"spot_tags"`
	SubnetFilter                      SubnetFilterOptions        `mapstructure:"subnet_filter"`
	SubnetId                          string                     `mapstructure:"subnet_id"`
	TemporaryKeyPairName              string                     `mapstructure:"temporary_key_pair_name"`
	TemporarySGSourceCidr             string                     `mapstructure:"temporary_security_group_source_cidr"`
	UserData                          string                     `mapstructure:"user_data"`
	UserDataFile                      string                     `mapstructure:"user_data_file"`
	VpcFilter                         VpcFilterOptions           `mapstructure:"vpc_filter"`
	VpcId                             string                     `mapstructure:"vpc_id"`
	WindowsPasswordTimeout            time.Duration              `mapstructure:"windows_password_timeout"`

	// Communicator settings
	Comm communicator.Config `mapstructure:",squash"`
}

RunConfig contains configuration for running an instance from a source AMI and details on how to access that launched image.

func (*RunConfig) IsSpotInstance added in v1.1.3

func (c *RunConfig) IsSpotInstance() bool

func (*RunConfig) Prepare

func (c *RunConfig) Prepare(ctx *interpolate.Context) []error

type SecurityGroupFilterOptions added in v1.3.2

type SecurityGroupFilterOptions struct {
	Filters map[*string]*string
}

func (*SecurityGroupFilterOptions) Empty added in v1.3.2

func (d *SecurityGroupFilterOptions) Empty() bool

type StateChangeConf

type StateChangeConf struct {
	Pending   []string
	Refresh   StateRefreshFunc
	StepState multistep.StateBag
	Target    string
}

StateChangeConf is the configuration struct used for `WaitForState`.

type StateRefreshFunc added in v0.2.3

type StateRefreshFunc func() (result interface{}, state string, err error)

StateRefreshFunc is a function type used for StateChangeConf that is responsible for refreshing the item being watched for a state change.

It returns three results. `result` is any object that will be returned as the final object after waiting for state change. This allows you to return the final updated object, for example an EC2 instance after refreshing it.

`state` is the latest state of that object. And `err` is any error that may have happened while refreshing the state.

type StepAMIRegionCopy added in v0.3.5

type StepAMIRegionCopy struct {
	AccessConfig      *AccessConfig
	Regions           []string
	RegionKeyIds      map[string]string
	EncryptBootVolume bool
	Name              string
}

func (*StepAMIRegionCopy) Cleanup added in v0.3.5

func (s *StepAMIRegionCopy) Cleanup(state multistep.StateBag)

func (*StepAMIRegionCopy) Run added in v0.3.5

type StepCleanupVolumes added in v1.3.0

type StepCleanupVolumes struct {
	BlockDevices BlockDevices
}

stepCleanupVolumes cleans up any orphaned volumes that were not designated to remain after termination of the instance. These volumes are typically ones that are marked as "delete on terminate:false" in the source_ami of a build.

func (*StepCleanupVolumes) Cleanup added in v1.3.0

func (s *StepCleanupVolumes) Cleanup(state multistep.StateBag)

func (*StepCleanupVolumes) Run added in v1.3.0

type StepCreateEncryptedAMICopy added in v0.12.3

type StepCreateEncryptedAMICopy struct {
	KeyID             string
	EncryptBootVolume bool
	Name              string
	AMIMappings       []BlockDevice
	// contains filtered or unexported fields
}

func (*StepCreateEncryptedAMICopy) Cleanup added in v0.12.3

func (s *StepCreateEncryptedAMICopy) Cleanup(state multistep.StateBag)

func (*StepCreateEncryptedAMICopy) Run added in v0.12.3

type StepCreateTags added in v0.2.3

type StepCreateTags struct {
	Tags         TagMap
	SnapshotTags TagMap
	Ctx          interpolate.Context
}

func (*StepCreateTags) Cleanup added in v0.2.3

func (s *StepCreateTags) Cleanup(state multistep.StateBag)

func (*StepCreateTags) Run added in v0.2.3

type StepDeregisterAMI added in v0.8.0

type StepDeregisterAMI struct {
	AccessConfig        *AccessConfig
	ForceDeregister     bool
	ForceDeleteSnapshot bool
	AMIName             string
	Regions             []string
}

func (*StepDeregisterAMI) Cleanup added in v0.8.0

func (s *StepDeregisterAMI) Cleanup(state multistep.StateBag)

func (*StepDeregisterAMI) Run added in v0.8.0

type StepGetPassword added in v0.8.0

type StepGetPassword struct {
	Debug     bool
	Comm      *communicator.Config
	Timeout   time.Duration
	BuildName string
}

StepGetPassword reads the password from a Windows server and sets it on the WinRM config.

func (*StepGetPassword) Cleanup added in v0.8.0

func (s *StepGetPassword) Cleanup(multistep.StateBag)

func (*StepGetPassword) Run added in v0.8.0

type StepKeyPair

type StepKeyPair struct {
	Debug        bool
	Comm         *communicator.Config
	DebugKeyPath string
	// contains filtered or unexported fields
}

func (*StepKeyPair) Cleanup

func (s *StepKeyPair) Cleanup(state multistep.StateBag)

func (*StepKeyPair) Run

type StepModifyAMIAttributes added in v0.3.0

type StepModifyAMIAttributes struct {
	Users          []string
	Groups         []string
	SnapshotUsers  []string
	SnapshotGroups []string
	ProductCodes   []string
	Description    string
	Ctx            interpolate.Context
}

func (*StepModifyAMIAttributes) Cleanup added in v0.3.0

func (s *StepModifyAMIAttributes) Cleanup(state multistep.StateBag)

func (*StepModifyAMIAttributes) Run added in v0.3.0

type StepModifyEBSBackedInstance added in v0.12.0

type StepModifyEBSBackedInstance struct {
	EnableAMIENASupport      *bool
	EnableAMISriovNetSupport bool
}

func (*StepModifyEBSBackedInstance) Cleanup added in v0.12.0

func (*StepModifyEBSBackedInstance) Run added in v0.12.0

type StepNetworkInfo added in v1.3.2

type StepNetworkInfo struct {
	VpcId               string
	VpcFilter           VpcFilterOptions
	SubnetId            string
	SubnetFilter        SubnetFilterOptions
	AvailabilityZone    string
	SecurityGroupIds    []string
	SecurityGroupFilter SecurityGroupFilterOptions
}

StepNetworkInfo queries AWS for information about VPC's and Subnets that is used throughout the AMI creation process.

Produces (adding them to the state bag):

vpc_id string - the VPC ID
subnet_id string - the Subnet ID
availability_zone string - the AZ name

func (*StepNetworkInfo) Cleanup added in v1.3.2

func (s *StepNetworkInfo) Cleanup(multistep.StateBag)

func (*StepNetworkInfo) Run added in v1.3.2

type StepPreValidate added in v0.8.0

type StepPreValidate struct {
	DestAmiName     string
	ForceDeregister bool
}

StepPreValidate provides an opportunity to pre-validate any configuration for the build before actually doing any time consuming work

func (*StepPreValidate) Cleanup added in v0.8.0

func (s *StepPreValidate) Cleanup(multistep.StateBag)

func (*StepPreValidate) Run added in v0.8.0

type StepRunSourceInstance

type StepRunSourceInstance struct {
	AssociatePublicIpAddress          bool
	BlockDevices                      BlockDevices
	Comm                              *communicator.Config
	Ctx                               interpolate.Context
	Debug                             bool
	EbsOptimized                      bool
	EnableT2Unlimited                 bool
	ExpectedRootDevice                string
	IamInstanceProfile                string
	InstanceInitiatedShutdownBehavior string
	InstanceType                      string
	IsRestricted                      bool
	SourceAMI                         string
	Tags                              TagMap
	UserData                          string
	UserDataFile                      string
	VolumeTags                        TagMap
	// contains filtered or unexported fields
}

func (*StepRunSourceInstance) Cleanup

func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag)

func (*StepRunSourceInstance) Run

type StepRunSpotInstance added in v1.1.1

type StepRunSpotInstance struct {
	AssociatePublicIpAddress          bool
	BlockDevices                      BlockDevices
	BlockDurationMinutes              int64
	Debug                             bool
	Comm                              *communicator.Config
	EbsOptimized                      bool
	ExpectedRootDevice                string
	IamInstanceProfile                string
	InstanceInitiatedShutdownBehavior string
	InstanceType                      string
	SourceAMI                         string
	SpotPrice                         string
	SpotPriceProduct                  string
	SpotTags                          TagMap
	Tags                              TagMap
	VolumeTags                        TagMap
	UserData                          string
	UserDataFile                      string
	Ctx                               interpolate.Context
	// contains filtered or unexported fields
}

func (*StepRunSpotInstance) Cleanup added in v1.1.1

func (s *StepRunSpotInstance) Cleanup(state multistep.StateBag)

func (*StepRunSpotInstance) Run added in v1.1.1

type StepSecurityGroup

type StepSecurityGroup struct {
	CommConfig            *communicator.Config
	SecurityGroupFilter   SecurityGroupFilterOptions
	SecurityGroupIds      []string
	TemporarySGSourceCidr string
	// contains filtered or unexported fields
}

func (*StepSecurityGroup) Cleanup

func (s *StepSecurityGroup) Cleanup(state multistep.StateBag)

func (*StepSecurityGroup) Run

type StepSourceAMIInfo added in v0.6.1

type StepSourceAMIInfo struct {
	SourceAmi                string
	EnableAMISriovNetSupport bool
	EnableAMIENASupport      *bool
	AMIVirtType              string
	AmiFilters               AmiFilterOptions
}

StepSourceAMIInfo extracts critical information from the source AMI that is used throughout the AMI creation process.

Produces:

source_image *ec2.Image - the source AMI info

func (*StepSourceAMIInfo) Cleanup added in v0.6.1

func (s *StepSourceAMIInfo) Cleanup(multistep.StateBag)

func (*StepSourceAMIInfo) Run added in v0.6.1

type StepStopEBSBackedInstance added in v0.12.0

type StepStopEBSBackedInstance struct {
	Skip                bool
	DisableStopInstance bool
}

func (*StepStopEBSBackedInstance) Cleanup added in v0.12.0

func (*StepStopEBSBackedInstance) Run added in v0.12.0

type SubnetFilterOptions added in v1.3.2

type SubnetFilterOptions struct {
	Filters  map[*string]*string
	MostFree bool `mapstructure:"most_free"`
	Random   bool `mapstructure:"random"`
}

func (*SubnetFilterOptions) Empty added in v1.3.2

func (d *SubnetFilterOptions) Empty() bool

type TagMap added in v1.2.0

type TagMap map[string]string

func (TagMap) EC2Tags added in v1.2.0

func (t TagMap) EC2Tags(ctx interpolate.Context, region string, state multistep.StateBag) (EC2Tags, error)

func (TagMap) IsSet added in v1.2.0

func (t TagMap) IsSet() bool

type VpcFilterOptions added in v1.3.2

type VpcFilterOptions struct {
	Filters map[*string]*string
}

func (*VpcFilterOptions) Empty added in v1.3.2

func (d *VpcFilterOptions) Empty() bool

Jump to

Keyboard shortcuts

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