Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPublicIp() (net.IP, error)
- func DecodeAuthZMessages(sess *session.Session)
- func DestroyAMIs(imageids []*string, ec2conn *ec2.EC2) error
- func GetGeneratedDataList() []string
- func GetRegionConn(config *AccessConfig, target string) (ec2iface.EC2API, error)
- func IsValidBootMode(bootmode string) error
- func Port(sshInterface string, port int) func(multistep.StateBag) (int, error)
- func SSHHost(e ec2Describer, sshInterface string, host string) func(multistep.StateBag) (string, error)
- func ValidateKmsKey(kmsKey string) (valid bool)
- func WaitForImageToBeImported(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeImportImageTasksInput, ...) error
- func WaitForVolumeToBeAttached(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeVolumesInput, ...) error
- func WaitForVolumeToBeDetached(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeVolumesInput, ...) error
- func WaitUntilFastLaunchEnabled(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeFastLaunchImagesInput, ...) error
- type AMIConfig
- type AWSPollingConfig
- func (*AWSPollingConfig) FlatMapstructure() interface{ ... }
- func (w *AWSPollingConfig) LogEnvOverrideWarnings()
- func (w *AWSPollingConfig) WaitUntilAMIAvailable(ctx aws.Context, conn ec2iface.EC2API, imageId string) error
- func (w *AWSPollingConfig) WaitUntilFastLaunchEnabled(ctx aws.Context, conn *ec2.EC2, imageID string) error
- func (w *AWSPollingConfig) WaitUntilImageImported(ctx aws.Context, conn *ec2.EC2, taskID string) error
- func (w *AWSPollingConfig) WaitUntilInstanceRunning(ctx aws.Context, conn ec2iface.EC2API, instanceId string) error
- func (w *AWSPollingConfig) WaitUntilInstanceTerminated(ctx aws.Context, conn *ec2.EC2, instanceId string) error
- func (w *AWSPollingConfig) WaitUntilSnapshotDone(ctx aws.Context, conn ec2iface.EC2API, snapshotID string) error
- func (w *AWSPollingConfig) WaitUntilSpotRequestFulfilled(ctx aws.Context, conn *ec2.EC2, spotRequestId string) error
- func (w *AWSPollingConfig) WaitUntilVolumeAttached(ctx aws.Context, conn *ec2.EC2, volumeId string) error
- func (w *AWSPollingConfig) WaitUntilVolumeAvailable(ctx aws.Context, conn *ec2.EC2, volumeId string) error
- func (w *AWSPollingConfig) WaitUntilVolumeDetached(ctx aws.Context, conn *ec2.EC2, volumeId string) error
- type AccessConfig
- func (c *AccessConfig) GetCredentials(config *aws.Config) (*awsCredentials.Credentials, error)
- func (c *AccessConfig) GetCredsFromVault() error
- func (c *AccessConfig) IsChinaCloud() bool
- func (c *AccessConfig) IsGovCloud() bool
- func (c *AccessConfig) NewEC2Connection() (ec2iface.EC2API, error)
- func (c *AccessConfig) NewNoValidCredentialSourcesError(err error) error
- func (c *AccessConfig) Prepare(packerConfig *common.PackerConfig) []error
- func (c *AccessConfig) Session() (*session.Session, error)
- func (c *AccessConfig) SessionRegion() string
- func (c *AccessConfig) ValidateRegion(regions ...string) error
- type AmiFilterOptions
- func (d *AmiFilterOptions) Empty() bool
- func (*AmiFilterOptions) FlatMapstructure() interface{ ... }
- func (d *AmiFilterOptions) GetFilteredImage(params *ec2.DescribeImagesInput, ec2conn *ec2.EC2) (*ec2.Image, error)
- func (d *AmiFilterOptions) GetOwners() []*string
- func (d *AmiFilterOptions) NoOwner() bool
- type Artifact
- type AssumeRoleConfig
- type BlockDevice
- type BlockDevices
- type BuildInfoTemplate
- type DeregistrationProtectionOptions
- type EC2BlockDeviceMappingsBuilder
- type EC2Tags
- type FlatAWSPollingConfig
- type FlatAmiFilterOptions
- type FlatAssumeRoleConfig
- type FlatBlockDevice
- type FlatDeregistrationProtectionOptions
- type FlatLicenseConfigurationRequest
- type FlatLicenseSpecification
- type FlatMetadataOptions
- type FlatPlacement
- type FlatPolicyDocument
- type FlatSecurityGroupFilterOptions
- type FlatStatement
- type FlatSubnetFilterOptions
- type FlatVaultAWSEngineOptions
- type FlatVpcFilterOptions
- type LicenseConfigurationRequest
- type LicenseSpecification
- type MetadataOptions
- type Placement
- type PolicyDocument
- type RunConfig
- type SecurityGroupFilterOptions
- type SnapshotConfig
- type StateChangeConf
- type StateRefreshFunc
- type Statement
- type StepAMIRegionCopy
- type StepCleanupVolumes
- type StepCreateSSMTunnel
- func (s *StepCreateSSMTunnel) Cleanup(state multistep.StateBag)
- func (s *StepCreateSSMTunnel) ConfigureLocalHostPort(ctx context.Context) error
- func (s *StepCreateSSMTunnel) CreatePersistentSSMSession(ctx context.Context, ui packersdk.Ui, session *pssm.Session, ...)
- func (s *StepCreateSSMTunnel) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
- type StepCreateTags
- type StepDeregisterAMI
- type StepEnableDeprecation
- type StepEnableDeregistrationProtection
- type StepGetPassword
- type StepIamInstanceProfile
- type StepKeyPair
- type StepModifyAMIAttributes
- type StepModifyEBSBackedInstance
- type StepNetworkInfo
- type StepPreValidate
- type StepRunSourceInstance
- type StepRunSpotInstance
- func (s *StepRunSpotInstance) Cleanup(state multistep.StateBag)
- func (s *StepRunSpotInstance) CreateTemplateData(userData *string, az string, state multistep.StateBag, ...) *ec2.RequestLaunchTemplateData
- func (s *StepRunSpotInstance) LoadUserData() (string, error)
- func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
- type StepSecurityGroup
- type StepSetGeneratedData
- type StepSourceAMIInfo
- type StepStopEBSBackedInstance
- type SubnetFilterOptions
- type TagMap
- type VaultAWSEngineOptions
- type VpcFilterOptions
Constants ¶
const ( // https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreditSpecificationRequest.html#API_CreditSpecificationRequest_Contents CPUCreditsStandard = "standard" CPUCreditsUnlimited = "unlimited" )
Variables ¶
var TemplateFuncs = template.FuncMap{
"clean_resource_name": templateCleanAMIName,
}
Functions ¶
func CheckPublicIp ¶ added in v1.1.4
Returns the current host's public IP as returned from https://checkip.amazonaws.com
func DecodeAuthZMessages ¶
DecodeAuthZMessages enables automatic decoding of any encoded authorization messages
func DestroyAMIs ¶
DestroyAMIs deregisters the AWS machine images in imageids from an active AWS account
func GetGeneratedDataList ¶
func GetGeneratedDataList() []string
func GetRegionConn ¶ added in v1.1.4
func GetRegionConn(config *AccessConfig, target string) (ec2iface.EC2API, error)
func IsValidBootMode ¶ added in v1.2.2
IsValidBootMode checks that the bootmode is a value supported by AWS
func Port ¶
Port returns a function that can be given to the communicator for determining the port to use when connecting to an instance.
func SSHHost ¶
func SSHHost(e ec2Describer, sshInterface string, host 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 ¶
func WaitForImageToBeImported(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeImportImageTasksInput, opts ...request.WaiterOption) error
func WaitForVolumeToBeAttached ¶
func WaitForVolumeToBeAttached(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeVolumesInput, opts ...request.WaiterOption) error
func WaitForVolumeToBeDetached ¶
func WaitForVolumeToBeDetached(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeVolumesInput, opts ...request.WaiterOption) error
func WaitUntilFastLaunchEnabled ¶ added in v1.2.2
func WaitUntilFastLaunchEnabled(c *ec2.EC2, ctx aws.Context, input *ec2.DescribeFastLaunchImagesInput, opts ...request.WaiterOption) error
Types ¶
type AMIConfig ¶
type AMIConfig struct { // The name of the resulting AMI that will appear when managing AMIs in the // AWS console or via APIs. This must be unique. To help make this unique, // use a function like timestamp (see [template // engine](/packer/docs/templates/legacy_json_templates/engine) for more info). AMIName string `mapstructure:"ami_name" required:"true"` // The description to set for the resulting // AMI(s). By default this description is empty. This is a // [template engine](/packer/docs/templates/legacy_json_templates/engine), see [Build template // data](#build-template-data) for more information. AMIDescription string `mapstructure:"ami_description" required:"false"` // The type of virtualization for the AMI // you are building. This option is required to register HVM images. Can be // paravirtual (default) or hvm. AMIVirtType string `mapstructure:"ami_virtualization_type" required:"false"` // A list of account IDs that have access to // launch the resulting AMI(s). By default no additional users other than the // user creating the AMI has permissions to launch it. AMIUsers []string `mapstructure:"ami_users" required:"false"` // A list of groups that have access to // launch the resulting AMI(s). By default no groups have permission to launch // the AMI. `all` will make the AMI publicly accessible. // AWS currently doesn't accept any value other than "all" AMIGroups []string `mapstructure:"ami_groups" required:"false"` // A list of Amazon Resource Names (ARN) of AWS Organizations that have access to // launch the resulting AMI(s). By default no organizations have permission to launch // the AMI. AMIOrgArns []string `mapstructure:"ami_org_arns" required:"false"` // A list of Amazon Resource Names (ARN) of AWS Organizations organizational units (OU) that have access to // launch the resulting AMI(s). By default no organizational units have permission to launch // the AMI. AMIOuArns []string `mapstructure:"ami_ou_arns" required:"false"` // A list of product codes to // associate with the AMI. By default no product codes are associated with the // AMI. AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false"` // A list of regions to copy the AMI to. // Tags and attributes are copied along with the AMI. AMI copying takes time // depending on the size of the AMI, but will generally take many minutes. AMIRegions []string `mapstructure:"ami_regions" required:"false"` // Set to true if you want to skip // validation of the ami_regions configuration option. Default false. AMISkipRegionValidation bool `mapstructure:"skip_region_validation" required:"false"` // Key/value pair tags applied to the AMI. This is a [template // engine](/packer/docs/templates/legacy_json_templates/engine), see [Build template // data](#build-template-data) for more information. // // The builder no longer adds a "Name": "Packer Builder" entry to the tags. AMITags map[string]string `mapstructure:"tags" required:"false"` // Same as [`tags`](#tags) but defined as a singular repeatable block // containing a `key` and a `value` field. In HCL2 mode the // [`dynamic_block`](/packer/docs/templates/hcl_templates/expressions#dynamic-blocks) // will allow you to create those programatically. AMITag config.KeyValues `mapstructure:"tag" required:"false"` // Enable enhanced networking (ENA but not SriovNetSupport) on // HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your // AWS IAM policy. // // Note: you must make sure enhanced networking is enabled on your // instance. See [Amazon's documentation on enabling enhanced // networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). AMIENASupport config.Trilean `mapstructure:"ena_support" required:"false"` // Enable enhanced networking (SriovNetSupport but not ENA) on // HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your // AWS IAM policy. Note: you must make sure enhanced networking is enabled // on your instance. See [Amazon's documentation on enabling enhanced // networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). // Default `false`. AMISriovNetSupport bool `mapstructure:"sriov_support" required:"false"` // Force Packer to first deregister an existing // AMI if one with the same name already exists. Default false. AMIForceDeregister bool `mapstructure:"force_deregister" required:"false"` // Force Packer to delete snapshots // associated with AMIs, which have been deregistered by force_deregister. // Default false. AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot" required:"false"` // Whether or not to encrypt the resulting AMI when // copying a provisioned instance to an AMI. By default, Packer will keep // the encryption setting to what it was in the source image. Setting false // will result in an unencrypted image, and true will result in an encrypted // one. // // If you have used the `launch_block_device_mappings` to set an encryption // key and that key is the same as the one you want the image encrypted with // at the end, then you don't need to set this field; leaving it empty will // prevent an unnecessary extra copy step and save you some time. // // Please note that if you are using an account with the global "Always // encrypt new EBS volumes" option set to `true`, Packer will be unable to // override this setting, and the final image will be encrypted whether // you set this value or not. AMIEncryptBootVolume config.Trilean `mapstructure:"encrypt_boot" required:"false"` // ID, alias or ARN of the KMS key to use for AMI encryption. This // only applies to the main `region` -- any regions the AMI gets copied to // will be encrypted by the default EBS KMS key for that region, // unless you set region-specific keys in `region_kms_key_ids`. // // Set this value if you select `encrypt_boot`, but don't want to use the // region's default KMS key. // // If you have a custom kms key you'd like to apply to the launch volume, // and are only building in one region, it is more efficient to leave this // and `encrypt_boot` empty and to instead set the key id in the // launch_block_device_mappings (you can find an example below). This saves // potentially many minutes at the end of the build by preventing Packer // from having to copy and re-encrypt the image at the end of the build. // // For valid formats see *KmsKeyId* in the [AWS API docs - // CopyImage](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CopyImage.html). // This field is validated by Packer, when using an alias, you will have to // prefix `kms_key_id` with `alias/`. AMIKmsKeyId string `mapstructure:"kms_key_id" required:"false"` // regions to copy the ami to, along with the custom kms key id (alias or // arn) to use for encryption for that region. Keys must match the regions // provided in `ami_regions`. If you just want to encrypt using a default // ID, you can stick with `kms_key_id` and `ami_regions`. If you want a // region to be encrypted with that region's default key ID, you can use an // empty string `""` instead of a key id in this map. (e.g. `"us-east-1": // ""`) However, you cannot use default key IDs if you are using this in // conjunction with `snapshot_users` -- in that situation you must use // custom keys. For valid formats see *KmsKeyId* in the [AWS API docs - // CopyImage](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CopyImage.html). // // This option supercedes the `kms_key_id` option -- if you set both, and // they are different, Packer will respect the value in // `region_kms_key_ids` for your build region and silently disregard the // value provided in `kms_key_id`. AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false"` // If true, Packer will not check whether an AMI with the `ami_name` exists // in the region it is building in. It will use an intermediary AMI name, // which it will not convert to an AMI in the build region. It will copy // the intermediary AMI into any regions provided in `ami_regions`, then // delete the intermediary AMI. Default `false`. AMISkipBuildRegion bool `mapstructure:"skip_save_build_region"` // Enforce version of the Instance Metadata Service on the built AMI. // Valid options are unset (legacy) and `v2.0`. See the documentation on // [IMDS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) // for more information. Defaults to legacy. AMIIMDSSupport string `mapstructure:"imds_support" required:"false"` // The date and time to deprecate the AMI, in UTC, in the following format: YYYY-MM-DDTHH:MM:SSZ. // If you specify a value for seconds, Amazon EC2 rounds the seconds to the nearest minute. // You can’t specify a date in the past. The upper limit for DeprecateAt is 10 years from now. DeprecationTime string `mapstructure:"deprecate_at"` SnapshotConfig `mapstructure:",squash"` // Enable AMI deregistration protection. See // [DeregistrationProtectionOptions](#deregistration-protection-options) below for more // details on all of the options available, and for a usage example. DeregistrationProtection DeregistrationProtectionOptions `mapstructure:"deregistration_protection" required:"false"` }
AMIConfig is for common configuration related to creating AMIs.
func (*AMIConfig) Prepare ¶
func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context) []error
type AWSPollingConfig ¶
type AWSPollingConfig struct { // Specifies the maximum number of attempts the waiter will check for resource state. // This value can also be set via the AWS_MAX_ATTEMPTS. // If both option and environment variable are set, the max_attempts will be considered over the AWS_MAX_ATTEMPTS. // If none is set, defaults to AWS waiter default which is 40 max_attempts. MaxAttempts int `mapstructure:"max_attempts" required:"false"` // Specifies the delay in seconds between attempts to check the resource state. // This value can also be set via the AWS_POLL_DELAY_SECONDS. // If both option and environment variable are set, the delay_seconds will be considered over the AWS_POLL_DELAY_SECONDS. // If none is set, defaults to AWS waiter default which is 15 seconds. DelaySeconds int `mapstructure:"delay_seconds" required:"false"` }
Polling configuration for the AWS waiter. Configures the waiter for resources creation or actions like attaching volumes or importing image.
HCL2 example: ```hcl
aws_polling { delay_seconds = 30 max_attempts = 50 }
```
JSON example: ```json
"aws_polling" : { "delay_seconds": 30, "max_attempts": 50 }
```
func (*AWSPollingConfig) FlatMapstructure ¶
func (*AWSPollingConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatAWSPollingConfig. FlatAWSPollingConfig is an auto-generated flat version of AWSPollingConfig. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
func (*AWSPollingConfig) LogEnvOverrideWarnings ¶
func (w *AWSPollingConfig) LogEnvOverrideWarnings()
func (*AWSPollingConfig) WaitUntilAMIAvailable ¶
func (*AWSPollingConfig) WaitUntilFastLaunchEnabled ¶ added in v1.2.2
func (*AWSPollingConfig) WaitUntilImageImported ¶
func (*AWSPollingConfig) WaitUntilInstanceRunning ¶
func (*AWSPollingConfig) WaitUntilInstanceTerminated ¶
func (*AWSPollingConfig) WaitUntilSnapshotDone ¶
func (*AWSPollingConfig) WaitUntilSpotRequestFulfilled ¶
func (w *AWSPollingConfig) WaitUntilSpotRequestFulfilled(ctx aws.Context, conn *ec2.EC2, spotRequestId string) error
This function works for both requesting and cancelling spot instances.
func (*AWSPollingConfig) WaitUntilVolumeAttached ¶
func (*AWSPollingConfig) WaitUntilVolumeAvailable ¶
func (*AWSPollingConfig) WaitUntilVolumeDetached ¶
type AccessConfig ¶
type AccessConfig struct { // The access key used to communicate with AWS. [Learn how to set this](/packer/plugins/builders/amazon#specifying-amazon-credentials). // On EBS, this is not required if you are using `use_vault_aws_engine` // for authentication instead. AccessKey string `mapstructure:"access_key" required:"true"` // If provided with a role ARN, Packer will attempt to assume this role // using the supplied credentials. See // [AssumeRoleConfig](#assume-role-configuration) below for more // details on all of the options available, and for a usage example. AssumeRole AssumeRoleConfig `mapstructure:"assume_role" required:"false"` // This option is useful if you use a cloud // provider whose API is compatible with aws EC2. Specify another endpoint // like this https://ec2.custom.endpoint.com. CustomEndpointEc2 string `mapstructure:"custom_endpoint_ec2" required:"false"` // Path to a credentials file to load credentials from CredsFilename string `mapstructure:"shared_credentials_file" required:"false"` // Enable automatic decoding of any encoded authorization (error) messages // using the `sts:DecodeAuthorizationMessage` API. Note: requires that the // effective user/role have permissions to `sts:DecodeAuthorizationMessage` // on resource `*`. Default `false`. DecodeAuthZMessages bool `mapstructure:"decode_authorization_messages" required:"false"` // This allows skipping TLS // verification of the AWS EC2 endpoint. The default is false. InsecureSkipTLSVerify bool `mapstructure:"insecure_skip_tls_verify" required:"false"` // This is the maximum number of times an API call is retried, in the case // where requests are being throttled or experiencing transient failures. // The delay between the subsequent API calls increases exponentially. MaxRetries int `mapstructure:"max_retries" required:"false"` // The MFA // [TOTP](https://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm) // code. This should probably be a user variable since it changes all the // time. MFACode string `mapstructure:"mfa_code" required:"false"` // The profile to use in the shared credentials file for // AWS. See Amazon's documentation on [specifying // profiles](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-profiles) // for more details. ProfileName string `mapstructure:"profile" required:"false"` // The name of the region, such as `us-east-1`, in which // to launch the EC2 instance to create the AMI. // When chroot building, this value is guessed from environment. RawRegion string `mapstructure:"region" required:"true"` // The secret key used to communicate with AWS. [Learn how to set // this](/packer/plugins/builders/amazon#specifying-amazon-credentials). This is not required // if you are using `use_vault_aws_engine` for authentication instead. SecretKey string `mapstructure:"secret_key" required:"true"` SkipMetadataApiCheck bool `mapstructure:"skip_metadata_api_check"` // Set to true if you want to skip validating AWS credentials before runtime. SkipCredsValidation bool `mapstructure:"skip_credential_validation"` // The access token to use. This is different from the // access key and secret key. If you're not sure what this is, then you // probably don't need it. This will also be read from the AWS_SESSION_TOKEN // environmental variable. Token string `mapstructure:"token" required:"false"` // Get credentials from HashiCorp Vault's aws secrets engine. You must // already have created a role to use. For more information about // generating credentials via the Vault engine, see the [Vault // docs.](https://www.vaultproject.io/api/secret/aws#generate-credentials) // If you set this flag, you must also set the below options: // - `name` (string) - Required. Specifies the name of the role to generate // credentials against. This is part of the request URL. // - `engine_name` (string) - The name of the aws secrets engine. In the // Vault docs, this is normally referred to as "aws", and Packer will // default to "aws" if `engine_name` is not set. // - `role_arn` (string)- The ARN of the role to assume if credential\_type // on the Vault role is assumed\_role. Must match one of the allowed role // ARNs in the Vault role. Optional if the Vault role only allows a single // AWS role ARN; required otherwise. // - `ttl` (string) - Specifies the TTL for the use of the STS token. This // is specified as a string with a duration suffix. Valid only when // credential\_type is assumed\_role or federation\_token. When not // specified, the default\_sts\_ttl set for the role will be used. If that // is also not set, then the default value of 3600s will be used. AWS // places limits on the maximum TTL allowed. See the AWS documentation on // the DurationSeconds parameter for AssumeRole (for assumed\_role // credential types) and GetFederationToken (for federation\_token // credential types) for more details. // // HCL2 example: // // “`hcl // vault_aws_engine { // name = "myrole" // role_arn = "myarn" // ttl = "3600s" // } // “` // // JSON example: // // “`json // { // "vault_aws_engine": { // "name": "myrole", // "role_arn": "myarn", // "ttl": "3600s" // } // } // “` VaultAWSEngine VaultAWSEngineOptions `mapstructure:"vault_aws_engine" required:"false"` // [Polling configuration](#polling-configuration) for the AWS waiter. Configures the waiter that checks // resource state. PollingConfig *AWSPollingConfig `mapstructure:"aws_polling" required:"false"` // contains filtered or unexported fields }
AccessConfig is for common configuration related to AWS access
func FakeAccessConfig ¶
func FakeAccessConfig() *AccessConfig
func (*AccessConfig) GetCredentials ¶
func (c *AccessConfig) GetCredentials(config *aws.Config) (*awsCredentials.Credentials, error)
GetCredentials gets credentials from the environment, shared credentials, the session (which may include a credential process), or ECS/EC2 metadata endpoints. GetCredentials also validates the credentials and the ability to assume a role or will return an error if unsuccessful.
func (*AccessConfig) GetCredsFromVault ¶
func (c *AccessConfig) GetCredsFromVault() error
func (*AccessConfig) IsChinaCloud ¶
func (c *AccessConfig) IsChinaCloud() bool
func (*AccessConfig) IsGovCloud ¶
func (c *AccessConfig) IsGovCloud() bool
func (*AccessConfig) NewEC2Connection ¶
func (c *AccessConfig) NewEC2Connection() (ec2iface.EC2API, error)
func (*AccessConfig) NewNoValidCredentialSourcesError ¶
func (c *AccessConfig) NewNoValidCredentialSourcesError(err error) error
func (*AccessConfig) Prepare ¶
func (c *AccessConfig) Prepare(packerConfig *common.PackerConfig) []error
func (*AccessConfig) Session ¶
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 ¶
func (c *AccessConfig) SessionRegion() string
func (*AccessConfig) ValidateRegion ¶
func (c *AccessConfig) ValidateRegion(regions ...string) error
ValidateRegion returns an nil if the regions are valid and exists; otherwise an error. ValidateRegion calls ec2conn.DescribeRegions to get the list of regions available to this account.
type AmiFilterOptions ¶
type AmiFilterOptions struct { // Filters used to select an AMI. Any filter described in the docs for // [DescribeImages](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html) // is valid. Filters map[string]string `mapstructure:"filters"` // Filters the images by their owner. You // may specify one or more AWS account IDs, "self" (which will use the // account whose credentials you are using to run Packer), or an AWS owner // alias: for example, `amazon`, `aws-marketplace`, or `microsoft`. This // option is required for security reasons. Owners []string `mapstructure:"owners"` // Selects the newest created image when true. // This is most useful for selecting a daily distro build. MostRecent bool `mapstructure:"most_recent"` // Include deprecated AMIs in the filtered response. Defaults to false. // If you are the AMI owner, deprecated AMIs appear in the response // regardless of what is specified for `include_deprecated`. IncludeDeprecated bool `mapstructure:"include_deprecated"` }
func (*AmiFilterOptions) Empty ¶
func (d *AmiFilterOptions) Empty() bool
func (*AmiFilterOptions) FlatMapstructure ¶
func (*AmiFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatAmiFilterOptions. FlatAmiFilterOptions is an auto-generated flat version of AmiFilterOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
func (*AmiFilterOptions) GetFilteredImage ¶
func (d *AmiFilterOptions) GetFilteredImage(params *ec2.DescribeImagesInput, ec2conn *ec2.EC2) (*ec2.Image, error)
func (*AmiFilterOptions) GetOwners ¶
func (d *AmiFilterOptions) GetOwners() []*string
func (*AmiFilterOptions) NoOwner ¶
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 // StateData should store data such as GeneratedData // to be shared with post-processors StateData map[string]interface{} // EC2 connection for performing API stuff. Session *session.Session }
Artifact is an artifact implementation that contains built AMIs.
type AssumeRoleConfig ¶
type AssumeRoleConfig struct { // Amazon Resource Name (ARN) of the IAM Role to assume. AssumeRoleARN string `mapstructure:"role_arn" required:"false"` // Number of seconds to restrict the assume role session duration. AssumeRoleDurationSeconds int `mapstructure:"duration_seconds" required:"false"` // The external ID to use when assuming the role. If omitted, no external // ID is passed to the AssumeRole call. AssumeRoleExternalID string `mapstructure:"external_id" required:"false"` // IAM Policy JSON describing further restricting permissions for the IAM // Role being assumed. AssumeRolePolicy string `mapstructure:"policy" required:"false"` // Set of Amazon Resource Names (ARNs) of IAM Policies describing further // restricting permissions for the IAM Role being AssumeRolePolicyARNs []string `mapstructure:"policy_arns" required:"false"` // Session name to use when assuming the role. AssumeRoleSessionName string `mapstructure:"session_name" required:"false"` // Map of assume role session tags. AssumeRoleTags map[string]string `mapstructure:"tags" required:"false"` // Set of assume role session tag keys to pass to any subsequent sessions. AssumeRoleTransitiveTagKeys []string `mapstructure:"transitive_tag_keys" required:"false"` }
AssumeRoleConfig lets users set configuration options for assuming a special role when executing Packer.
Usage example:
HCL config example:
```HCL
source "amazon-ebs" "example" { assume_role { role_arn = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME" session_name = "SESSION_NAME" external_id = "EXTERNAL_ID" } }
```
JSON config example:
```json
builder{ "type": "amazon-ebs", "assume_role": { "role_arn" : "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME", "session_name": "SESSION_NAME", "external_id" : "EXTERNAL_ID" } }
```
func (*AssumeRoleConfig) FlatMapstructure ¶
func (*AssumeRoleConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatAssumeRoleConfig. FlatAssumeRoleConfig is an auto-generated flat version of AssumeRoleConfig. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type BlockDevice ¶
type BlockDevice struct { // Indicates whether the EBS volume is deleted on instance termination. // Default false. NOTE: If this value is not explicitly set to true and // volumes are not cleaned up by an alternative method, additional volumes // will accumulate after every build. DeleteOnTermination bool `mapstructure:"delete_on_termination" required:"false"` // The device name exposed to the instance (for example, /dev/sdh or xvdh). // Required for every device in the block device mapping. DeviceName string `mapstructure:"device_name" required:"false"` // Indicates whether or not to encrypt the volume. By default, Packer will // keep the encryption setting to what it was in the source image. Setting // false will result in an unencrypted device, and true will result in an // encrypted one. Encrypted config.Trilean `mapstructure:"encrypted" required:"false"` // The number of I/O operations per second (IOPS) that the volume supports. // See the documentation on // [IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html) // for more information IOPS *int64 `mapstructure:"iops" required:"false"` // Suppresses the specified device included in the block device mapping of // the AMI. NoDevice bool `mapstructure:"no_device" required:"false"` // The ID of the snapshot. SnapshotId string `mapstructure:"snapshot_id" required:"false"` // The throughput for gp3 volumes, only valid for gp3 types // See the documentation on // [Throughput](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html) // for more information Throughput *int64 `mapstructure:"throughput" required:"false"` // The virtual device name. See the documentation on // [Block Device Mapping](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html) // for more information. // // Note: virtual_name only applies for ephemeral (instance) volumes. Any // EBS-backed volume will have a `snapshot_id` instead. // // The volume virtual_name should be in the `ephemeral[0-23]` form, e.g. ephemeral1 VirtualName string `mapstructure:"virtual_name" required:"false"` // The volume type. gp2 & gp3 for General Purpose (SSD) volumes, io1 & io2 // for Provisioned IOPS (SSD) volumes, st1 for Throughput Optimized HDD, // sc1 for Cold HDD, and standard for Magnetic volumes. VolumeType string `mapstructure:"volume_type" required:"false"` // The size of the volume, in GiB. Required if not specifying a // snapshot_id. VolumeSize int64 `mapstructure:"volume_size" required:"false"` // ID, alias or ARN of the KMS key to use for boot volume encryption. // This option exists for launch_block_device_mappings but not // ami_block_device_mappings. The kms key id defined here only applies to // the original build region; if the AMI gets copied to other regions, the // volume in those regions will be encrypted by the default EBS KMS key. // For valid formats see KmsKeyId in the [AWS API docs - // CopyImage](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CopyImage.html) // This field is validated by Packer. When using an alias, you will have to // prefix kms_key_id with alias/. KmsKeyId string `mapstructure:"kms_key_id" required:"false"` }
These will be attached when launching your instance. Your options here may vary depending on the type of VM you use.
Example use case:
The following mapping will tell Packer to encrypt the root volume of the build instance at launch using a specific non-default kms key:
HCL2 example:
```hcl
launch_block_device_mappings { device_name = "/dev/sda1" encrypted = true kms_key_id = "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" }
```
JSON example: ```json "launch_block_device_mappings": [
{ "device_name": "/dev/sda1", "encrypted": true, "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" }
] ```
Please note that the kms_key_id option in this example exists for launch_block_device_mappings but not ami_block_device_mappings.
Documentation for Block Devices Mappings can be found here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html
func (BlockDevice) BuildEC2BlockDeviceMapping ¶
func (blockDevice BlockDevice) BuildEC2BlockDeviceMapping() *ec2.BlockDeviceMapping
func (*BlockDevice) FlatMapstructure ¶
func (*BlockDevice) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatBlockDevice. FlatBlockDevice is an auto-generated flat version of BlockDevice. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
func (*BlockDevice) Prepare ¶
func (b *BlockDevice) Prepare(ctx *interpolate.Context) error
type BlockDevices ¶
type BlockDevices []BlockDevice
func (BlockDevices) BuildEC2BlockDeviceMappings ¶
func (bds BlockDevices) BuildEC2BlockDeviceMappings() []*ec2.BlockDeviceMapping
func (BlockDevices) Prepare ¶
func (bds BlockDevices) Prepare(ctx *interpolate.Context) (errs []error)
type BuildInfoTemplate ¶
type DeregistrationProtectionOptions ¶ added in v1.3.4
type DeregistrationProtectionOptions struct { // Enable AMI deregistration protection. // To allow the AMI to be deregistered, you must first disable deregistration protection. Enabled bool `mapstructure:"enabled"` // When you turn on deregistration protection on an AMI, you have the option to include a 24-hour cooldown period. // This cooldown period is the time during which deregistration protection remains in effect after you turn it off. // During this cooldown period, the AMI can’t be deregistered. // When the cooldown period ends, the AMI can be deregistered. WithCooldown bool `mapstructure:"with_cooldown" required:"false"` }
DeregistrationProtectionOptions lets users set AMI deregistration protection
HCL2 example:
```hcl
source "amazon-ebs" "basic-example" { deregistration_protection { enabled = true with_cooldown = true } }
```
JSON Example:
```json "builders" [
{ "type": "amazon-ebs", "deregistration_protection": { "enabled": true, "with_cooldown": true } }
] ```
[Protect an AMI from deregistration](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-deregistration-protection.html) When deregistration protection is enabled, the AMI cannot be deregistered. To allow the AMI to be deregistered, you must first disable deregistration protection.
func (*DeregistrationProtectionOptions) FlatMapstructure ¶ added in v1.3.4
func (*DeregistrationProtectionOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatDeregistrationProtectionOptions. FlatDeregistrationProtectionOptions is an auto-generated flat version of DeregistrationProtectionOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type EC2BlockDeviceMappingsBuilder ¶
type EC2BlockDeviceMappingsBuilder interface {
BuildEC2BlockDeviceMappings() []*ec2.BlockDeviceMapping
}
type EC2Tags ¶
func (EC2Tags) TagSpecifications ¶ added in v1.0.2
func (t EC2Tags) TagSpecifications(resourceType ...string) []*ec2.TagSpecification
type FlatAWSPollingConfig ¶
type FlatAWSPollingConfig struct { MaxAttempts *int `mapstructure:"max_attempts" required:"false" cty:"max_attempts" hcl:"max_attempts"` DelaySeconds *int `mapstructure:"delay_seconds" required:"false" cty:"delay_seconds" hcl:"delay_seconds"` }
FlatAWSPollingConfig is an auto-generated flat version of AWSPollingConfig. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatAWSPollingConfig) HCL2Spec ¶
func (*FlatAWSPollingConfig) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a AWSPollingConfig. This spec is used by HCL to read the fields of AWSPollingConfig. The decoded values from this spec will then be applied to a FlatAWSPollingConfig.
type FlatAmiFilterOptions ¶
type FlatAmiFilterOptions struct { Filters map[string]string `mapstructure:"filters" cty:"filters" hcl:"filters"` Owners []string `mapstructure:"owners" cty:"owners" hcl:"owners"` MostRecent *bool `mapstructure:"most_recent" cty:"most_recent" hcl:"most_recent"` IncludeDeprecated *bool `mapstructure:"include_deprecated" cty:"include_deprecated" hcl:"include_deprecated"` }
FlatAmiFilterOptions is an auto-generated flat version of AmiFilterOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatAmiFilterOptions) HCL2Spec ¶
func (*FlatAmiFilterOptions) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a AmiFilterOptions. This spec is used by HCL to read the fields of AmiFilterOptions. The decoded values from this spec will then be applied to a FlatAmiFilterOptions.
type FlatAssumeRoleConfig ¶
type FlatAssumeRoleConfig struct { AssumeRoleARN *string `mapstructure:"role_arn" required:"false" cty:"role_arn" hcl:"role_arn"` AssumeRoleDurationSeconds *int `mapstructure:"duration_seconds" required:"false" cty:"duration_seconds" hcl:"duration_seconds"` AssumeRoleExternalID *string `mapstructure:"external_id" required:"false" cty:"external_id" hcl:"external_id"` AssumeRolePolicy *string `mapstructure:"policy" required:"false" cty:"policy" hcl:"policy"` AssumeRolePolicyARNs []string `mapstructure:"policy_arns" required:"false" cty:"policy_arns" hcl:"policy_arns"` AssumeRoleSessionName *string `mapstructure:"session_name" required:"false" cty:"session_name" hcl:"session_name"` AssumeRoleTags map[string]string `mapstructure:"tags" required:"false" cty:"tags" hcl:"tags"` AssumeRoleTransitiveTagKeys []string `mapstructure:"transitive_tag_keys" required:"false" cty:"transitive_tag_keys" hcl:"transitive_tag_keys"` }
FlatAssumeRoleConfig is an auto-generated flat version of AssumeRoleConfig. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatAssumeRoleConfig) HCL2Spec ¶
func (*FlatAssumeRoleConfig) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a AssumeRoleConfig. This spec is used by HCL to read the fields of AssumeRoleConfig. The decoded values from this spec will then be applied to a FlatAssumeRoleConfig.
type FlatBlockDevice ¶
type FlatBlockDevice struct { DeleteOnTermination *bool `mapstructure:"delete_on_termination" required:"false" cty:"delete_on_termination" hcl:"delete_on_termination"` DeviceName *string `mapstructure:"device_name" required:"false" cty:"device_name" hcl:"device_name"` Encrypted *bool `mapstructure:"encrypted" required:"false" cty:"encrypted" hcl:"encrypted"` IOPS *int64 `mapstructure:"iops" required:"false" cty:"iops" hcl:"iops"` NoDevice *bool `mapstructure:"no_device" required:"false" cty:"no_device" hcl:"no_device"` SnapshotId *string `mapstructure:"snapshot_id" required:"false" cty:"snapshot_id" hcl:"snapshot_id"` Throughput *int64 `mapstructure:"throughput" required:"false" cty:"throughput" hcl:"throughput"` VirtualName *string `mapstructure:"virtual_name" required:"false" cty:"virtual_name" hcl:"virtual_name"` VolumeType *string `mapstructure:"volume_type" required:"false" cty:"volume_type" hcl:"volume_type"` VolumeSize *int64 `mapstructure:"volume_size" required:"false" cty:"volume_size" hcl:"volume_size"` KmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id" hcl:"kms_key_id"` }
FlatBlockDevice is an auto-generated flat version of BlockDevice. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatDeregistrationProtectionOptions ¶ added in v1.3.4
type FlatDeregistrationProtectionOptions struct { Enabled *bool `mapstructure:"enabled" cty:"enabled" hcl:"enabled"` WithCooldown *bool `mapstructure:"with_cooldown" required:"false" cty:"with_cooldown" hcl:"with_cooldown"` }
FlatDeregistrationProtectionOptions is an auto-generated flat version of DeregistrationProtectionOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatDeregistrationProtectionOptions) HCL2Spec ¶ added in v1.3.4
func (*FlatDeregistrationProtectionOptions) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a DeregistrationProtectionOptions. This spec is used by HCL to read the fields of DeregistrationProtectionOptions. The decoded values from this spec will then be applied to a FlatDeregistrationProtectionOptions.
type FlatLicenseConfigurationRequest ¶ added in v1.0.7
type FlatLicenseConfigurationRequest struct {
LicenseConfigurationArn *string `mapstructure:"license_configuration_arn" cty:"license_configuration_arn" hcl:"license_configuration_arn"`
}
FlatLicenseConfigurationRequest is an auto-generated flat version of LicenseConfigurationRequest. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatLicenseConfigurationRequest) HCL2Spec ¶ added in v1.0.7
func (*FlatLicenseConfigurationRequest) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a LicenseConfigurationRequest. This spec is used by HCL to read the fields of LicenseConfigurationRequest. The decoded values from this spec will then be applied to a FlatLicenseConfigurationRequest.
type FlatLicenseSpecification ¶ added in v1.0.7
type FlatLicenseSpecification struct {
LicenseConfigurationRequest *FlatLicenseConfigurationRequest `mapstructure:"license_configuration_request" cty:"license_configuration_request" hcl:"license_configuration_request"`
}
FlatLicenseSpecification is an auto-generated flat version of LicenseSpecification. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatLicenseSpecification) HCL2Spec ¶ added in v1.0.7
func (*FlatLicenseSpecification) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a LicenseSpecification. This spec is used by HCL to read the fields of LicenseSpecification. The decoded values from this spec will then be applied to a FlatLicenseSpecification.
type FlatMetadataOptions ¶
type FlatMetadataOptions struct { HttpEndpoint *string `mapstructure:"http_endpoint" required:"false" cty:"http_endpoint" hcl:"http_endpoint"` HttpTokens *string `mapstructure:"http_tokens" required:"false" cty:"http_tokens" hcl:"http_tokens"` HttpPutResponseHopLimit *int64 `` /* 127-byte string literal not displayed */ InstanceMetadataTags *string `mapstructure:"instance_metadata_tags" required:"false" cty:"instance_metadata_tags" hcl:"instance_metadata_tags"` }
FlatMetadataOptions is an auto-generated flat version of MetadataOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatPlacement ¶ added in v1.0.7
type FlatPlacement struct { HostResourceGroupArn *string `mapstructure:"host_resource_group_arn" required:"false" cty:"host_resource_group_arn" hcl:"host_resource_group_arn"` HostId *string `mapstructure:"host_id" required:"false" cty:"host_id" hcl:"host_id"` Tenancy *string `mapstructure:"tenancy" required:"false" cty:"tenancy" hcl:"tenancy"` }
FlatPlacement is an auto-generated flat version of Placement. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatPolicyDocument ¶
type FlatPolicyDocument struct { Version *string `mapstructure:"Version" required:"false" cty:"Version" hcl:"Version"` Statement []FlatStatement `mapstructure:"Statement" required:"false" cty:"Statement" hcl:"Statement"` }
FlatPolicyDocument is an auto-generated flat version of PolicyDocument. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatSecurityGroupFilterOptions ¶
type FlatSecurityGroupFilterOptions struct { Filters map[string]string `cty:"filters" hcl:"filters"` Filter []config.FlatNameValue `cty:"filter" hcl:"filter"` }
FlatSecurityGroupFilterOptions is an auto-generated flat version of SecurityGroupFilterOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatSecurityGroupFilterOptions) HCL2Spec ¶
func (*FlatSecurityGroupFilterOptions) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a SecurityGroupFilterOptions. This spec is used by HCL to read the fields of SecurityGroupFilterOptions. The decoded values from this spec will then be applied to a FlatSecurityGroupFilterOptions.
type FlatStatement ¶
type FlatStatement struct { Effect *string `mapstructure:"Effect" required:"false" cty:"Effect" hcl:"Effect"` Action []string `mapstructure:"Action" required:"false" cty:"Action" hcl:"Action"` Resource []string `mapstructure:"Resource" required:"false" cty:"Resource" hcl:"Resource"` }
FlatStatement is an auto-generated flat version of Statement. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
type FlatSubnetFilterOptions ¶
type FlatSubnetFilterOptions struct { Filters map[string]string `cty:"filters" hcl:"filters"` Filter []config.FlatNameValue `cty:"filter" hcl:"filter"` MostFree *bool `mapstructure:"most_free" cty:"most_free" hcl:"most_free"` Random *bool `mapstructure:"random" cty:"random" hcl:"random"` }
FlatSubnetFilterOptions is an auto-generated flat version of SubnetFilterOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatSubnetFilterOptions) HCL2Spec ¶
func (*FlatSubnetFilterOptions) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a SubnetFilterOptions. This spec is used by HCL to read the fields of SubnetFilterOptions. The decoded values from this spec will then be applied to a FlatSubnetFilterOptions.
type FlatVaultAWSEngineOptions ¶
type FlatVaultAWSEngineOptions struct { Name *string `mapstructure:"name" cty:"name" hcl:"name"` RoleARN *string `mapstructure:"role_arn" cty:"role_arn" hcl:"role_arn"` TTL *string `mapstructure:"ttl" required:"false" cty:"ttl" hcl:"ttl"` EngineName *string `mapstructure:"engine_name" cty:"engine_name" hcl:"engine_name"` }
FlatVaultAWSEngineOptions is an auto-generated flat version of VaultAWSEngineOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatVaultAWSEngineOptions) HCL2Spec ¶
func (*FlatVaultAWSEngineOptions) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a VaultAWSEngineOptions. This spec is used by HCL to read the fields of VaultAWSEngineOptions. The decoded values from this spec will then be applied to a FlatVaultAWSEngineOptions.
type FlatVpcFilterOptions ¶
type FlatVpcFilterOptions struct { Filters map[string]string `cty:"filters" hcl:"filters"` Filter []config.FlatNameValue `cty:"filter" hcl:"filter"` }
FlatVpcFilterOptions is an auto-generated flat version of VpcFilterOptions. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
func (*FlatVpcFilterOptions) HCL2Spec ¶
func (*FlatVpcFilterOptions) HCL2Spec() map[string]hcldec.Spec
HCL2Spec returns the hcl spec of a VpcFilterOptions. This spec is used by HCL to read the fields of VpcFilterOptions. The decoded values from this spec will then be applied to a FlatVpcFilterOptions.
type LicenseConfigurationRequest ¶ added in v1.0.7
type LicenseConfigurationRequest struct { // The Amazon Resource Name (ARN) of the license configuration. LicenseConfigurationArn string `mapstructure:"license_configuration_arn"` }
func (*LicenseConfigurationRequest) FlatMapstructure ¶ added in v1.0.7
func (*LicenseConfigurationRequest) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatLicenseConfigurationRequest. FlatLicenseConfigurationRequest is an auto-generated flat version of LicenseConfigurationRequest. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type LicenseSpecification ¶ added in v1.0.7
type LicenseSpecification struct { // Describes a license configuration. LicenseConfigurationRequest LicenseConfigurationRequest `mapstructure:"license_configuration_request"` }
func (*LicenseSpecification) FlatMapstructure ¶ added in v1.0.7
func (*LicenseSpecification) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatLicenseSpecification. FlatLicenseSpecification is an auto-generated flat version of LicenseSpecification. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type MetadataOptions ¶
type MetadataOptions struct { // A string to enable or disable the IMDS endpoint for an instance. Defaults to enabled. // Accepts either "enabled" or "disabled" HttpEndpoint string `mapstructure:"http_endpoint" required:"false"` // A string to either set the use of IMDSv2 for the instance to optional or required. Defaults to "optional". // Accepts either "optional" or "required" HttpTokens string `mapstructure:"http_tokens" required:"false"` // A numerical value to set an upper limit for the amount of hops allowed when communicating with IMDS endpoints. // Defaults to 1. HttpPutResponseHopLimit int64 `mapstructure:"http_put_response_hop_limit" required:"false"` // A string to enable or disable access to instance tags from the instance metadata. Defaults to disabled. // Access to instance metadata tags is available for commercial regions. For non-commercial regions please check availability before enabling. // Accepts either "enabled" or "disabled" InstanceMetadataTags string `mapstructure:"instance_metadata_tags" required:"false"` }
Configures the metadata options. See [Configure IMDS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html) for details.
func (*MetadataOptions) FlatMapstructure ¶
func (*MetadataOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatMetadataOptions. FlatMetadataOptions is an auto-generated flat version of MetadataOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type Placement ¶ added in v1.0.7
type Placement struct { // The ARN of the host resource group in which to launch the instances. HostResourceGroupArn string `mapstructure:"host_resource_group_arn" required:"false"` // The ID of the host used when Packer launches an EC2 instance. HostId string `mapstructure:"host_id" required:"false"` // [Tenancy](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-instance.html) used // when Packer launches the EC2 instance, allowing it to be launched on dedicated hardware. // // The default is "default", meaning shared tenancy. Allowed values are "default", // "dedicated" and "host". Tenancy string `mapstructure:"tenancy" required:"false"` }
func (*Placement) FlatMapstructure ¶ added in v1.0.7
FlatMapstructure returns a new FlatPlacement. FlatPlacement is an auto-generated flat version of Placement. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type PolicyDocument ¶
type PolicyDocument struct { Version string `mapstructure:"Version" required:"false"` Statement []Statement `mapstructure:"Statement" required:"false"` }
func (*PolicyDocument) FlatMapstructure ¶
func (*PolicyDocument) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatPolicyDocument. FlatPolicyDocument is an auto-generated flat version of PolicyDocument. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type RunConfig ¶
type RunConfig struct { // If using a non-default VPC, // public IP addresses are not provided by default. If this is true, your // new instance will get a Public IP. default: unset // // Note: when specifying this attribute without a `subnet_[id|filter]` or // `vpc_[id|filter]`, we will attempt to infer this information from the // default VPC/Subnet. // This operation may require some extra permissions to the IAM role that // runs the build: // // * ec2:DescribeVpcs // * ec2:DescribeSubnets // // Additionally, since we filter subnets/AZs by their capability to host // an instance of the selected type, you may also want to define the // `ec2:DescribeInstanceTypeOfferings` action to the role running the build. // Otherwise, Packer will pick the most available subnet in the VPC selected, // which may not be able to host the instance type you provided. AssociatePublicIpAddress config.Trilean `mapstructure:"associate_public_ip_address" required:"false"` // Destination availability zone to launch // instance in. Leave this empty to allow Amazon to auto-assign. AvailabilityZone string `mapstructure:"availability_zone" required:"false"` // Requires spot_price to be set. The // required duration for the Spot Instances (also known as Spot blocks). This // value must be a multiple of 60 (60, 120, 180, 240, 300, or 360). You can't // specify an Availability Zone group or a launch group if you specify a // duration. Note: This parameter is no longer available to new customers // from July 1, 2021. [See Amazon's //documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#fixed-duration-spot-instances). BlockDurationMinutes int64 `mapstructure:"block_duration_minutes" required:"false"` // Set the preference for using a capacity reservation if one exists. // Either will be `open` or `none`. Defaults to `none` CapacityReservationPreference string `mapstructure:"capacity_reservation_preference" required:"false"` // Provide the specific EC2 Capacity Reservation ID that will be used // by Packer. CapacityReservationId string `mapstructure:"capacity_reservation_id" required:"false"` // Provide the EC2 Capacity Reservation Group ARN that will be used by // Packer. CapacityReservationGroupArn string `mapstructure:"capacity_reservation_group_arn" required:"false"` // Packer normally stops the build instance after all provisioners have // run. For Windows instances, it is sometimes desirable to [run // Sysprep](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_EBSbacked_WinAMI.html) // which will stop the instance for you. If this is set to `true`, Packer // *will not* stop the instance but will assume that you will send the stop // signal yourself through your final provisioner. You can do this with a // [windows-shell provisioner](/packer/plugins/provisioners/windows-shell). Note that // Packer will still wait for the instance to be stopped, and failing to // send the stop signal yourself, when you have set this flag to `true`, // will cause a timeout. // // An example of a valid windows shutdown command in a `windows-shell` // provisioner is : // “`shell-session // ec2config.exe -sysprep // “` // or // “`sell-session // "%programfiles%\amazon\ec2configservice\"ec2config.exe -sysprep"" // “` // -> Note: The double quotation marks in the command are not required if // your CMD shell is already in the // `C:\Program Files\Amazon\EC2ConfigService\` directory. DisableStopInstance bool `mapstructure:"disable_stop_instance" required:"false"` // Mark instance as [EBS // Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). // Default `false`. EbsOptimized bool `mapstructure:"ebs_optimized" required:"false"` // Enable support for Nitro Enclaves on the instance. Note that the instance type must // be able to [support Nitro Enclaves](https://aws.amazon.com/ec2/nitro/nitro-enclaves/faqs/). // This option is not supported for spot instances. EnableNitroEnclave bool `mapstructure:"enable_nitro_enclave" required:"false"` // Deprecated argument - please use "enable_unlimited_credits". // Enabling T2 Unlimited allows the source instance to burst additional CPU // beyond its available [CPU // Credits](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-credits-baseline-concepts.html) // for as long as the demand exists. This is in contrast to the standard // configuration that only allows an instance to consume up to its // available CPU Credits. See the AWS documentation for [T2 // Unlimited](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-unlimited.html) // and the **T2 Unlimited Pricing** section of the [Amazon EC2 On-Demand // Pricing](https://aws.amazon.com/ec2/pricing/on-demand/) document for // more information. By default this option is disabled and Packer will set // up a [T2 // Standard](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-std.html) // instance instead. // // To use T2 Unlimited you must use a T2 instance type, e.g. `t2.micro`. // Additionally, T2 Unlimited cannot be used in conjunction with Spot // Instances, e.g. when the `spot_price` option has been configured. // Attempting to do so will cause an error. // // !> **Warning!** Additional costs may be incurred by enabling T2 // Unlimited - even for instances that would usually qualify for the // [AWS Free Tier](https://aws.amazon.com/free/). EnableT2Unlimited bool `mapstructure:"enable_t2_unlimited" required:"false"` // Enabling Unlimited credits allows the source instance to burst additional CPU // beyond its available [CPU // Credits](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-unlimited-mode-concepts.html#unlimited-mode-surplus-credits) // for as long as the demand exists. This is in contrast to the standard // configuration that only allows an instance to consume up to its // available CPU Credits. See the AWS documentation for [T2 // Unlimited](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-unlimited-mode-concepts.html) // and the **Unlimited Pricing** section of the [Amazon EC2 On-Demand // Pricing](https://aws.amazon.com/ec2/pricing/on-demand/) document for // more information. By default this option is disabled and Packer will set // up a [Standard](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-standard-mode.html) // instance instead. // // To use Unlimited you must use a T2/T3/T3a/T4g instance type, e.g. (`t2.micro`, `t3.micro`). // Additionally, Unlimited cannot be used in conjunction with Spot // Instances for T2 type instances, e.g. when the `spot_price` option has been configured. // Attempting to do so will cause an error if the underlying instance type is a T2 type instance. // By default the supported burstable instance types (including t3/t3a/t4g) will be provisioned with its cpu credits set to standard, // only when `enable_unlimited_credits` is true will the instance be provisioned with unlimited cpu credits. EnableUnlimitedCredits bool `mapstructure:"enable_unlimited_credits" required:"false"` // The name of an [IAM instance // profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) // to launch the EC2 instance with. IamInstanceProfile string `mapstructure:"iam_instance_profile" required:"false"` // Key/value pair tags to apply tags to the fleet that is issued. FleetTags map[string]string `mapstructure:"fleet_tags" required:"false"` // Same as [`fleet_tags`](#fleet_tags) but defined as a singular repeatable block // containing a `key` and a `value` field. In HCL2 mode the // [`dynamic_block`](/packer/docs/templates/hcl_templates/expressions#dynamic-blocks) // will allow you to create those programatically. FleetTag config.KeyValues `mapstructure:"fleet_tag" required:"false"` // Whether or not to check if the IAM instance profile exists. Defaults to false SkipProfileValidation bool `mapstructure:"skip_profile_validation" required:"false"` // Temporary IAM instance profile policy document // If IamInstanceProfile is specified it will be used instead. // // HCL2 example: // “`hcl //temporary_iam_instance_profile_policy_document { // Statement { // Action = ["logs:*"] // Effect = "Allow" // Resource = ["*"] // } // Version = "2012-10-17" //} // “` // // JSON example: // “`json //{ // "Version": "2012-10-17", // "Statement": [ // { // "Action": [ // "logs:*" // ], // "Effect": "Allow", // "Resource": ["*"] // } // ] //} // “` // TemporaryIamInstanceProfilePolicyDocument *PolicyDocument `mapstructure:"temporary_iam_instance_profile_policy_document" required:"false"` // Automatically terminate instances on // shutdown in case Packer exits ungracefully. Possible values are stop and // terminate. Defaults to stop. InstanceInitiatedShutdownBehavior string `mapstructure:"shutdown_behavior" required:"false"` // The EC2 instance type to use while building the // AMI, such as t2.small. InstanceType string `mapstructure:"instance_type" required:"true"` // Filters used to populate the `security_group_ids` field. // // HCL2 Example: // // “`hcl // security_group_filter { // filters = { // "tag:Class": "packer" // } // } // “` // // JSON Example: // “`json // { // "security_group_filter": { // "filters": { // "tag:Class": "packer" // } // } // } // “` // // This selects the SG's with tag `Class` with the value `packer`. // // - `filters` (map[string,string] | multiple filters are allowed when seperated by commas) - filters used to select a // `security_group_ids`. Any filter described in the docs for // [DescribeSecurityGroups](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSecurityGroups.html) // is valid. // // `security_group_ids` take precedence over this. SecurityGroupFilter SecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false"` // Key/value pair tags to apply to the generated key-pair, security group, iam profile and role, snapshot, network interfaces and instance // that is *launched* to create the EBS volumes. The resulting AMI will also inherit these tags. // This is a [template // engine](/packer/docs/templates/legacy_json_templates/engine), see [Build template // data](#build-template-data) for more information. RunTags map[string]string `mapstructure:"run_tags" required:"false"` // Same as [`run_tags`](#run_tags) but defined as a singular repeatable // block containing a `key` and a `value` field. In HCL2 mode the // [`dynamic_block`](/packer/docs/templates/hcl_templates/expressions#dynamic-blocks) // will allow you to create those programatically. RunTag config.KeyValues `mapstructure:"run_tag" required:"false"` // The ID (not the name) of the security // group to assign to the instance. By default this is not set and Packer will // automatically create a new temporary security group to allow SSH access. // Note that if this is specified, you must be sure the security group allows // access to the ssh_port given below. SecurityGroupId string `mapstructure:"security_group_id" required:"false"` // A list of security groups as // described above. Note that if this is specified, you must omit the // security_group_id. SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false"` // The source AMI whose root volume will be copied and // provisioned on the currently running instance. This must be an EBS-backed // AMI with a root volume snapshot that you have access to. SourceAmi string `mapstructure:"source_ami" required:"true"` // Filters used to populate the `source_ami` // field. // // HCL2 example: // “`hcl // source "amazon-ebs" "basic-example" { // source_ami_filter { // filters = { // virtualization-type = "hvm" // name = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*" // root-device-type = "ebs" // } // owners = ["099720109477"] // most_recent = true // } // } // “` // // JSON Example: // “`json // "builders" [ // { // "type": "amazon-ebs", // "source_ami_filter": { // "filters": { // "virtualization-type": "hvm", // "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*", // "root-device-type": "ebs" // }, // "owners": ["099720109477"], // "most_recent": true // } // } // ] // “` // // This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. NOTE: // This will fail unless *exactly* one AMI is returned. In the above example, // `most_recent` will cause this to succeed by selecting the newest image. // // - `filters` (map[string,string] | multiple filters are allowed when seperated by commas) - filters used to select a `source_ami`. // NOTE: This will fail unless *exactly* one AMI is returned. Any filter // described in the docs for // [DescribeImages](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html) // is valid. // // - `owners` (array of strings) - Filters the images by their owner. You // may specify one or more AWS account IDs, "self" (which will use the // account whose credentials you are using to run Packer), or an AWS owner // alias: for example, `amazon`, `aws-marketplace`, or `microsoft`. This // option is required for security reasons. // // - `most_recent` (boolean) - Selects the newest created image when true. // This is most useful for selecting a daily distro build. // // You may set this in place of `source_ami` or in conjunction with it. If you // set this in conjunction with `source_ami`, the `source_ami` will be added // to the filter. The provided `source_ami` must meet all of the filtering // criteria provided in `source_ami_filter`; this pins the AMI returned by the // filter, but will cause Packer to fail if the `source_ami` does not exist. SourceAmiFilter AmiFilterOptions `mapstructure:"source_ami_filter" required:"false"` // a list of acceptable instance // types to run your build on. We will request a spot instance using the max // price of spot_price and the allocation strategy of "lowest price". // Your instance will be launched on an instance type of the lowest available // price that you have in your list. This is used in place of instance_type. // You may only set either spot_instance_types or instance_type, not both. // This feature exists to help prevent situations where a Packer build fails // because a particular availability zone does not have capacity for the // specific instance_type requested in instance_type. SpotInstanceTypes []string `mapstructure:"spot_instance_types" required:"false"` // With Spot Instances, you pay the Spot price that's in effect for the // time period your instances are running. Spot Instance prices are set by // Amazon EC2 and adjust gradually based on long-term trends in supply and // demand for Spot Instance capacity. // // When this field is set, it represents the maximum hourly price you are // willing to pay for a spot instance. If you do not set this value, it // defaults to a maximum price equal to the on demand price of the // instance. In the situation where the current Amazon-set spot price // exceeds the value set in this field, Packer will not launch an instance // and the build will error. In the situation where the Amazon-set spot // price is less than the value set in this field, Packer will launch and // you will pay the Amazon-set spot price, not this maximum value. // For more information, see the Amazon docs on // [spot pricing](https://aws.amazon.com/ec2/spot/pricing/). SpotPrice string `mapstructure:"spot_price" required:"false"` // Required if spot_price is set to // auto. This tells Packer what sort of AMI you're launching to find the // best spot price. This must be one of: Linux/UNIX, SUSE Linux, // Windows, Linux/UNIX (Amazon VPC), SUSE Linux (Amazon VPC), // Windows (Amazon VPC) SpotPriceAutoProduct string `mapstructure:"spot_price_auto_product" required:"false" undocumented:"true"` // Requires spot_price to be set. Key/value pair tags to apply tags to the // spot request that is issued. SpotTags map[string]string `mapstructure:"spot_tags" required:"false"` // Same as [`spot_tags`](#spot_tags) but defined as a singular repeatable block // containing a `key` and a `value` field. In HCL2 mode the // [`dynamic_block`](/packer/docs/templates/hcl_templates/expressions#dynamic-blocks) // will allow you to create those programatically. SpotTag config.KeyValues `mapstructure:"spot_tag" required:"false"` // Filters used to populate the `subnet_id` field. // // HCL2 example: // // “`hcl // source "amazon-ebs" "basic-example" { // subnet_filter { // filters = { // "tag:Class": "build" // } // most_free = true // random = false // } // } // “` // // JSON Example: // “`json // "builders" [ // { // "type": "amazon-ebs", // "subnet_filter": { // "filters": { // "tag:Class": "build" // }, // "most_free": true, // "random": false // } // } // ] // “` // // This selects the Subnet with tag `Class` with the value `build`, which has // the most free IP addresses. NOTE: This will fail unless *exactly* one // Subnet is returned. By using `most_free` or `random` one will be selected // from those matching the filter. // // - `filters` (map[string,string] | multiple filters are allowed when seperated by commas) - filters used to select a `subnet_id`. // NOTE: This will fail unless *exactly* one Subnet is returned. Any // filter described in the docs for // [DescribeSubnets](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSubnets.html) // is valid. // // - `most_free` (boolean) - The Subnet with the most free IPv4 addresses // will be used if multiple Subnets matches the filter. // // - `random` (boolean) - A random Subnet will be used if multiple Subnets // matches the filter. `most_free` have precendence over this. // // `subnet_id` take precedence over this. SubnetFilter SubnetFilterOptions `mapstructure:"subnet_filter" required:"false"` // If using VPC, the ID of the subnet, such as // subnet-12345def, where Packer will launch the EC2 instance. This field is // required if you are using an non-default VPC. SubnetId string `mapstructure:"subnet_id" required:"false"` // The license configurations. // // HCL2 example: // “`hcl // source "amazon-ebs" "basic-example" { // license_specifications { // license_configuration_request = { // license_configuration_arn = "${var.license_configuration_arn}" // } // } // } // “` // // JSON example: // “`json // "builders" [ // { // "type": "amazon-ebs", // "license_specifications": [ // { // "license_configuration_request": { // "license_configuration_arn": "{{user `license_configuration_arn`}}" // } // } // ] // } // ] // “` // // Each `license_configuration_request` describes a license configuration, // the properties of which are: // // - `license_configuration_arn` (string) - The Amazon Resource Name (ARN) // of the license configuration. // LicenseSpecifications []LicenseSpecification `mapstructure:"license_specifications" required:"false"` // Describes the placement of an instance. // // HCL2 example: // “`hcl // source "amazon-ebs" "basic-example" { // placement = { // host_resource_group_arn = "${var.host_resource_group_arn}" // tenancy = "${var.placement_tenancy}" // } // } // “` // // JSON example: // “`json // "builders" [ // { // "type": "amazon-ebs", // "placement": { // "host_resource_group_arn": "{{user `host_resource_group_arn`}}", // "tenancy": "{{user `placement_tenancy`}}" // } // } // ] // “` // // Refer to the [Placement docs](#placement-configuration) for more information on the supported attributes for placement configuration. Placement Placement `mapstructure:"placement" required:"false"` // Deprecated: Use Placement Tenancy instead. Tenancy string `mapstructure:"tenancy" required:"false"` // A list of IPv4 CIDR blocks to be authorized access to the instance, when // packer is creating a temporary security group. // // The default is [`0.0.0.0/0`] (i.e., allow any IPv4 source). // Use `temporary_security_group_source_public_ip` to allow current host's // public IP instead of any IPv4 source. // This is only used when `security_group_id` or `security_group_ids` is not // specified. TemporarySGSourceCidrs []string `mapstructure:"temporary_security_group_source_cidrs" required:"false"` // When enabled, use public IP of the host (obtained from https://checkip.amazonaws.com) // as CIDR block to be authorized access to the instance, when packer // is creating a temporary security group. Defaults to `false`. // // This is only used when `security_group_id`, `security_group_ids`, // and `temporary_security_group_source_cidrs` are not specified. TemporarySGSourcePublicIp bool `mapstructure:"temporary_security_group_source_public_ip" required:"false"` // User data to apply when launching the instance. Note // that you need to be careful about escaping characters due to the templates // being JSON. It is often more convenient to use user_data_file, instead. // Packer will not automatically wait for a user script to finish before // shutting down the instance this must be handled in a provisioner. UserData string `mapstructure:"user_data" required:"false"` // Path to a file that will be used for the user // data when launching the instance. UserDataFile string `mapstructure:"user_data_file" required:"false"` // Filters used to populate the `vpc_id` field. // // HCL2 example: // “`hcl // source "amazon-ebs" "basic-example" { // vpc_filter { // filters = { // "tag:Class": "build", // "isDefault": "false", // "cidr": "/24" // } // } // } // “` // // JSON Example: // “`json // "builders" [ // { // "type": "amazon-ebs", // "vpc_filter": { // "filters": { // "tag:Class": "build", // "isDefault": "false", // "cidr": "/24" // } // } // } // ] // “` // // This selects the VPC with tag `Class` with the value `build`, which is not // the default VPC, and have a IPv4 CIDR block of `/24`. NOTE: This will fail // unless *exactly* one VPC is returned. // // - `filters` (map[string,string] | multiple filters are allowed when seperated by commas) - filters used to select a `vpc_id`. NOTE: // This will fail unless *exactly* one VPC is returned. Any filter // described in the docs for // [DescribeVpcs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcs.html) // is valid. // // `vpc_id` take precedence over this. VpcFilter VpcFilterOptions `mapstructure:"vpc_filter" required:"false"` // If launching into a VPC subnet, Packer needs the VPC ID // in order to create a temporary security group within the VPC. Requires // subnet_id to be set. If this field is left blank, Packer will try to get // the VPC ID from the subnet_id. VpcId string `mapstructure:"vpc_id" required:"false"` // The timeout for waiting for a Windows // password for Windows instances. Defaults to 20 minutes. Example value: // 10m WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout" required:"false"` // [Metadata Settings](#metadata-settings) Metadata MetadataOptions `mapstructure:"metadata_options" required:"false"` // Communicator settings Comm communicator.Config `mapstructure:",squash"` // One of `public_ip`, `private_ip`, `public_dns`, `private_dns` or `session_manager`. // If set, either the public IP address, private IP address, public DNS name // or private DNS name will be used as the host for SSH. The default behaviour // if inside a VPC is to use the public IP address if available, otherwise // the private IP address will be used. If not in a VPC the public DNS name // will be used. Also works for WinRM. // // Where Packer is configured for an outbound proxy but WinRM traffic // should be direct, `ssh_interface` must be set to `private_dns` and // `<region>.compute.internal` included in the `NO_PROXY` environment // variable. // // When using `session_manager` the machine running Packer must have // the AWS Session Manager Plugin installed and within the users' system path. // Connectivity via the `session_manager` interface establishes a secure tunnel // between the local host and the remote host on an available local port to the specified `ssh_port`. // See [Session Manager Connections](#session-manager-connections) for more information. // - Session manager connectivity is currently only implemented for the SSH communicator, not the WinRM communicator. // - Upon termination the secure tunnel will be terminated automatically, if however there is a failure in // terminating the tunnel it will automatically terminate itself after 20 minutes of inactivity. SSHInterface string `mapstructure:"ssh_interface"` // The time to wait before establishing the Session Manager session. // The value of this should be a duration. Examples are // `5s` and `1m30s` which will cause Packer to wait five seconds and one // minute 30 seconds, respectively. If no set, defaults to 10 seconds. // This option is useful when the remote port takes longer to become available. PauseBeforeSSM time.Duration `mapstructure:"pause_before_ssm"` // Which port to connect the local end of the session tunnel to. If // left blank, Packer will choose a port for you from available ports. // This option is only used when `ssh_interface` is set `session_manager`. SessionManagerPort int `mapstructure:"session_manager_port"` }
RunConfig contains configuration for running an instance from a source AMI and details on how to access that launched image.
func (*RunConfig) IsBurstableInstanceType ¶ added in v1.1.5
IsBurstableInstanceType checks if the InstanceType for the config is one of the following types T2, T3a, T3, T4g
func (*RunConfig) IsSpotInstance ¶
func (*RunConfig) SSMAgentEnabled ¶
type SecurityGroupFilterOptions ¶
type SecurityGroupFilterOptions struct {
config.NameValueFilter `mapstructure:",squash"`
}
func (*SecurityGroupFilterOptions) FlatMapstructure ¶
func (*SecurityGroupFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatSecurityGroupFilterOptions. FlatSecurityGroupFilterOptions is an auto-generated flat version of SecurityGroupFilterOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type SnapshotConfig ¶
type SnapshotConfig struct { // Key/value pair tags to apply to snapshot. They will override AMI tags if // already applied to snapshot. This is a [template // engine](/packer/docs/templates/legacy_json_templates/engine), see [Build template // data](#build-template-data) for more information. SnapshotTags map[string]string `mapstructure:"snapshot_tags" required:"false"` // Same as [`snapshot_tags`](#snapshot_tags) but defined as a singular // repeatable block containing a `key` and a `value` field. In HCL2 mode the // [`dynamic_block`](/packer/docs/templates/hcl_templates/expressions#dynamic-blocks) // will allow you to create those programatically. SnapshotTag config.KeyValues `mapstructure:"snapshot_tag" required:"false"` // A list of account IDs that have // access to create volumes from the snapshot(s). By default no additional // users other than the user creating the AMI has permissions to create // volumes from the backing snapshot(s). SnapshotUsers []string `mapstructure:"snapshot_users" required:"false"` // A list of groups that have access to // create volumes from the snapshot(s). By default no groups have permission // to create volumes from the snapshot(s). all will make the snapshot // publicly accessible. SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false"` }
SnapshotConfig is for common configuration related to creating AMIs.
type StateChangeConf ¶
type StateChangeConf struct { Pending []string Refresh StateRefreshFunc StepState multistep.StateBag Target string }
StateChangeConf is the configuration struct used for `WaitForState`.
type StateRefreshFunc ¶
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 Statement ¶
type Statement struct { Effect string `mapstructure:"Effect" required:"false"` Action []string `mapstructure:"Action" required:"false"` Resource []string `mapstructure:"Resource" required:"false"` }
func (*Statement) FlatMapstructure ¶
FlatMapstructure returns a new FlatStatement. FlatStatement is an auto-generated flat version of Statement. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type StepAMIRegionCopy ¶
type StepAMIRegionCopy struct { AccessConfig *AccessConfig Regions []string AMIKmsKeyId string RegionKeyIds map[string]string EncryptBootVolume config.Trilean // nil means preserve Name string OriginalRegion string AMISkipCreateImage bool AMISkipBuildRegion bool // contains filtered or unexported fields }
func (*StepAMIRegionCopy) Cleanup ¶
func (s *StepAMIRegionCopy) Cleanup(state multistep.StateBag)
func (*StepAMIRegionCopy) DeduplicateRegions ¶
func (s *StepAMIRegionCopy) DeduplicateRegions(intermediary bool)
func (*StepAMIRegionCopy) Run ¶
func (s *StepAMIRegionCopy) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCleanupVolumes ¶
type StepCleanupVolumes struct {
LaunchMappings 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 ¶
func (s *StepCleanupVolumes) Cleanup(state multistep.StateBag)
func (*StepCleanupVolumes) Run ¶
func (s *StepCleanupVolumes) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCreateSSMTunnel ¶
type StepCreateSSMTunnel struct { AWSSession *session.Session Region string LocalPortNumber int RemotePortNumber int SSMAgentEnabled bool SSHConfig *communicator.SSH PauseBeforeSSM time.Duration // contains filtered or unexported fields }
func (*StepCreateSSMTunnel) Cleanup ¶
func (s *StepCreateSSMTunnel) Cleanup(state multistep.StateBag)
Cleanup terminates an active session on AWS, which in turn terminates the associated tunnel process running on the local machine.
func (*StepCreateSSMTunnel) ConfigureLocalHostPort ¶
func (s *StepCreateSSMTunnel) ConfigureLocalHostPort(ctx context.Context) error
ConfigureLocalHostPort finds an available port on the localhost that can be used for the remote tunnel. Defaults to using s.LocalPortNumber if it is set.
func (*StepCreateSSMTunnel) CreatePersistentSSMSession ¶ added in v1.2.2
func (*StepCreateSSMTunnel) Run ¶
func (s *StepCreateSSMTunnel) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
Run executes the Packer build step that creates a session tunnel.
type StepCreateTags ¶
type StepCreateTags struct { AMISkipCreateImage bool Tags map[string]string SnapshotTags map[string]string Ctx interpolate.Context }
func (*StepCreateTags) Cleanup ¶
func (s *StepCreateTags) Cleanup(state multistep.StateBag)
func (*StepCreateTags) Run ¶
func (s *StepCreateTags) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepDeregisterAMI ¶
type StepDeregisterAMI struct { AccessConfig *AccessConfig ForceDeregister bool ForceDeleteSnapshot bool AMIName string Regions []string }
func (*StepDeregisterAMI) Cleanup ¶
func (s *StepDeregisterAMI) Cleanup(state multistep.StateBag)
func (*StepDeregisterAMI) Run ¶
func (s *StepDeregisterAMI) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepEnableDeprecation ¶ added in v1.3.3
type StepEnableDeprecation struct { AccessConfig *AccessConfig DeprecationTime string AMISkipCreateImage bool }
func (*StepEnableDeprecation) Cleanup ¶ added in v1.3.3
func (s *StepEnableDeprecation) Cleanup(state multistep.StateBag)
func (*StepEnableDeprecation) Run ¶ added in v1.3.3
func (s *StepEnableDeprecation) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepEnableDeregistrationProtection ¶ added in v1.3.4
type StepEnableDeregistrationProtection struct { AccessConfig *AccessConfig AMISkipCreateImage bool DeregistrationProtection *DeregistrationProtectionOptions }
func (*StepEnableDeregistrationProtection) Cleanup ¶ added in v1.3.4
func (s *StepEnableDeregistrationProtection) Cleanup(state multistep.StateBag)
func (*StepEnableDeregistrationProtection) Run ¶ added in v1.3.4
func (s *StepEnableDeregistrationProtection) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepGetPassword ¶
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 ¶
func (s *StepGetPassword) Cleanup(multistep.StateBag)
func (*StepGetPassword) Run ¶
func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepIamInstanceProfile ¶
type StepIamInstanceProfile struct { PollingConfig *AWSPollingConfig IamInstanceProfile string SkipProfileValidation bool TemporaryIamInstanceProfilePolicyDocument *PolicyDocument Tags map[string]string Ctx interpolate.Context // contains filtered or unexported fields }
func (*StepIamInstanceProfile) Cleanup ¶
func (s *StepIamInstanceProfile) Cleanup(state multistep.StateBag)
func (*StepIamInstanceProfile) Run ¶
func (s *StepIamInstanceProfile) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepKeyPair ¶
type StepKeyPair struct { Debug bool Comm *communicator.Config DebugKeyPath string IsRestricted bool Ctx interpolate.Context Tags map[string]string // contains filtered or unexported fields }
func (*StepKeyPair) Cleanup ¶
func (s *StepKeyPair) Cleanup(state multistep.StateBag)
func (*StepKeyPair) Run ¶
func (s *StepKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepModifyAMIAttributes ¶
type StepModifyAMIAttributes struct { AMISkipCreateImage bool Users []string Groups []string OrgArns []string OuArns []string SnapshotUsers []string SnapshotGroups []string ProductCodes []string IMDSSupport string Description string Ctx interpolate.Context GeneratedData *packerbuilderdata.GeneratedData }
func (*StepModifyAMIAttributes) Cleanup ¶
func (s *StepModifyAMIAttributes) Cleanup(state multistep.StateBag)
func (*StepModifyAMIAttributes) Run ¶
func (s *StepModifyAMIAttributes) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepModifyEBSBackedInstance ¶
type StepModifyEBSBackedInstance struct { Skip bool EnableAMIENASupport config.Trilean EnableAMISriovNetSupport bool }
func (*StepModifyEBSBackedInstance) Cleanup ¶
func (s *StepModifyEBSBackedInstance) Cleanup(state multistep.StateBag)
func (*StepModifyEBSBackedInstance) Run ¶
func (s *StepModifyEBSBackedInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepNetworkInfo ¶
type StepNetworkInfo struct { VpcId string VpcFilter VpcFilterOptions SubnetId string SubnetFilter SubnetFilterOptions AssociatePublicIpAddress config.Trilean AvailabilityZone string SecurityGroupIds []string SecurityGroupFilter SecurityGroupFilterOptions // RequestedMachineType is the machine type of the instance we want to create. // This is used for selecting a subnet/AZ which supports the type of instance // selected, and not just the most available / random one. RequestedMachineType string }
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 ¶
func (s *StepNetworkInfo) Cleanup(multistep.StateBag)
func (*StepNetworkInfo) GetDefaultVPCAndSubnet ¶ added in v1.2.5
func (*StepNetworkInfo) Run ¶
func (s *StepNetworkInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepPreValidate ¶
type StepPreValidate struct { DestAmiName string ForceDeregister bool AMISkipBuildRegion bool AMISkipCreateImage bool VpcId string SubnetId string HasSubnetFilter bool }
StepPreValidate provides an opportunity to pre-validate any configuration for the build before actually doing any time consuming work
func (*StepPreValidate) Run ¶
func (s *StepPreValidate) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepRunSourceInstance ¶
type StepRunSourceInstance struct { PollingConfig *AWSPollingConfig AssociatePublicIpAddress config.Trilean LaunchMappings EC2BlockDeviceMappingsBuilder CapacityReservationPreference string CapacityReservationId string CapacityReservationGroupArn string Comm *communicator.Config Ctx interpolate.Context Debug bool EbsOptimized bool EnableUnlimitedCredits bool ExpectedRootDevice string HttpEndpoint string HttpTokens string HttpPutResponseHopLimit int64 InstanceMetadataTags string InstanceInitiatedShutdownBehavior string InstanceType string IsRestricted bool SourceAMI string Tags map[string]string LicenseSpecifications []LicenseSpecification HostResourceGroupArn string HostId string Tenancy string UserData string UserDataFile string VolumeTags map[string]string NoEphemeral bool EnableNitroEnclave bool IsBurstableInstanceType bool // contains filtered or unexported fields }
func (*StepRunSourceInstance) Cleanup ¶
func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag)
func (*StepRunSourceInstance) Run ¶
func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepRunSpotInstance ¶
type StepRunSpotInstance struct { PollingConfig *AWSPollingConfig AssociatePublicIpAddress config.Trilean LaunchMappings EC2BlockDeviceMappingsBuilder BlockDurationMinutes int64 Debug bool Comm *communicator.Config EbsOptimized bool ExpectedRootDevice string FleetTags map[string]string HttpEndpoint string HttpTokens string HttpPutResponseHopLimit int64 InstanceMetadataTags string InstanceInitiatedShutdownBehavior string InstanceType string Region string SourceAMI string SpotPrice string SpotTags map[string]string SpotInstanceTypes []string Tags map[string]string VolumeTags map[string]string UserData string UserDataFile string Ctx interpolate.Context NoEphemeral bool IsBurstableInstanceType bool EnableUnlimitedCredits bool // contains filtered or unexported fields }
func (*StepRunSpotInstance) Cleanup ¶
func (s *StepRunSpotInstance) Cleanup(state multistep.StateBag)
func (*StepRunSpotInstance) CreateTemplateData ¶
func (s *StepRunSpotInstance) CreateTemplateData(userData *string, az string, state multistep.StateBag, marketOptions *ec2.LaunchTemplateInstanceMarketOptionsRequest) *ec2.RequestLaunchTemplateData
func (*StepRunSpotInstance) LoadUserData ¶
func (s *StepRunSpotInstance) LoadUserData() (string, error)
func (*StepRunSpotInstance) Run ¶
func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepSecurityGroup ¶
type StepSecurityGroup struct { CommConfig *communicator.Config SecurityGroupFilter SecurityGroupFilterOptions SecurityGroupIds []string TemporarySGSourceCidrs []string TemporarySGSourcePublicIp bool SkipSSHRuleCreation bool Ctx interpolate.Context IsRestricted bool Tags map[string]string // contains filtered or unexported fields }
func (*StepSecurityGroup) Cleanup ¶
func (s *StepSecurityGroup) Cleanup(state multistep.StateBag)
func (*StepSecurityGroup) Run ¶
func (s *StepSecurityGroup) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepSetGeneratedData ¶
type StepSetGeneratedData struct {
GeneratedData *packerbuilderdata.GeneratedData
}
func (*StepSetGeneratedData) Cleanup ¶
func (s *StepSetGeneratedData) Cleanup(state multistep.StateBag)
func (*StepSetGeneratedData) Run ¶
func (s *StepSetGeneratedData) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepSourceAMIInfo ¶
type StepSourceAMIInfo struct { SourceAmi string EnableAMISriovNetSupport bool EnableAMIENASupport config.Trilean AMIVirtType string AmiFilters AmiFilterOptions IncludeDeprecated bool }
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 ¶
func (s *StepSourceAMIInfo) Cleanup(multistep.StateBag)
func (*StepSourceAMIInfo) Run ¶
func (s *StepSourceAMIInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepStopEBSBackedInstance ¶
type StepStopEBSBackedInstance struct { PollingConfig *AWSPollingConfig Skip bool DisableStopInstance bool }
func (*StepStopEBSBackedInstance) Cleanup ¶
func (s *StepStopEBSBackedInstance) Cleanup(multistep.StateBag)
func (*StepStopEBSBackedInstance) Run ¶
func (s *StepStopEBSBackedInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type SubnetFilterOptions ¶
type SubnetFilterOptions struct { config.NameValueFilter `mapstructure:",squash"` MostFree bool `mapstructure:"most_free"` Random bool `mapstructure:"random"` }
func (*SubnetFilterOptions) FlatMapstructure ¶
func (*SubnetFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatSubnetFilterOptions. FlatSubnetFilterOptions is an auto-generated flat version of SubnetFilterOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type VaultAWSEngineOptions ¶
type VaultAWSEngineOptions struct { Name string `mapstructure:"name"` RoleARN string `mapstructure:"role_arn"` // Specifies the TTL for the use of the STS token. This // is specified as a string with a duration suffix. Valid only when // credential_type is assumed_role or federation_token. When not // specified, the default_sts_ttl set for the role will be used. If that // is also not set, then the default value of 3600s will be used. AWS // places limits on the maximum TTL allowed. See the AWS documentation on // the DurationSeconds parameter for AssumeRole (for assumed_role // credential types) and GetFederationToken (for federation_token // credential types) for more details. TTL string `mapstructure:"ttl" required:"false"` EngineName string `mapstructure:"engine_name"` }
func (*VaultAWSEngineOptions) Empty ¶
func (v *VaultAWSEngineOptions) Empty() bool
func (*VaultAWSEngineOptions) FlatMapstructure ¶
func (*VaultAWSEngineOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatVaultAWSEngineOptions. FlatVaultAWSEngineOptions is an auto-generated flat version of VaultAWSEngineOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
type VpcFilterOptions ¶
type VpcFilterOptions struct {
config.NameValueFilter `mapstructure:",squash"`
}
func (*VpcFilterOptions) FlatMapstructure ¶
func (*VpcFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }
FlatMapstructure returns a new FlatVpcFilterOptions. FlatVpcFilterOptions is an auto-generated flat version of VpcFilterOptions. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
Source Files
¶
- access_config.go
- access_config.hcl2spec.go
- ami_config.go
- ami_config.hcl2spec.go
- ami_filter.go
- artifact.go
- block_device.go
- block_device.hcl2spec.go
- boot_mode_validation.go
- build_filter.go
- checkip.go
- errors.go
- helper_funcs.go
- interpolate_build_info.go
- regions.go
- run_config.go
- run_config.hcl2spec.go
- snapshot_config.go
- ssh.go
- state.go
- state.hcl2spec.go
- step_ami_region_copy.go
- step_cleanup_volumes.go
- step_create_ssm_tunnel.go
- step_create_tags.go
- step_deregister_ami.go
- step_enable_deprecation.go
- step_enable_deregistration_protection.go
- step_get_password.go
- step_iam_instance_profile.go
- step_key_pair.go
- step_modify_ami_attributes.go
- step_modify_ebs_instance.go
- step_network_info.go
- step_pre_validate.go
- step_run_source_instance.go
- step_run_spot_instance.go
- step_security_group.go
- step_set_generated_data.go
- step_source_ami_info.go
- step_stop_ebs_instance.go
- tags.go
- template_funcs.go
- test_helper_funcs.go