{"modulePath":"github.com/stackpointcloud/packer","version":"v0.10.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package common\n\n## Variables\n\n```go\nvar TemplateFuncs = template.FuncMap{\n\t\"clean_ami_name\": templateCleanAMIName,\n}\n```\n\n## Functions\n\n```go\nfunc GetInstanceMetaData(path string) (contents []byte, err error)\n```\n\n```go\nfunc SSHConfig(username string) func(multistep.StateBag) (*ssh.ClientConfig, error)\n```\nSSHConfig returns a function that can be used for the SSH communicator config for connecting to the instance created over SSH using the generated private key.\n\n```go\nfunc SSHHost(e *ec2.EC2, private bool) func(multistep.StateBag) (string, error)\n```\nSSHHost returns a function that can be given to the SSH communicator for determining the SSH address based on the instance DNS name.\n\n```go\nfunc TimeoutSeconds() (seconds int)\n```\nReturns 300 seconds (5 minutes) by default Some AWS operations, like copying an AMI to a distant region, take a very long time Allow user to override with AWS\\_TIMEOUT\\_SECONDS environment variable\n\n```go\nfunc ValidateRegion(region string) bool\n```\nValidateRegion returns true if the supplied region is a valid AWS region and false if it's not.\n\n```go\nfunc WaitForState(conf *StateChangeConf) (i interface{}, err error)\n```\nWaitForState watches an object and waits for it to achieve a certain state.\n\n## Types\n\n```go\ntype AMIConfig struct {\n\tAMIName               string            `mapstructure:\"ami_name\"`\n\tAMIDescription        string            `mapstructure:\"ami_description\"`\n\tAMIVirtType           string            `mapstructure:\"ami_virtualization_type\"`\n\tAMIUsers              []string          `mapstructure:\"ami_users\"`\n\tAMIGroups             []string          `mapstructure:\"ami_groups\"`\n\tAMIProductCodes       []string          `mapstructure:\"ami_product_codes\"`\n\tAMIRegions            []string          `mapstructure:\"ami_regions\"`\n\tAMITags               map[string]string `mapstructure:\"tags\"`\n\tAMIEnhancedNetworking bool              `mapstructure:\"enhanced_networking\"`\n\tAMIForceDeregister    bool              `mapstructure:\"force_deregister\"`\n}\n```\nAMIConfig is for common configuration related to creating AMIs.\n\n```go\nfunc (c *AMIConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype AccessConfig struct {\n\tAccessKey   string `mapstructure:\"access_key\"`\n\tSecretKey   string `mapstructure:\"secret_key\"`\n\tRawRegion   string `mapstructure:\"region\"`\n\tToken       string `mapstructure:\"token\"`\n\tProfileName string `mapstructure:\"profile\"`\n}\n```\nAccessConfig is for common configuration related to AWS access\n\n```go\nfunc (c *AccessConfig) Config() (*aws.Config, error)\n```\nConfig returns a valid aws.Config object for access to AWS services, or an error if the authentication and region couldn't be resolved\n\n```go\nfunc (c *AccessConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\nfunc (c *AccessConfig) Region() (string, error)\n```\nRegion returns the aws.Region object for access to AWS services, requesting the region from the instance metadata if possible.\n\n```go\ntype Artifact struct {\n\t// A map of regions to AMI IDs.\n\tAmis map[string]string\n\n\t// BuilderId is the unique ID for the builder that created this AMI\n\tBuilderIdValue string\n\n\t// EC2 connection for performing API stuff.\n\tConn *ec2.EC2\n}\n```\nArtifact is an artifact implementation that contains built AMIs.\n\n```go\nfunc (a *Artifact) BuilderId() string\n```\n\n```go\nfunc (a *Artifact) Destroy() error\n```\n\n```go\nfunc (*Artifact) Files() []string\n```\n\n```go\nfunc (a *Artifact) Id() string\n```\n\n```go\nfunc (a *Artifact) State(name string) interface{}\n```\n\n```go\nfunc (a *Artifact) String() string\n```\n\n```go\ntype BlockDevice struct {\n\tDeleteOnTermination bool   `mapstructure:\"delete_on_termination\"`\n\tDeviceName          string `mapstructure:\"device_name\"`\n\tEncrypted           bool   `mapstructure:\"encrypted\"`\n\tIOPS                int64  `mapstructure:\"iops\"`\n\tNoDevice            bool   `mapstructure:\"no_device\"`\n\tSnapshotId          string `mapstructure:\"snapshot_id\"`\n\tVirtualName         string `mapstructure:\"virtual_name\"`\n\tVolumeType          string `mapstructure:\"volume_type\"`\n\tVolumeSize          int64  `mapstructure:\"volume_size\"`\n}\n```\nBlockDevice\n\n```go\ntype BlockDevices struct {\n\tAMIMappings    []BlockDevice `mapstructure:\"ami_block_device_mappings\"`\n\tLaunchMappings []BlockDevice `mapstructure:\"launch_block_device_mappings\"`\n}\n```\n\n```go\nfunc (b *BlockDevices) BuildAMIDevices() []*ec2.BlockDeviceMapping\n```\n\n```go\nfunc (b *BlockDevices) BuildLaunchDevices() []*ec2.BlockDeviceMapping\n```\n\n```go\nfunc (b *BlockDevices) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype CLIConfig struct {\n\tProfileName   string\n\tSourceProfile string\n\n\tAssumeRoleInput   *sts.AssumeRoleInput\n\tSourceCredentials *credentials.Credentials\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewFromProfile(name string) (*CLIConfig, error)\n```\nReturn a new CLIConfig with stored profile settings\n\n```go\nfunc (c *CLIConfig) CredentialsFromProfile(conf *aws.Config) (*credentials.Credentials, error)\n```\nReturn AWS Credentials using current profile. Must supply source config.\n\n```go\nfunc (c *CLIConfig) Prepare(name string) error\n```\nSets params in the struct based on the file section\n\n```go\ntype RunConfig struct {\n\tAssociatePublicIpAddress bool              `mapstructure:\"associate_public_ip_address\"`\n\tAvailabilityZone         string            `mapstructure:\"availability_zone\"`\n\tEbsOptimized             bool              `mapstructure:\"ebs_optimized\"`\n\tIamInstanceProfile       string            `mapstructure:\"iam_instance_profile\"`\n\tInstanceType             string            `mapstructure:\"instance_type\"`\n\tRunTags                  map[string]string `mapstructure:\"run_tags\"`\n\tSourceAmi                string            `mapstructure:\"source_ami\"`\n\tSpotPrice                string            `mapstructure:\"spot_price\"`\n\tSpotPriceAutoProduct     string            `mapstructure:\"spot_price_auto_product\"`\n\tSecurityGroupId          string            `mapstructure:\"security_group_id\"`\n\tSecurityGroupIds         []string          `mapstructure:\"security_group_ids\"`\n\tSubnetId                 string            `mapstructure:\"subnet_id\"`\n\tTemporaryKeyPairName     string            `mapstructure:\"temporary_key_pair_name\"`\n\tUserData                 string            `mapstructure:\"user_data\"`\n\tUserDataFile             string            `mapstructure:\"user_data_file\"`\n\tWindowsPasswordTimeout   time.Duration     `mapstructure:\"windows_password_timeout\"`\n\tVpcId                    string            `mapstructure:\"vpc_id\"`\n\n\t// Communicator settings\n\tComm           communicator.Config `mapstructure:\",squash\"`\n\tSSHKeyPairName string              `mapstructure:\"ssh_keypair_name\"`\n\tSSHPrivateIp   bool                `mapstructure:\"ssh_private_ip\"`\n}\n```\nRunConfig contains configuration for running an instance from a source AMI and details on how to access that launched image.\n\n```go\nfunc (c *RunConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype StateChangeConf struct {\n\tPending   []string\n\tRefresh   StateRefreshFunc\n\tStepState multistep.StateBag\n\tTarget    string\n}\n```\nStateChangeConf is the configuration struct used for \\`WaitForState\\`.\n\n```go\ntype StateRefreshFunc func() (result interface{}, state string, err error)\n```\nStateRefreshFunc is a function type used for StateChangeConf that is responsible for refreshing the item being watched for a state change.\n\nIt 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.\n\n\\`state\\` is the latest state of that object. And \\`err\\` is any error that may have happened while refreshing the state.\n\n```go\nfunc AMIStateRefreshFunc(conn *ec2.EC2, imageId string) StateRefreshFunc\n```\nAMIStateRefreshFunc returns a StateRefreshFunc that is used to watch an AMI for state changes.\n\n```go\nfunc ImportImageRefreshFunc(conn *ec2.EC2, importTaskId string) StateRefreshFunc\n```\n\n```go\nfunc InstanceStateRefreshFunc(conn *ec2.EC2, instanceId string) StateRefreshFunc\n```\nInstanceStateRefreshFunc returns a StateRefreshFunc that is used to watch an EC2 instance.\n\n```go\nfunc SpotRequestStateRefreshFunc(conn *ec2.EC2, spotRequestId string) StateRefreshFunc\n```\nSpotRequestStateRefreshFunc returns a StateRefreshFunc that is used to watch a spot request for state changes.\n\n```go\ntype StepAMIRegionCopy struct {\n\tAccessConfig *AccessConfig\n\tRegions      []string\n\tName         string\n}\n```\n\n```go\nfunc (s *StepAMIRegionCopy) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepCreateTags struct {\n\tTags map[string]string\n}\n```\n\n```go\nfunc (s *StepCreateTags) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepDeregisterAMI struct {\n\tForceDeregister bool\n\tAMIName         string\n}\n```\n\n```go\nfunc (s *StepDeregisterAMI) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepDeregisterAMI) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepGetPassword struct {\n\tDebug   bool\n\tComm    *communicator.Config\n\tTimeout time.Duration\n}\n```\nStepGetPassword reads the password from a Windows server and sets it on the WinRM config.\n\n```go\nfunc (s *StepGetPassword) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepGetPassword) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepKeyPair struct {\n\tDebug                bool\n\tDebugKeyPath         string\n\tTemporaryKeyPairName string\n\tKeyPairName          string\n\tPrivateKeyFile       string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *StepKeyPair) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepModifyAMIAttributes struct {\n\tUsers        []string\n\tGroups       []string\n\tProductCodes []string\n\tDescription  string\n}\n```\n\n```go\nfunc (s *StepModifyAMIAttributes) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepModifyAMIAttributes) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepPreValidate struct {\n\tDestAmiName     string\n\tForceDeregister bool\n}\n```\nStepPreValidate provides an opportunity to pre-validate any configuration for the build before actually doing any time consuming work\n\n```go\nfunc (s *StepPreValidate) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepPreValidate) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepRunSourceInstance struct {\n\tAssociatePublicIpAddress bool\n\tAvailabilityZone         string\n\tBlockDevices             BlockDevices\n\tDebug                    bool\n\tEbsOptimized             bool\n\tExpectedRootDevice       string\n\tInstanceType             string\n\tIamInstanceProfile       string\n\tSourceAMI                string\n\tSpotPrice                string\n\tSpotPriceProduct         string\n\tSubnetId                 string\n\tTags                     map[string]string\n\tUserData                 string\n\tUserDataFile             string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *StepRunSourceInstance) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepSecurityGroup struct {\n\tCommConfig       *communicator.Config\n\tSecurityGroupIds []string\n\tVpcId            string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *StepSecurityGroup) Cleanup(state multistep.StateBag)\n```\n\n```go\nfunc (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepSourceAMIInfo struct {\n\tSourceAmi          string\n\tEnhancedNetworking bool\n}\n```\nStepSourceAMIInfo extracts critical information from the source AMI that is used throughout the AMI creation process.\n\nProduces:\n\n\tsource_image *ec2.Image - the source AMI info\n\n```go\nfunc (s *StepSourceAMIInfo) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepSourceAMIInfo) Run(state multistep.StateBag) multistep.StepAction\n```\n\n","path":"github.com/stackpointcloud/packer/builder/amazon/common","name":"common","synopsis":"","isRedistributable":true}
