common

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MPL-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func DecodeAuthZMessages

func DecodeAuthZMessages(cfg aws.Config)

DecodeAuthZMessages enables automatic decoding of any encoded authorization messages

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()

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) Config

func (c *AccessConfig) Config(ctx context.Context) (*aws.Config, 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) GetCredsFromVault

func (c *AccessConfig) GetCredsFromVault() error

func (*AccessConfig) IsChinaCloud

func (c *AccessConfig) IsChinaCloud() bool

func (*AccessConfig) IsGovCloud

func (c *AccessConfig) IsGovCloud() bool

func (*AccessConfig) NewEC2Client

func (c *AccessConfig) NewEC2Client(ctx context.Context) (Ec2Client, error)

NewEC2Client return a aws sdk v2 ec2 client object

func (*AccessConfig) NewNoValidCredentialSourcesError

func (c *AccessConfig) NewNoValidCredentialSourcesError(err error) error

func (*AccessConfig) Prepare

func (c *AccessConfig) Prepare(packerConfig *common.PackerConfig) []error

func (*AccessConfig) SessionRegion

func (c *AccessConfig) SessionRegion() string

func (*AccessConfig) ValidateRegion

func (c *AccessConfig) ValidateRegion(ctx context.Context, 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) GetFilteredImage

func (d *AmiFilterOptions) GetFilteredImage(ctx context.Context, params *ec2.DescribeImagesInput, client Ec2Client) (*types.Image, error)

func (*AmiFilterOptions) GetOwners

func (d *AmiFilterOptions) GetOwners() []string

func (*AmiFilterOptions) NoOwner

func (d *AmiFilterOptions) NoOwner() bool

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 DeregistrationProtectionOptions

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

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 Ec2Client

type Ec2Client interface {
	ec2.DescribeImagesAPIClient
	DescribeRegions(ctx context.Context, params *ec2.DescribeRegionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error)
}

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 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 FlatDeregistrationProtectionOptions

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

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 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 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

type StateRefreshFunc func() (result any, state string, err error)

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

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

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

type 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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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