Merge pull request #8889 from hashicorp/hcl2_singular_blocks
Hcl2 singular blocks
This commit is contained in:
commit
23f56036a4
1
Makefile
1
Makefile
@ -121,7 +121,6 @@ generate: install-gen-deps ## Generate dynamically generated code
|
|||||||
@find post-processor common helper template builder provisioner -type f | xargs grep -l '^// Code generated' | xargs rm
|
@find post-processor common helper template builder provisioner -type f | xargs grep -l '^// Code generated' | xargs rm
|
||||||
go generate ./...
|
go generate ./...
|
||||||
go fmt common/bootcommand/boot_command.go
|
go fmt common/bootcommand/boot_command.go
|
||||||
go fmt command/plugin.go
|
|
||||||
|
|
||||||
generate-check: generate ## Check go code generation is on par
|
generate-check: generate ## Check go code generation is on par
|
||||||
@echo "==> Checking that auto-generated code is not changed..."
|
@echo "==> Checking that auto-generated code is not changed..."
|
||||||
|
@ -3,6 +3,7 @@ package ecs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,99 +47,100 @@ func (*FlatAlicloudDiskDevice) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatConfig is an auto-generated flat version of Config.
|
// FlatConfig is an auto-generated flat version of Config.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatConfig struct {
|
type FlatConfig struct {
|
||||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
||||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
||||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
||||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
||||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
||||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
||||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
||||||
AlicloudAccessKey *string `mapstructure:"access_key" required:"false" cty:"access_key"`
|
AlicloudAccessKey *string `mapstructure:"access_key" required:"false" cty:"access_key"`
|
||||||
AlicloudSecretKey *string `mapstructure:"secret_key" required:"false" cty:"secret_key"`
|
AlicloudSecretKey *string `mapstructure:"secret_key" required:"false" cty:"secret_key"`
|
||||||
AlicloudRegion *string `mapstructure:"region" required:"false" cty:"region"`
|
AlicloudRegion *string `mapstructure:"region" required:"false" cty:"region"`
|
||||||
AlicloudSkipValidation *bool `mapstructure:"skip_region_validation" required:"false" cty:"skip_region_validation"`
|
AlicloudSkipValidation *bool `mapstructure:"skip_region_validation" required:"false" cty:"skip_region_validation"`
|
||||||
AlicloudSkipImageValidation *bool `mapstructure:"skip_image_validation" required:"false" cty:"skip_image_validation"`
|
AlicloudSkipImageValidation *bool `mapstructure:"skip_image_validation" required:"false" cty:"skip_image_validation"`
|
||||||
AlicloudProfile *string `mapstructure:"profile" required:"false" cty:"profile"`
|
AlicloudProfile *string `mapstructure:"profile" required:"false" cty:"profile"`
|
||||||
AlicloudSharedCredentialsFile *string `mapstructure:"shared_credentials_file" required:"false" cty:"shared_credentials_file"`
|
AlicloudSharedCredentialsFile *string `mapstructure:"shared_credentials_file" required:"false" cty:"shared_credentials_file"`
|
||||||
SecurityToken *string `mapstructure:"security_token" required:"false" cty:"security_token"`
|
SecurityToken *string `mapstructure:"security_token" required:"false" cty:"security_token"`
|
||||||
AlicloudImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"`
|
AlicloudImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"`
|
||||||
AlicloudImageVersion *string `mapstructure:"image_version" required:"false" cty:"image_version"`
|
AlicloudImageVersion *string `mapstructure:"image_version" required:"false" cty:"image_version"`
|
||||||
AlicloudImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
AlicloudImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
||||||
AlicloudImageShareAccounts []string `mapstructure:"image_share_account" required:"false" cty:"image_share_account"`
|
AlicloudImageShareAccounts []string `mapstructure:"image_share_account" required:"false" cty:"image_share_account"`
|
||||||
AlicloudImageUNShareAccounts []string `mapstructure:"image_unshare_account" cty:"image_unshare_account"`
|
AlicloudImageUNShareAccounts []string `mapstructure:"image_unshare_account" cty:"image_unshare_account"`
|
||||||
AlicloudImageDestinationRegions []string `mapstructure:"image_copy_regions" required:"false" cty:"image_copy_regions"`
|
AlicloudImageDestinationRegions []string `mapstructure:"image_copy_regions" required:"false" cty:"image_copy_regions"`
|
||||||
AlicloudImageDestinationNames []string `mapstructure:"image_copy_names" required:"false" cty:"image_copy_names"`
|
AlicloudImageDestinationNames []string `mapstructure:"image_copy_names" required:"false" cty:"image_copy_names"`
|
||||||
ImageEncrypted *bool `mapstructure:"image_encrypted" required:"false" cty:"image_encrypted"`
|
ImageEncrypted *bool `mapstructure:"image_encrypted" required:"false" cty:"image_encrypted"`
|
||||||
AlicloudImageForceDelete *bool `mapstructure:"image_force_delete" required:"false" cty:"image_force_delete"`
|
AlicloudImageForceDelete *bool `mapstructure:"image_force_delete" required:"false" cty:"image_force_delete"`
|
||||||
AlicloudImageForceDeleteSnapshots *bool `mapstructure:"image_force_delete_snapshots" required:"false" cty:"image_force_delete_snapshots"`
|
AlicloudImageForceDeleteSnapshots *bool `mapstructure:"image_force_delete_snapshots" required:"false" cty:"image_force_delete_snapshots"`
|
||||||
AlicloudImageForceDeleteInstances *bool `mapstructure:"image_force_delete_instances" cty:"image_force_delete_instances"`
|
AlicloudImageForceDeleteInstances *bool `mapstructure:"image_force_delete_instances" cty:"image_force_delete_instances"`
|
||||||
AlicloudImageIgnoreDataDisks *bool `mapstructure:"image_ignore_data_disks" required:"false" cty:"image_ignore_data_disks"`
|
AlicloudImageIgnoreDataDisks *bool `mapstructure:"image_ignore_data_disks" required:"false" cty:"image_ignore_data_disks"`
|
||||||
AlicloudImageTags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
AlicloudImageTags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
||||||
ECSSystemDiskMapping *FlatAlicloudDiskDevice `mapstructure:"system_disk_mapping" required:"false" cty:"system_disk_mapping"`
|
AlicloudImageTag []hcl2template.FlatNameValue `mapstructure:"tag" required:"false" cty:"tag"`
|
||||||
ECSImagesDiskMappings []FlatAlicloudDiskDevice `mapstructure:"image_disk_mappings" required:"false" cty:"image_disk_mappings"`
|
ECSSystemDiskMapping *FlatAlicloudDiskDevice `mapstructure:"system_disk_mapping" required:"false" cty:"system_disk_mapping"`
|
||||||
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" cty:"associate_public_ip_address"`
|
ECSImagesDiskMappings []FlatAlicloudDiskDevice `mapstructure:"image_disk_mappings" required:"false" cty:"image_disk_mappings"`
|
||||||
ZoneId *string `mapstructure:"zone_id" required:"false" cty:"zone_id"`
|
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" cty:"associate_public_ip_address"`
|
||||||
IOOptimized *bool `mapstructure:"io_optimized" required:"false" cty:"io_optimized"`
|
ZoneId *string `mapstructure:"zone_id" required:"false" cty:"zone_id"`
|
||||||
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
IOOptimized *bool `mapstructure:"io_optimized" required:"false" cty:"io_optimized"`
|
||||||
Description *string `mapstructure:"description" cty:"description"`
|
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
||||||
AlicloudSourceImage *string `mapstructure:"source_image" required:"true" cty:"source_image"`
|
Description *string `mapstructure:"description" cty:"description"`
|
||||||
ForceStopInstance *bool `mapstructure:"force_stop_instance" required:"false" cty:"force_stop_instance"`
|
AlicloudSourceImage *string `mapstructure:"source_image" required:"true" cty:"source_image"`
|
||||||
DisableStopInstance *bool `mapstructure:"disable_stop_instance" required:"false" cty:"disable_stop_instance"`
|
ForceStopInstance *bool `mapstructure:"force_stop_instance" required:"false" cty:"force_stop_instance"`
|
||||||
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
DisableStopInstance *bool `mapstructure:"disable_stop_instance" required:"false" cty:"disable_stop_instance"`
|
||||||
SecurityGroupName *string `mapstructure:"security_group_name" required:"false" cty:"security_group_name"`
|
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
||||||
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"`
|
SecurityGroupName *string `mapstructure:"security_group_name" required:"false" cty:"security_group_name"`
|
||||||
UserDataFile *string `mapstructure:"user_data_file" required:"false" cty:"user_data_file"`
|
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"`
|
||||||
VpcId *string `mapstructure:"vpc_id" required:"false" cty:"vpc_id"`
|
UserDataFile *string `mapstructure:"user_data_file" required:"false" cty:"user_data_file"`
|
||||||
VpcName *string `mapstructure:"vpc_name" required:"false" cty:"vpc_name"`
|
VpcId *string `mapstructure:"vpc_id" required:"false" cty:"vpc_id"`
|
||||||
CidrBlock *string `mapstructure:"vpc_cidr_block" required:"false" cty:"vpc_cidr_block"`
|
VpcName *string `mapstructure:"vpc_name" required:"false" cty:"vpc_name"`
|
||||||
VSwitchId *string `mapstructure:"vswitch_id" required:"false" cty:"vswitch_id"`
|
CidrBlock *string `mapstructure:"vpc_cidr_block" required:"false" cty:"vpc_cidr_block"`
|
||||||
VSwitchName *string `mapstructure:"vswitch_name" required:"false" cty:"vswitch_name"`
|
VSwitchId *string `mapstructure:"vswitch_id" required:"false" cty:"vswitch_id"`
|
||||||
InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name"`
|
VSwitchName *string `mapstructure:"vswitch_name" required:"false" cty:"vswitch_name"`
|
||||||
InternetChargeType *string `mapstructure:"internet_charge_type" required:"false" cty:"internet_charge_type"`
|
InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name"`
|
||||||
InternetMaxBandwidthOut *int `mapstructure:"internet_max_bandwidth_out" required:"false" cty:"internet_max_bandwidth_out"`
|
InternetChargeType *string `mapstructure:"internet_charge_type" required:"false" cty:"internet_charge_type"`
|
||||||
WaitSnapshotReadyTimeout *int `mapstructure:"wait_snapshot_ready_timeout" required:"false" cty:"wait_snapshot_ready_timeout"`
|
InternetMaxBandwidthOut *int `mapstructure:"internet_max_bandwidth_out" required:"false" cty:"internet_max_bandwidth_out"`
|
||||||
Type *string `mapstructure:"communicator" cty:"communicator"`
|
WaitSnapshotReadyTimeout *int `mapstructure:"wait_snapshot_ready_timeout" required:"false" cty:"wait_snapshot_ready_timeout"`
|
||||||
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
Type *string `mapstructure:"communicator" cty:"communicator"`
|
||||||
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
||||||
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
||||||
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
||||||
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
||||||
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
||||||
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
||||||
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
||||||
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
||||||
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
||||||
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
||||||
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
||||||
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
||||||
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
||||||
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
||||||
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
||||||
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
||||||
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
||||||
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
||||||
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
||||||
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
||||||
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
||||||
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
||||||
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
||||||
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
||||||
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
||||||
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
||||||
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
||||||
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
||||||
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
||||||
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
||||||
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
||||||
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
||||||
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
||||||
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
||||||
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
||||||
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
||||||
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
||||||
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
||||||
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
||||||
SSHPrivateIp *bool `mapstructure:"ssh_private_ip" required:"false" cty:"ssh_private_ip"`
|
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
||||||
|
SSHPrivateIp *bool `mapstructure:"ssh_private_ip" required:"false" cty:"ssh_private_ip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatConfig.
|
// FlatMapstructure returns a new FlatConfig.
|
||||||
@ -181,6 +183,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"image_force_delete_instances": &hcldec.AttrSpec{Name: "image_force_delete_instances", Type: cty.Bool, Required: false},
|
"image_force_delete_instances": &hcldec.AttrSpec{Name: "image_force_delete_instances", Type: cty.Bool, Required: false},
|
||||||
"image_ignore_data_disks": &hcldec.AttrSpec{Name: "image_ignore_data_disks", Type: cty.Bool, Required: false},
|
"image_ignore_data_disks": &hcldec.AttrSpec{Name: "image_ignore_data_disks", Type: cty.Bool, Required: false},
|
||||||
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
||||||
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"system_disk_mapping": &hcldec.BlockSpec{TypeName: "system_disk_mapping", Nested: hcldec.ObjectSpec((*FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
"system_disk_mapping": &hcldec.BlockSpec{TypeName: "system_disk_mapping", Nested: hcldec.ObjectSpec((*FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
||||||
"image_disk_mappings": &hcldec.BlockListSpec{TypeName: "image_disk_mappings", Nested: hcldec.ObjectSpec((*FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
"image_disk_mappings": &hcldec.BlockListSpec{TypeName: "image_disk_mappings", Nested: hcldec.ObjectSpec((*FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
||||||
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/config"
|
"github.com/hashicorp/packer/helper/config"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
@ -189,14 +190,19 @@ type AlicloudImageConfig struct {
|
|||||||
// The region validation can be skipped
|
// The region validation can be skipped
|
||||||
// if this value is true, the default value is false.
|
// if this value is true, the default value is false.
|
||||||
AlicloudImageSkipRegionValidation bool `mapstructure:"skip_region_validation" required:"false"`
|
AlicloudImageSkipRegionValidation bool `mapstructure:"skip_region_validation" required:"false"`
|
||||||
// Tags applied to the destination
|
// Tags applied to the destination image and relevant snapshots.
|
||||||
// image and relevant snapshots.
|
AlicloudImageTags map[string]string `mapstructure:"tags" required:"false"`
|
||||||
AlicloudImageTags map[string]string `mapstructure:"tags" required:"false"`
|
// Same as [`tags`](#tags) but defined as a singular repeatable block
|
||||||
|
// containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
AlicloudImageTag hcl2template.NameValues `mapstructure:"tag" required:"false"`
|
||||||
AlicloudDiskDevices `mapstructure:",squash"`
|
AlicloudDiskDevices `mapstructure:",squash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AlicloudImageConfig) Prepare(ctx *interpolate.Context) []error {
|
func (c *AlicloudImageConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
var errs []error
|
var errs []error
|
||||||
|
errs = append(errs, c.AlicloudImageTag.CopyOn(&c.AlicloudImageTags)...)
|
||||||
if c.AlicloudImageName == "" {
|
if c.AlicloudImageName == "" {
|
||||||
errs = append(errs, fmt.Errorf("image_name must be specified"))
|
errs = append(errs, fmt.Errorf("image_name must be specified"))
|
||||||
} else if len(c.AlicloudImageName) < 2 || len(c.AlicloudImageName) > 128 {
|
} else if len(c.AlicloudImageName) < 2 || len(c.AlicloudImageName) > 128 {
|
||||||
@ -228,9 +234,5 @@ func (c *AlicloudImageConfig) Prepare(ctx *interpolate.Context) []error {
|
|||||||
c.AlicloudImageDestinationRegions = regions
|
c.AlicloudImageDestinationRegions = regions
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
return errs
|
||||||
return errs
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
||||||
"github.com/hashicorp/packer/common"
|
"github.com/hashicorp/packer/common"
|
||||||
"github.com/hashicorp/packer/common/chroot"
|
"github.com/hashicorp/packer/common/chroot"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/config"
|
"github.com/hashicorp/packer/helper/config"
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
@ -162,7 +163,12 @@ type Config struct {
|
|||||||
// Tags to apply to the volumes that are *launched*. This is a [template
|
// Tags to apply to the volumes that are *launched*. This is a [template
|
||||||
// engine](/docs/templates/engine.html), see [Build template
|
// engine](/docs/templates/engine.html), see [Build template
|
||||||
// data](#build-template-data) for more information.
|
// data](#build-template-data) for more information.
|
||||||
RootVolumeTags awscommon.TagMap `mapstructure:"root_volume_tags" required:"false"`
|
RootVolumeTags map[string]string `mapstructure:"root_volume_tags" required:"false"`
|
||||||
|
// Same as [`root_volume_tags`](#root_volume_tags) but defined as a
|
||||||
|
// singular block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
RootVolumeTag hcl2template.NameValues `mapstructure:"root_volume_tag" required:"false"`
|
||||||
// what architecture to use when registering the final AMI; valid options
|
// what architecture to use when registering the final AMI; valid options
|
||||||
// are "x86_64" or "arm64". Defaults to "x86_64".
|
// are "x86_64" or "arm64". Defaults to "x86_64".
|
||||||
Architecture string `mapstructure:"ami_architecture" required:"false"`
|
Architecture string `mapstructure:"ami_architecture" required:"false"`
|
||||||
@ -253,6 +259,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|||||||
var errs *packer.MultiError
|
var errs *packer.MultiError
|
||||||
var warns []string
|
var warns []string
|
||||||
|
|
||||||
|
errs = packer.MultiErrorAppend(errs, b.config.RootVolumeTag.CopyOn(&b.config.RootVolumeTags)...)
|
||||||
|
errs = packer.MultiErrorAppend(errs, b.config.SourceAmiFilter.Prepare()...)
|
||||||
|
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs,
|
errs = packer.MultiErrorAppend(errs,
|
||||||
b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
|
b.config.AMIConfig.Prepare(&b.config.AccessConfig, &b.config.ctx)...)
|
||||||
|
@ -4,6 +4,7 @@ package chroot
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/builder/amazon/common"
|
"github.com/hashicorp/packer/builder/amazon/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,7 +26,8 @@ type FlatConfig struct {
|
|||||||
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
||||||
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
||||||
AMISkipRegionValidation *bool `mapstructure:"skip_region_validation" required:"false" cty:"skip_region_validation"`
|
AMISkipRegionValidation *bool `mapstructure:"skip_region_validation" required:"false" cty:"skip_region_validation"`
|
||||||
AMITags common.TagMap `mapstructure:"tags" required:"false" cty:"tags"`
|
AMITags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
||||||
|
AMITag []hcl2template.FlatNameValue `mapstructure:"tag" required:"false" cty:"tag"`
|
||||||
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
||||||
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
||||||
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
||||||
@ -34,7 +36,8 @@ type FlatConfig struct {
|
|||||||
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
||||||
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
||||||
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
||||||
SnapshotTags common.TagMap `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
SnapshotTags map[string]string `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
||||||
|
SnapshotTag []hcl2template.FlatNameValue `mapstructure:"snapshot_tag" required:"false" cty:"snapshot_tag"`
|
||||||
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
||||||
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
||||||
AccessKey *string `mapstructure:"access_key" required:"true" cty:"access_key"`
|
AccessKey *string `mapstructure:"access_key" required:"true" cty:"access_key"`
|
||||||
@ -66,7 +69,8 @@ type FlatConfig struct {
|
|||||||
RootVolumeType *string `mapstructure:"root_volume_type" required:"false" cty:"root_volume_type"`
|
RootVolumeType *string `mapstructure:"root_volume_type" required:"false" cty:"root_volume_type"`
|
||||||
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
||||||
SourceAmiFilter *common.FlatAmiFilterOptions `mapstructure:"source_ami_filter" required:"false" cty:"source_ami_filter"`
|
SourceAmiFilter *common.FlatAmiFilterOptions `mapstructure:"source_ami_filter" required:"false" cty:"source_ami_filter"`
|
||||||
RootVolumeTags common.TagMap `mapstructure:"root_volume_tags" required:"false" cty:"root_volume_tags"`
|
RootVolumeTags map[string]string `mapstructure:"root_volume_tags" required:"false" cty:"root_volume_tags"`
|
||||||
|
RootVolumeTag []hcl2template.FlatNameValue `mapstructure:"root_volume_tag" required:"false" cty:"root_volume_tag"`
|
||||||
Architecture *string `mapstructure:"ami_architecture" required:"false" cty:"ami_architecture"`
|
Architecture *string `mapstructure:"ami_architecture" required:"false" cty:"ami_architecture"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +102,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
||||||
"skip_region_validation": &hcldec.AttrSpec{Name: "skip_region_validation", Type: cty.Bool, Required: false},
|
"skip_region_validation": &hcldec.AttrSpec{Name: "skip_region_validation", Type: cty.Bool, Required: false},
|
||||||
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
||||||
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
||||||
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
||||||
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
||||||
@ -107,6 +112,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
||||||
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
||||||
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"snapshot_tag": &hcldec.BlockListSpec{TypeName: "snapshot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
||||||
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
||||||
"access_key": &hcldec.AttrSpec{Name: "access_key", Type: cty.String, Required: false},
|
"access_key": &hcldec.AttrSpec{Name: "access_key", Type: cty.String, Required: false},
|
||||||
@ -139,6 +145,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
||||||
"source_ami_filter": &hcldec.BlockSpec{TypeName: "source_ami_filter", Nested: hcldec.ObjectSpec((*common.FlatAmiFilterOptions)(nil).HCL2Spec())},
|
"source_ami_filter": &hcldec.BlockSpec{TypeName: "source_ami_filter", Nested: hcldec.ObjectSpec((*common.FlatAmiFilterOptions)(nil).HCL2Spec())},
|
||||||
"root_volume_tags": &hcldec.BlockAttrsSpec{TypeName: "root_volume_tags", ElementType: cty.String, Required: false},
|
"root_volume_tags": &hcldec.BlockAttrsSpec{TypeName: "root_volume_tags", ElementType: cty.String, Required: false},
|
||||||
|
"root_volume_tag": &hcldec.BlockListSpec{TypeName: "root_volume_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"ami_architecture": &hcldec.AttrSpec{Name: "ami_architecture", Type: cty.String, Required: false},
|
"ami_architecture": &hcldec.AttrSpec{Name: "ami_architecture", Type: cty.String, Required: false},
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
@ -23,7 +23,7 @@ type StepCreateVolume struct {
|
|||||||
volumeId string
|
volumeId string
|
||||||
RootVolumeSize int64
|
RootVolumeSize int64
|
||||||
RootVolumeType string
|
RootVolumeType string
|
||||||
RootVolumeTags awscommon.TagMap
|
RootVolumeTags map[string]string
|
||||||
Ctx interpolate.Context
|
Ctx interpolate.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
|
|||||||
instance := state.Get("instance").(*ec2.Instance)
|
instance := state.Get("instance").(*ec2.Instance)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
|
|
||||||
volTags, err := s.RootVolumeTags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
volTags, err := awscommon.TagMap(s.RootVolumeTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error tagging volumes: %s", err)
|
err := fmt.Errorf("Error tagging volumes: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/config"
|
"github.com/hashicorp/packer/helper/config"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
@ -49,7 +50,12 @@ type AMIConfig struct {
|
|||||||
// Tags applied to the AMI. This is a
|
// Tags applied to the AMI. This is a
|
||||||
// [template engine](/docs/templates/engine.html), see [Build template
|
// [template engine](/docs/templates/engine.html), see [Build template
|
||||||
// data](#build-template-data) for more information.
|
// data](#build-template-data) for more information.
|
||||||
AMITags TagMap `mapstructure:"tags" required:"false"`
|
AMITags map[string]string `mapstructure:"tags" required:"false"`
|
||||||
|
// Same as [`tags`](#tags) but defined as a singular repeatable block
|
||||||
|
// containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
AMITag hcl2template.NameValues `mapstructure:"tag" required:"false"`
|
||||||
// Enable enhanced networking (ENA but not SriovNetSupport) on
|
// Enable enhanced networking (ENA but not SriovNetSupport) on
|
||||||
// HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your
|
// HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your
|
||||||
// AWS IAM policy.
|
// AWS IAM policy.
|
||||||
@ -115,7 +121,12 @@ type AMIConfig struct {
|
|||||||
// They will override AMI tags if already applied to snapshot. This is a
|
// They will override AMI tags if already applied to snapshot. This is a
|
||||||
// [template engine](../templates/engine.html), see [Build template
|
// [template engine](../templates/engine.html), see [Build template
|
||||||
// data](#build-template-data) for more information.
|
// data](#build-template-data) for more information.
|
||||||
SnapshotTags TagMap `mapstructure:"snapshot_tags" required:"false"`
|
SnapshotTags map[string]string `mapstructure:"snapshot_tags" required:"false"`
|
||||||
|
// Same as [`snapshot_tags`](#snapshot_tags) but defined as a singular
|
||||||
|
// repeatable block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
SnapshotTag hcl2template.NameValues `mapstructure:"snapshot_tag" required:"false"`
|
||||||
// A list of account IDs that have
|
// A list of account IDs that have
|
||||||
// access to create volumes from the snapshot(s). By default no additional
|
// access to create volumes from the snapshot(s). By default no additional
|
||||||
// users other than the user creating the AMI has permissions to create
|
// users other than the user creating the AMI has permissions to create
|
||||||
@ -140,6 +151,9 @@ func stringInSlice(s []string, searchstr string) bool {
|
|||||||
func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context) []error {
|
func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context) []error {
|
||||||
var errs []error
|
var errs []error
|
||||||
|
|
||||||
|
errs = append(errs, c.SnapshotTag.CopyOn(&c.SnapshotTags)...)
|
||||||
|
errs = append(errs, c.AMITag.CopyOn(&c.AMITags)...)
|
||||||
|
|
||||||
if c.AMIName == "" {
|
if c.AMIName == "" {
|
||||||
errs = append(errs, fmt.Errorf("ami_name must be specified"))
|
errs = append(errs, fmt.Errorf("ami_name must be specified"))
|
||||||
}
|
}
|
||||||
@ -189,7 +203,7 @@ func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context
|
|||||||
}
|
}
|
||||||
for _, kmsKey := range kmsKeys {
|
for _, kmsKey := range kmsKeys {
|
||||||
if !validateKmsKey(kmsKey) {
|
if !validateKmsKey(kmsKey) {
|
||||||
errs = append(errs, fmt.Errorf("%s is not a valid KMS Key Id.", kmsKey))
|
errs = append(errs, fmt.Errorf("%q is not a valid KMS Key Id.", kmsKey))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/common/uuid"
|
"github.com/hashicorp/packer/common/uuid"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
@ -19,9 +20,9 @@ import (
|
|||||||
var reShutdownBehavior = regexp.MustCompile("^(stop|terminate)$")
|
var reShutdownBehavior = regexp.MustCompile("^(stop|terminate)$")
|
||||||
|
|
||||||
type AmiFilterOptions struct {
|
type AmiFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
Owners []string
|
Owners []string
|
||||||
MostRecent bool `mapstructure:"most_recent"`
|
MostRecent bool `mapstructure:"most_recent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *AmiFilterOptions) GetOwners() []*string {
|
func (d *AmiFilterOptions) GetOwners() []*string {
|
||||||
@ -34,7 +35,7 @@ func (d *AmiFilterOptions) GetOwners() []*string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *AmiFilterOptions) Empty() bool {
|
func (d *AmiFilterOptions) Empty() bool {
|
||||||
return len(d.Owners) == 0 && len(d.Filters) == 0
|
return len(d.Owners) == 0 && d.KVFilter.Empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *AmiFilterOptions) NoOwner() bool {
|
func (d *AmiFilterOptions) NoOwner() bool {
|
||||||
@ -42,17 +43,13 @@ func (d *AmiFilterOptions) NoOwner() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SubnetFilterOptions struct {
|
type SubnetFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
MostFree bool `mapstructure:"most_free"`
|
MostFree bool `mapstructure:"most_free"`
|
||||||
Random bool `mapstructure:"random"`
|
Random bool `mapstructure:"random"`
|
||||||
}
|
|
||||||
|
|
||||||
func (d *SubnetFilterOptions) Empty() bool {
|
|
||||||
return len(d.Filters) == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type VpcFilterOptions struct {
|
type VpcFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Statement struct {
|
type Statement struct {
|
||||||
@ -66,16 +63,8 @@ type PolicyDocument struct {
|
|||||||
Statement []Statement
|
Statement []Statement
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *VpcFilterOptions) Empty() bool {
|
|
||||||
return len(d.Filters) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type SecurityGroupFilterOptions struct {
|
type SecurityGroupFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
}
|
|
||||||
|
|
||||||
func (d *SecurityGroupFilterOptions) Empty() bool {
|
|
||||||
return len(d.Filters) == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunConfig contains configuration for running an instance from a source
|
// RunConfig contains configuration for running an instance from a source
|
||||||
@ -198,6 +187,11 @@ type RunConfig struct {
|
|||||||
// EBS volumes. This is a [template engine](/docs/templates/engine.html),
|
// EBS volumes. This is a [template engine](/docs/templates/engine.html),
|
||||||
// see [Build template data](#build-template-data) for more information.
|
// see [Build template data](#build-template-data) for more information.
|
||||||
RunTags map[string]string `mapstructure:"run_tags" required:"false"`
|
RunTags map[string]string `mapstructure:"run_tags" required:"false"`
|
||||||
|
// Same as [`run_tags`](#run_tags) but defined as a singular repeatable
|
||||||
|
// block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
RunTag hcl2template.NameValues `mapstructure:"run_tag" required:"false"`
|
||||||
// The ID (not the name) of the security
|
// The ID (not the name) of the security
|
||||||
// group to assign to the instance. By default this is not set and Packer will
|
// 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.
|
// automatically create a new temporary security group to allow SSH access.
|
||||||
@ -287,9 +281,14 @@ type RunConfig struct {
|
|||||||
// Windows, Linux/UNIX (Amazon VPC), SUSE Linux (Amazon VPC),
|
// Windows, Linux/UNIX (Amazon VPC), SUSE Linux (Amazon VPC),
|
||||||
// Windows (Amazon VPC)
|
// Windows (Amazon VPC)
|
||||||
SpotPriceAutoProduct string `mapstructure:"spot_price_auto_product" required:"false"`
|
SpotPriceAutoProduct string `mapstructure:"spot_price_auto_product" required:"false"`
|
||||||
// Requires spot_price to be
|
// Requires spot_price to be set. This tells Packer to apply tags to the
|
||||||
// set. This tells Packer to apply tags to the spot request that is issued.
|
// spot request that is issued.
|
||||||
SpotTags map[string]string `mapstructure:"spot_tags" required:"false"`
|
SpotTags map[string]string `mapstructure:"spot_tags" required:"false"`
|
||||||
|
// Same as [`spot_tags`](#spot_tags) but defined as a singular repeatable block
|
||||||
|
// containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
SpotTag hcl2template.NameValues `mapstructure:"spot_tag" required:"false"`
|
||||||
// Filters used to populate the `subnet_id` field.
|
// Filters used to populate the `subnet_id` field.
|
||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
@ -423,6 +422,19 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||||||
// Validation
|
// Validation
|
||||||
errs := c.Comm.Prepare(ctx)
|
errs := c.Comm.Prepare(ctx)
|
||||||
|
|
||||||
|
// Copy singular tag maps
|
||||||
|
errs = append(errs, c.RunTag.CopyOn(&c.RunTags)...)
|
||||||
|
errs = append(errs, c.SpotTag.CopyOn(&c.SpotTags)...)
|
||||||
|
|
||||||
|
for _, preparer := range []interface{ Prepare() []error }{
|
||||||
|
&c.SourceAmiFilter,
|
||||||
|
&c.SecurityGroupFilter,
|
||||||
|
&c.SubnetFilter,
|
||||||
|
&c.VpcFilter,
|
||||||
|
} {
|
||||||
|
errs = append(errs, preparer.Prepare()...)
|
||||||
|
}
|
||||||
|
|
||||||
// Validating ssh_interface
|
// Validating ssh_interface
|
||||||
if c.SSHInterface != "public_ip" &&
|
if c.SSHInterface != "public_ip" &&
|
||||||
c.SSHInterface != "private_ip" &&
|
c.SSHInterface != "private_ip" &&
|
||||||
|
@ -3,15 +3,17 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlatAmiFilterOptions is an auto-generated flat version of AmiFilterOptions.
|
// FlatAmiFilterOptions is an auto-generated flat version of AmiFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatAmiFilterOptions struct {
|
type FlatAmiFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
Owners []string `cty:"owners"`
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
MostRecent *bool `mapstructure:"most_recent" cty:"most_recent"`
|
Owners []string `cty:"owners"`
|
||||||
|
MostRecent *bool `mapstructure:"most_recent" cty:"most_recent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatAmiFilterOptions.
|
// FlatMapstructure returns a new FlatAmiFilterOptions.
|
||||||
@ -27,6 +29,7 @@ func (*AmiFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcl
|
|||||||
func (*FlatAmiFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatAmiFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"owners": &hcldec.AttrSpec{Name: "owners", Type: cty.List(cty.String), Required: false},
|
"owners": &hcldec.AttrSpec{Name: "owners", Type: cty.List(cty.String), Required: false},
|
||||||
"most_recent": &hcldec.AttrSpec{Name: "most_recent", Type: cty.Bool, Required: false},
|
"most_recent": &hcldec.AttrSpec{Name: "most_recent", Type: cty.Bool, Required: false},
|
||||||
}
|
}
|
||||||
@ -61,7 +64,8 @@ func (*FlatPolicyDocument) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatSecurityGroupFilterOptions is an auto-generated flat version of SecurityGroupFilterOptions.
|
// FlatSecurityGroupFilterOptions is an auto-generated flat version of SecurityGroupFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatSecurityGroupFilterOptions struct {
|
type FlatSecurityGroupFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatSecurityGroupFilterOptions.
|
// FlatMapstructure returns a new FlatSecurityGroupFilterOptions.
|
||||||
@ -77,6 +81,7 @@ func (*SecurityGroupFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[
|
|||||||
func (*FlatSecurityGroupFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatSecurityGroupFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@ -111,9 +116,10 @@ func (*FlatStatement) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatSubnetFilterOptions is an auto-generated flat version of SubnetFilterOptions.
|
// FlatSubnetFilterOptions is an auto-generated flat version of SubnetFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatSubnetFilterOptions struct {
|
type FlatSubnetFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
MostFree *bool `mapstructure:"most_free" cty:"most_free"`
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
Random *bool `mapstructure:"random" cty:"random"`
|
MostFree *bool `mapstructure:"most_free" cty:"most_free"`
|
||||||
|
Random *bool `mapstructure:"random" cty:"random"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatSubnetFilterOptions.
|
// FlatMapstructure returns a new FlatSubnetFilterOptions.
|
||||||
@ -129,6 +135,7 @@ func (*SubnetFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]
|
|||||||
func (*FlatSubnetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatSubnetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"most_free": &hcldec.AttrSpec{Name: "most_free", Type: cty.Bool, Required: false},
|
"most_free": &hcldec.AttrSpec{Name: "most_free", Type: cty.Bool, Required: false},
|
||||||
"random": &hcldec.AttrSpec{Name: "random", Type: cty.Bool, Required: false},
|
"random": &hcldec.AttrSpec{Name: "random", Type: cty.Bool, Required: false},
|
||||||
}
|
}
|
||||||
@ -138,7 +145,8 @@ func (*FlatSubnetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatVpcFilterOptions is an auto-generated flat version of VpcFilterOptions.
|
// FlatVpcFilterOptions is an auto-generated flat version of VpcFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatVpcFilterOptions struct {
|
type FlatVpcFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatVpcFilterOptions.
|
// FlatMapstructure returns a new FlatVpcFilterOptions.
|
||||||
@ -154,6 +162,7 @@ func (*VpcFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcl
|
|||||||
func (*FlatVpcFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatVpcFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ func TestRunConfigPrepare_SourceAmiFilterOwnersBlank(t *testing.T) {
|
|||||||
c := testConfigFilter()
|
c := testConfigFilter()
|
||||||
filter_key := "name"
|
filter_key := "name"
|
||||||
filter_value := "foo"
|
filter_value := "foo"
|
||||||
c.SourceAmiFilter = AmiFilterOptions{Filters: map[string]string{filter_key: filter_value}}
|
c.SourceAmiFilter.Filters = map[string]string{filter_key: filter_value}
|
||||||
if err := c.Prepare(nil); len(err) != 1 {
|
if err := c.Prepare(nil); len(err) != 1 {
|
||||||
t.Fatalf("Should error if Owners is not specified)")
|
t.Fatalf("Should error if Owners is not specified)")
|
||||||
}
|
}
|
||||||
@ -84,7 +85,12 @@ func TestRunConfigPrepare_SourceAmiFilterGood(t *testing.T) {
|
|||||||
owner := "123"
|
owner := "123"
|
||||||
filter_key := "name"
|
filter_key := "name"
|
||||||
filter_value := "foo"
|
filter_value := "foo"
|
||||||
goodFilter := AmiFilterOptions{Owners: []string{owner}, Filters: map[string]string{filter_key: filter_value}}
|
goodFilter := AmiFilterOptions{
|
||||||
|
Owners: []string{owner},
|
||||||
|
KVFilter: hcl2template.KVFilter{
|
||||||
|
Filters: map[string]string{filter_key: filter_value},
|
||||||
|
},
|
||||||
|
}
|
||||||
c.SourceAmiFilter = goodFilter
|
c.SourceAmiFilter = goodFilter
|
||||||
if err := c.Prepare(nil); len(err) != 0 {
|
if err := c.Prepare(nil); len(err) != 0 {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type StepCreateTags struct {
|
type StepCreateTags struct {
|
||||||
Tags TagMap
|
Tags map[string]string
|
||||||
SnapshotTags TagMap
|
SnapshotTags map[string]string
|
||||||
Ctx interpolate.Context
|
Ctx interpolate.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ func (s *StepCreateTags) Run(ctx context.Context, state multistep.StateBag) mult
|
|||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
amis := state.Get("amis").(map[string]string)
|
amis := state.Get("amis").(map[string]string)
|
||||||
|
|
||||||
if !s.Tags.IsSet() && !s.SnapshotTags.IsSet() {
|
if len(s.Tags) == 0 && len(s.SnapshotTags) == 0 {
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ func (s *StepCreateTags) Run(ctx context.Context, state multistep.StateBag) mult
|
|||||||
|
|
||||||
// Convert tags to ec2.Tag format
|
// Convert tags to ec2.Tag format
|
||||||
ui.Say("Creating AMI tags")
|
ui.Say("Creating AMI tags")
|
||||||
amiTags, err := s.Tags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
amiTags, err := TagMap(s.Tags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
@ -81,7 +81,7 @@ func (s *StepCreateTags) Run(ctx context.Context, state multistep.StateBag) mult
|
|||||||
amiTags.Report(ui)
|
amiTags.Report(ui)
|
||||||
|
|
||||||
ui.Say("Creating snapshot tags")
|
ui.Say("Creating snapshot tags")
|
||||||
snapshotTags, err := s.SnapshotTags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
snapshotTags, err := TagMap(s.SnapshotTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
|
@ -31,10 +31,10 @@ type StepRunSourceInstance struct {
|
|||||||
InstanceType string
|
InstanceType string
|
||||||
IsRestricted bool
|
IsRestricted bool
|
||||||
SourceAMI string
|
SourceAMI string
|
||||||
Tags TagMap
|
Tags map[string]string
|
||||||
UserData string
|
UserData string
|
||||||
UserDataFile string
|
UserDataFile string
|
||||||
VolumeTags TagMap
|
VolumeTags map[string]string
|
||||||
NoEphemeral bool
|
NoEphemeral bool
|
||||||
|
|
||||||
instanceId string
|
instanceId string
|
||||||
@ -88,7 +88,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
|
|||||||
s.Tags["Name"] = "Packer Builder"
|
s.Tags["Name"] = "Packer Builder"
|
||||||
}
|
}
|
||||||
|
|
||||||
ec2Tags, err := s.Tags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
ec2Tags, err := TagMap(s.Tags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error tagging source instance: %s", err)
|
err := fmt.Errorf("Error tagging source instance: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
@ -96,7 +96,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
volTags, err := s.VolumeTags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
volTags, err := TagMap(s.VolumeTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error tagging volumes: %s", err)
|
err := fmt.Errorf("Error tagging volumes: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
@ -322,10 +322,10 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(volumeIds) > 0 && s.VolumeTags.IsSet() {
|
if len(volumeIds) > 0 && len(s.VolumeTags) > 0 {
|
||||||
ui.Say("Adding tags to source EBS Volumes")
|
ui.Say("Adding tags to source EBS Volumes")
|
||||||
|
|
||||||
volumeTags, err := s.VolumeTags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
volumeTags, err := TagMap(s.VolumeTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error tagging source EBS Volumes on %s: %s", *instance.InstanceId, err)
|
err := fmt.Errorf("Error tagging source EBS Volumes on %s: %s", *instance.InstanceId, err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -34,10 +34,10 @@ type StepRunSpotInstance struct {
|
|||||||
InstanceType string
|
InstanceType string
|
||||||
SourceAMI string
|
SourceAMI string
|
||||||
SpotPrice string
|
SpotPrice string
|
||||||
SpotTags TagMap
|
SpotTags map[string]string
|
||||||
SpotInstanceTypes []string
|
SpotInstanceTypes []string
|
||||||
Tags TagMap
|
Tags map[string]string
|
||||||
VolumeTags TagMap
|
VolumeTags map[string]string
|
||||||
UserData string
|
UserData string
|
||||||
UserDataFile string
|
UserDataFile string
|
||||||
Ctx interpolate.Context
|
Ctx interpolate.Context
|
||||||
@ -194,7 +194,7 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert tags from the tag map provided by the user into *ec2.Tag s
|
// Convert tags from the tag map provided by the user into *ec2.Tag s
|
||||||
ec2Tags, err := s.Tags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
ec2Tags, err := TagMap(s.Tags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error generating tags for source instance: %s", err)
|
err := fmt.Errorf("Error generating tags for source instance: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
@ -336,7 +336,7 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||||||
instance := describeOutput.Reservations[0].Instances[0]
|
instance := describeOutput.Reservations[0].Instances[0]
|
||||||
|
|
||||||
// Tag the spot instance request (not the eventual spot instance)
|
// Tag the spot instance request (not the eventual spot instance)
|
||||||
spotTags, err := s.SpotTags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
spotTags, err := TagMap(s.SpotTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error generating tags for spot request: %s", err)
|
err := fmt.Errorf("Error generating tags for spot request: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
@ -344,7 +344,7 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(spotTags) > 0 && s.SpotTags.IsSet() {
|
if len(spotTags) > 0 && len(s.SpotTags) > 0 {
|
||||||
spotTags.Report(ui)
|
spotTags.Report(ui)
|
||||||
// Use the instance ID to find out the SIR, so that we can tag the spot
|
// Use the instance ID to find out the SIR, so that we can tag the spot
|
||||||
// request associated with this instance.
|
// request associated with this instance.
|
||||||
@ -400,10 +400,10 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(volumeIds) > 0 && s.VolumeTags.IsSet() {
|
if len(volumeIds) > 0 && len(s.VolumeTags) > 0 {
|
||||||
ui.Say("Adding tags to source EBS Volumes")
|
ui.Say("Adding tags to source EBS Volumes")
|
||||||
|
|
||||||
volumeTags, err := s.VolumeTags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
volumeTags, err := TagMap(s.VolumeTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error tagging source EBS Volumes on %s: %s", *instance.InstanceId, err)
|
err := fmt.Errorf("Error tagging source EBS Volumes on %s: %s", *instance.InstanceId, err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -44,9 +44,9 @@ func getBasicStep() *StepRunSpotInstance {
|
|||||||
InstanceType: "t2.micro",
|
InstanceType: "t2.micro",
|
||||||
SourceAMI: "",
|
SourceAMI: "",
|
||||||
SpotPrice: "auto",
|
SpotPrice: "auto",
|
||||||
SpotTags: TagMap(nil),
|
SpotTags: nil,
|
||||||
Tags: TagMap{},
|
Tags: map[string]string{},
|
||||||
VolumeTags: TagMap(nil),
|
VolumeTags: nil,
|
||||||
UserData: "",
|
UserData: "",
|
||||||
UserDataFile: "",
|
UserDataFile: "",
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,6 @@ func (t EC2Tags) Report(ui packer.Ui) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TagMap) IsSet() bool {
|
|
||||||
return len(t) > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t TagMap) EC2Tags(ictx interpolate.Context, region string, state multistep.StateBag) (EC2Tags, error) {
|
func (t TagMap) EC2Tags(ictx interpolate.Context, region string, state multistep.StateBag) (EC2Tags, error) {
|
||||||
var ec2Tags []*ec2.Tag
|
var ec2Tags []*ec2.Tag
|
||||||
generatedData := builder.GeneratedData{State: state}
|
generatedData := builder.GeneratedData{State: state}
|
||||||
|
@ -211,7 +211,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
|||||||
AMISkipBuildRegion: b.config.AMISkipBuildRegion,
|
AMISkipBuildRegion: b.config.AMISkipBuildRegion,
|
||||||
VpcId: b.config.VpcId,
|
VpcId: b.config.VpcId,
|
||||||
SubnetId: b.config.SubnetId,
|
SubnetId: b.config.SubnetId,
|
||||||
HasSubnetFilter: len(b.config.SubnetFilter.Filters) > 0,
|
HasSubnetFilter: !b.config.SubnetFilter.Empty(),
|
||||||
},
|
},
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
|
@ -4,6 +4,7 @@ package ebs
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/builder/amazon/common"
|
"github.com/hashicorp/packer/builder/amazon/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ type FlatConfig struct {
|
|||||||
AMIGroups []string `mapstructure:"ami_groups" required:"false" cty:"ami_groups"`
|
AMIGroups []string `mapstructure:"ami_groups" required:"false" cty:"ami_groups"`
|
||||||
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
||||||
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
||||||
AMITags common.TagMap `mapstructure:"tags" required:"false" cty:"tags"`
|
AMITags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
||||||
|
AMITag []hcl2template.FlatNameValue `mapstructure:"tag" required:"false" cty:"tag"`
|
||||||
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
||||||
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
||||||
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
||||||
@ -46,7 +48,8 @@ type FlatConfig struct {
|
|||||||
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
||||||
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
||||||
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
||||||
SnapshotTags common.TagMap `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
SnapshotTags map[string]string `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
||||||
|
SnapshotTag []hcl2template.FlatNameValue `mapstructure:"snapshot_tag" required:"false" cty:"snapshot_tag"`
|
||||||
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
||||||
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
||||||
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" required:"false" cty:"associate_public_ip_address"`
|
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" required:"false" cty:"associate_public_ip_address"`
|
||||||
@ -62,6 +65,7 @@ type FlatConfig struct {
|
|||||||
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
||||||
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
||||||
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
||||||
|
RunTag []hcl2template.FlatNameValue `mapstructure:"run_tag" required:"false" cty:"run_tag"`
|
||||||
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
||||||
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
||||||
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
||||||
@ -70,6 +74,7 @@ type FlatConfig struct {
|
|||||||
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
||||||
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
||||||
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
||||||
|
SpotTag []hcl2template.FlatNameValue `mapstructure:"spot_tag" required:"false" cty:"spot_tag"`
|
||||||
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
||||||
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
||||||
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
||||||
@ -166,6 +171,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"ami_product_codes": &hcldec.AttrSpec{Name: "ami_product_codes", Type: cty.List(cty.String), Required: false},
|
"ami_product_codes": &hcldec.AttrSpec{Name: "ami_product_codes", Type: cty.List(cty.String), Required: false},
|
||||||
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
||||||
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
||||||
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
||||||
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
||||||
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
||||||
@ -175,6 +181,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
||||||
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
||||||
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"snapshot_tag": &hcldec.BlockListSpec{TypeName: "snapshot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
||||||
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
||||||
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
||||||
@ -190,6 +197,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
||||||
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
||||||
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
||||||
|
"run_tag": &hcldec.BlockListSpec{TypeName: "run_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
||||||
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
||||||
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
||||||
@ -198,6 +206,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
||||||
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
||||||
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"spot_tag": &hcldec.BlockListSpec{TypeName: "spot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
||||||
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
||||||
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
||||||
|
@ -234,7 +234,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
|||||||
ForceDeregister: b.config.AMIForceDeregister,
|
ForceDeregister: b.config.AMIForceDeregister,
|
||||||
VpcId: b.config.VpcId,
|
VpcId: b.config.VpcId,
|
||||||
SubnetId: b.config.SubnetId,
|
SubnetId: b.config.SubnetId,
|
||||||
HasSubnetFilter: len(b.config.SubnetFilter.Filters) > 0,
|
HasSubnetFilter: !b.config.SubnetFilter.Empty(),
|
||||||
},
|
},
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
|
@ -4,6 +4,7 @@ package ebssurrogate
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/builder/amazon/common"
|
"github.com/hashicorp/packer/builder/amazon/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ type FlatConfig struct {
|
|||||||
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
||||||
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
||||||
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
||||||
|
RunTag []hcl2template.FlatNameValue `mapstructure:"run_tag" required:"false" cty:"run_tag"`
|
||||||
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
||||||
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
||||||
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
||||||
@ -94,6 +96,7 @@ type FlatConfig struct {
|
|||||||
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
||||||
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
||||||
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
||||||
|
SpotTag []hcl2template.FlatNameValue `mapstructure:"spot_tag" required:"false" cty:"spot_tag"`
|
||||||
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
||||||
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
||||||
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
||||||
@ -151,7 +154,8 @@ type FlatConfig struct {
|
|||||||
AMIGroups []string `mapstructure:"ami_groups" required:"false" cty:"ami_groups"`
|
AMIGroups []string `mapstructure:"ami_groups" required:"false" cty:"ami_groups"`
|
||||||
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
||||||
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
||||||
AMITags common.TagMap `mapstructure:"tags" required:"false" cty:"tags"`
|
AMITags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
||||||
|
AMITag []hcl2template.FlatNameValue `mapstructure:"tag" required:"false" cty:"tag"`
|
||||||
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
||||||
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
||||||
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
||||||
@ -160,7 +164,8 @@ type FlatConfig struct {
|
|||||||
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
||||||
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
||||||
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
||||||
SnapshotTags common.TagMap `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
SnapshotTags map[string]string `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
||||||
|
SnapshotTag []hcl2template.FlatNameValue `mapstructure:"snapshot_tag" required:"false" cty:"snapshot_tag"`
|
||||||
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
||||||
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
||||||
AMIMappings []common.FlatBlockDevice `mapstructure:"ami_block_device_mappings" required:"false" cty:"ami_block_device_mappings"`
|
AMIMappings []common.FlatBlockDevice `mapstructure:"ami_block_device_mappings" required:"false" cty:"ami_block_device_mappings"`
|
||||||
@ -215,6 +220,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
||||||
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
||||||
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
||||||
|
"run_tag": &hcldec.BlockListSpec{TypeName: "run_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
||||||
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
||||||
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
||||||
@ -223,6 +229,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
||||||
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
||||||
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"spot_tag": &hcldec.BlockListSpec{TypeName: "spot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
||||||
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
||||||
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
||||||
@ -281,6 +288,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"ami_product_codes": &hcldec.AttrSpec{Name: "ami_product_codes", Type: cty.List(cty.String), Required: false},
|
"ami_product_codes": &hcldec.AttrSpec{Name: "ami_product_codes", Type: cty.List(cty.String), Required: false},
|
||||||
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
||||||
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
||||||
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
||||||
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
||||||
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
||||||
@ -290,6 +298,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
||||||
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
||||||
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"snapshot_tag": &hcldec.BlockListSpec{TypeName: "snapshot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
||||||
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
||||||
"ami_block_device_mappings": &hcldec.BlockListSpec{TypeName: "ami_block_device_mappings", Nested: hcldec.ObjectSpec((*common.FlatBlockDevice)(nil).HCL2Spec())},
|
"ami_block_device_mappings": &hcldec.BlockListSpec{TypeName: "ami_block_device_mappings", Nested: hcldec.ObjectSpec((*common.FlatBlockDevice)(nil).HCL2Spec())},
|
||||||
|
@ -5,6 +5,7 @@ package ebsvolume
|
|||||||
import (
|
import (
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +14,12 @@ type BlockDevice struct {
|
|||||||
// Tags to apply to the volume. These are retained after the builder
|
// Tags to apply to the volume. These are retained after the builder
|
||||||
// completes. This is a [template engine](/docs/templates/engine.html), see
|
// completes. This is a [template engine](/docs/templates/engine.html), see
|
||||||
// [Build template data](#build-template-data) for more information.
|
// [Build template data](#build-template-data) for more information.
|
||||||
Tags awscommon.TagMap `mapstructure:"tags" required:"false"`
|
Tags map[string]string `mapstructure:"tags" required:"false"`
|
||||||
|
// Same as [`tags`](#tags) but defined as a singular repeatable block
|
||||||
|
// containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
Tag hcl2template.NameValues `mapstructure:"tag" required:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockDevices []BlockDevice
|
type BlockDevices []BlockDevice
|
||||||
@ -28,10 +34,15 @@ func (bds BlockDevices) BuildEC2BlockDeviceMappings() []*ec2.BlockDeviceMapping
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bds BlockDevices) Prepare(ctx *interpolate.Context) (errs []error) {
|
func (bds BlockDevices) Prepare(ctx *interpolate.Context) (errs []error) {
|
||||||
|
|
||||||
for _, block := range bds {
|
for _, block := range bds {
|
||||||
|
|
||||||
|
errs = append(errs, block.Tag.CopyOn(&block.Tags)...)
|
||||||
|
|
||||||
if err := block.Prepare(ctx); err != nil {
|
if err := block.Prepare(ctx); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
||||||
"github.com/hashicorp/packer/common"
|
"github.com/hashicorp/packer/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
"github.com/hashicorp/packer/helper/config"
|
"github.com/hashicorp/packer/helper/config"
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
@ -64,7 +65,13 @@ type Config struct {
|
|||||||
// created. Packer will replace all tags on the volume with the tags
|
// created. Packer will replace all tags on the volume with the tags
|
||||||
// configured in the `ebs_volumes` section as soon as the instance is
|
// configured in the `ebs_volumes` section as soon as the instance is
|
||||||
// reported as 'ready'.
|
// reported as 'ready'.
|
||||||
VolumeRunTags awscommon.TagMap `mapstructure:"run_volume_tags"`
|
VolumeRunTags map[string]string `mapstructure:"run_volume_tags"`
|
||||||
|
// Same as [`run_volume_tags`](#run_volume_tags) but defined as a singular
|
||||||
|
// repeatable block containing a `name` and a `value` field. In HCL2 mode
|
||||||
|
// the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
VolumeRunTag hcl2template.NameValues `mapstructure:"run_volume_tag"`
|
||||||
|
|
||||||
launchBlockDevices BlockDevices
|
launchBlockDevices BlockDevices
|
||||||
|
|
||||||
@ -102,6 +109,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|||||||
// Accumulate any errors
|
// Accumulate any errors
|
||||||
var errs *packer.MultiError
|
var errs *packer.MultiError
|
||||||
var warns []string
|
var warns []string
|
||||||
|
errs = packer.MultiErrorAppend(errs, b.config.VolumeRunTag.CopyOn(&b.config.VolumeRunTags)...)
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
|
||||||
errs = packer.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, b.config.launchBlockDevices.Prepare(&b.config.ctx)...)
|
||||||
|
@ -4,23 +4,25 @@ package ebsvolume
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/builder/amazon/common"
|
"github.com/hashicorp/packer/builder/amazon/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlatBlockDevice is an auto-generated flat version of BlockDevice.
|
// FlatBlockDevice is an auto-generated flat version of BlockDevice.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatBlockDevice struct {
|
type FlatBlockDevice struct {
|
||||||
DeleteOnTermination *bool `mapstructure:"delete_on_termination" required:"false" cty:"delete_on_termination"`
|
DeleteOnTermination *bool `mapstructure:"delete_on_termination" required:"false" cty:"delete_on_termination"`
|
||||||
DeviceName *string `mapstructure:"device_name" required:"false" cty:"device_name"`
|
DeviceName *string `mapstructure:"device_name" required:"false" cty:"device_name"`
|
||||||
Encrypted *bool `mapstructure:"encrypted" required:"false" cty:"encrypted"`
|
Encrypted *bool `mapstructure:"encrypted" required:"false" cty:"encrypted"`
|
||||||
IOPS *int64 `mapstructure:"iops" required:"false" cty:"iops"`
|
IOPS *int64 `mapstructure:"iops" required:"false" cty:"iops"`
|
||||||
NoDevice *bool `mapstructure:"no_device" required:"false" cty:"no_device"`
|
NoDevice *bool `mapstructure:"no_device" required:"false" cty:"no_device"`
|
||||||
SnapshotId *string `mapstructure:"snapshot_id" required:"false" cty:"snapshot_id"`
|
SnapshotId *string `mapstructure:"snapshot_id" required:"false" cty:"snapshot_id"`
|
||||||
VirtualName *string `mapstructure:"virtual_name" required:"false" cty:"virtual_name"`
|
VirtualName *string `mapstructure:"virtual_name" required:"false" cty:"virtual_name"`
|
||||||
VolumeType *string `mapstructure:"volume_type" required:"false" cty:"volume_type"`
|
VolumeType *string `mapstructure:"volume_type" required:"false" cty:"volume_type"`
|
||||||
VolumeSize *int64 `mapstructure:"volume_size" required:"false" cty:"volume_size"`
|
VolumeSize *int64 `mapstructure:"volume_size" required:"false" cty:"volume_size"`
|
||||||
KmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
KmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
||||||
Tags common.TagMap `mapstructure:"tags" required:"false" cty:"tags"`
|
Tags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
||||||
|
Tag []hcl2template.FlatNameValue `mapstructure:"tag" required:"false" cty:"tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatBlockDevice.
|
// FlatMapstructure returns a new FlatBlockDevice.
|
||||||
@ -46,6 +48,7 @@ func (*FlatBlockDevice) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"volume_size": &hcldec.AttrSpec{Name: "volume_size", Type: cty.Number, Required: false},
|
"volume_size": &hcldec.AttrSpec{Name: "volume_size", Type: cty.Number, Required: false},
|
||||||
"kms_key_id": &hcldec.AttrSpec{Name: "kms_key_id", Type: cty.String, Required: false},
|
"kms_key_id": &hcldec.AttrSpec{Name: "kms_key_id", Type: cty.String, Required: false},
|
||||||
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
||||||
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@ -86,6 +89,7 @@ type FlatConfig struct {
|
|||||||
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
||||||
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
||||||
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
||||||
|
RunTag []hcl2template.FlatNameValue `mapstructure:"run_tag" required:"false" cty:"run_tag"`
|
||||||
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
||||||
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
||||||
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
||||||
@ -94,6 +98,7 @@ type FlatConfig struct {
|
|||||||
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
||||||
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
||||||
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
||||||
|
SpotTag []hcl2template.FlatNameValue `mapstructure:"spot_tag" required:"false" cty:"spot_tag"`
|
||||||
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
||||||
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
||||||
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
||||||
@ -147,7 +152,8 @@ type FlatConfig struct {
|
|||||||
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
||||||
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
||||||
VolumeMappings []FlatBlockDevice `mapstructure:"ebs_volumes" required:"false" cty:"ebs_volumes"`
|
VolumeMappings []FlatBlockDevice `mapstructure:"ebs_volumes" required:"false" cty:"ebs_volumes"`
|
||||||
VolumeRunTags common.TagMap `mapstructure:"run_volume_tags" cty:"run_volume_tags"`
|
VolumeRunTags map[string]string `mapstructure:"run_volume_tags" cty:"run_volume_tags"`
|
||||||
|
VolumeRunTag []hcl2template.FlatNameValue `mapstructure:"run_volume_tag" cty:"run_volume_tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatConfig.
|
// FlatMapstructure returns a new FlatConfig.
|
||||||
@ -195,6 +201,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
||||||
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
||||||
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
||||||
|
"run_tag": &hcldec.BlockListSpec{TypeName: "run_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
||||||
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
||||||
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
||||||
@ -203,6 +210,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
||||||
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
||||||
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"spot_tag": &hcldec.BlockListSpec{TypeName: "spot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
||||||
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
||||||
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
||||||
@ -257,6 +265,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
||||||
"ebs_volumes": &hcldec.BlockListSpec{TypeName: "ebs_volumes", Nested: hcldec.ObjectSpec((*FlatBlockDevice)(nil).HCL2Spec())},
|
"ebs_volumes": &hcldec.BlockListSpec{TypeName: "ebs_volumes", Nested: hcldec.ObjectSpec((*FlatBlockDevice)(nil).HCL2Spec())},
|
||||||
"run_volume_tags": &hcldec.BlockAttrsSpec{TypeName: "run_volume_tags", ElementType: cty.String, Required: false},
|
"run_volume_tags": &hcldec.BlockAttrsSpec{TypeName: "run_volume_tags", ElementType: cty.String, Required: false},
|
||||||
|
"run_volume_tag": &hcldec.BlockListSpec{TypeName: "run_volume_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
|
awscommon "github.com/hashicorp/packer/builder/amazon/common"
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
@ -43,11 +44,11 @@ func (s *stepTagEBSVolumes) Run(ctx context.Context, state multistep.StateBag) m
|
|||||||
// volume will have had these tags applied when the instance was
|
// volume will have had these tags applied when the instance was
|
||||||
// created. We now need to remove these tags to ensure only the EBS
|
// created. We now need to remove these tags to ensure only the EBS
|
||||||
// volume tags are applied (if any)
|
// volume tags are applied (if any)
|
||||||
if config.VolumeRunTags.IsSet() {
|
if len(config.VolumeRunTags) > 0 {
|
||||||
ui.Say("Removing any tags applied to EBS volumes when the source instance was created...")
|
ui.Say("Removing any tags applied to EBS volumes when the source instance was created...")
|
||||||
|
|
||||||
ui.Message("Compiling list of existing tags to remove...")
|
ui.Message("Compiling list of existing tags to remove...")
|
||||||
existingTags, err := config.VolumeRunTags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
existingTags, err := awscommon.TagMap(config.VolumeRunTags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error generating list of tags to remove: %s", err)
|
err := fmt.Errorf("Error generating list of tags to remove: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
@ -91,7 +92,7 @@ func (s *stepTagEBSVolumes) Run(ctx context.Context, state multistep.StateBag) m
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.Message(fmt.Sprintf("Compiling list of tags to apply to volume on %s...", mapping.DeviceName))
|
ui.Message(fmt.Sprintf("Compiling list of tags to apply to volume on %s...", mapping.DeviceName))
|
||||||
tags, err := mapping.Tags.EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
tags, err := awscommon.TagMap(mapping.Tags).EC2Tags(s.Ctx, *ec2conn.Config.Region, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error generating tags for device %s: %s", mapping.DeviceName, err)
|
err := fmt.Errorf("Error generating tags for device %s: %s", mapping.DeviceName, err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -296,7 +296,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
|||||||
ForceDeregister: b.config.AMIForceDeregister,
|
ForceDeregister: b.config.AMIForceDeregister,
|
||||||
VpcId: b.config.VpcId,
|
VpcId: b.config.VpcId,
|
||||||
SubnetId: b.config.SubnetId,
|
SubnetId: b.config.SubnetId,
|
||||||
HasSubnetFilter: len(b.config.SubnetFilter.Filters) > 0,
|
HasSubnetFilter: !b.config.SubnetFilter.Empty(),
|
||||||
},
|
},
|
||||||
&awscommon.StepSourceAMIInfo{
|
&awscommon.StepSourceAMIInfo{
|
||||||
SourceAmi: b.config.SourceAmi,
|
SourceAmi: b.config.SourceAmi,
|
||||||
|
@ -4,6 +4,7 @@ package instance
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/builder/amazon/common"
|
"github.com/hashicorp/packer/builder/amazon/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ type FlatConfig struct {
|
|||||||
AMIGroups []string `mapstructure:"ami_groups" required:"false" cty:"ami_groups"`
|
AMIGroups []string `mapstructure:"ami_groups" required:"false" cty:"ami_groups"`
|
||||||
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
AMIProductCodes []string `mapstructure:"ami_product_codes" required:"false" cty:"ami_product_codes"`
|
||||||
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
AMIRegions []string `mapstructure:"ami_regions" required:"false" cty:"ami_regions"`
|
||||||
AMITags common.TagMap `mapstructure:"tags" required:"false" cty:"tags"`
|
AMITags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
||||||
|
AMITag []hcl2template.FlatNameValue `mapstructure:"tag" required:"false" cty:"tag"`
|
||||||
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
AMIENASupport *bool `mapstructure:"ena_support" required:"false" cty:"ena_support"`
|
||||||
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
AMISriovNetSupport *bool `mapstructure:"sriov_support" required:"false" cty:"sriov_support"`
|
||||||
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
AMIForceDeregister *bool `mapstructure:"force_deregister" required:"false" cty:"force_deregister"`
|
||||||
@ -46,7 +48,8 @@ type FlatConfig struct {
|
|||||||
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
AMIKmsKeyId *string `mapstructure:"kms_key_id" required:"false" cty:"kms_key_id"`
|
||||||
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false" cty:"region_kms_key_ids"`
|
||||||
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
AMISkipBuildRegion *bool `mapstructure:"skip_save_build_region" cty:"skip_save_build_region"`
|
||||||
SnapshotTags common.TagMap `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
SnapshotTags map[string]string `mapstructure:"snapshot_tags" required:"false" cty:"snapshot_tags"`
|
||||||
|
SnapshotTag []hcl2template.FlatNameValue `mapstructure:"snapshot_tag" required:"false" cty:"snapshot_tag"`
|
||||||
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
SnapshotUsers []string `mapstructure:"snapshot_users" required:"false" cty:"snapshot_users"`
|
||||||
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
SnapshotGroups []string `mapstructure:"snapshot_groups" required:"false" cty:"snapshot_groups"`
|
||||||
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" required:"false" cty:"associate_public_ip_address"`
|
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" required:"false" cty:"associate_public_ip_address"`
|
||||||
@ -62,6 +65,7 @@ type FlatConfig struct {
|
|||||||
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
||||||
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
SecurityGroupFilter *common.FlatSecurityGroupFilterOptions `mapstructure:"security_group_filter" required:"false" cty:"security_group_filter"`
|
||||||
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
||||||
|
RunTag []hcl2template.FlatNameValue `mapstructure:"run_tag" required:"false" cty:"run_tag"`
|
||||||
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
||||||
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
SecurityGroupIds []string `mapstructure:"security_group_ids" required:"false" cty:"security_group_ids"`
|
||||||
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
SourceAmi *string `mapstructure:"source_ami" required:"true" cty:"source_ami"`
|
||||||
@ -70,6 +74,7 @@ type FlatConfig struct {
|
|||||||
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
SpotPrice *string `mapstructure:"spot_price" required:"false" cty:"spot_price"`
|
||||||
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
SpotPriceAutoProduct *string `mapstructure:"spot_price_auto_product" required:"false" cty:"spot_price_auto_product"`
|
||||||
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
SpotTags map[string]string `mapstructure:"spot_tags" required:"false" cty:"spot_tags"`
|
||||||
|
SpotTag []hcl2template.FlatNameValue `mapstructure:"spot_tag" required:"false" cty:"spot_tag"`
|
||||||
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
SubnetFilter *common.FlatSubnetFilterOptions `mapstructure:"subnet_filter" required:"false" cty:"subnet_filter"`
|
||||||
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
||||||
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
TemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" required:"false" cty:"temporary_key_pair_name"`
|
||||||
@ -173,6 +178,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"ami_product_codes": &hcldec.AttrSpec{Name: "ami_product_codes", Type: cty.List(cty.String), Required: false},
|
"ami_product_codes": &hcldec.AttrSpec{Name: "ami_product_codes", Type: cty.List(cty.String), Required: false},
|
||||||
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
"ami_regions": &hcldec.AttrSpec{Name: "ami_regions", Type: cty.List(cty.String), Required: false},
|
||||||
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
||||||
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
"ena_support": &hcldec.AttrSpec{Name: "ena_support", Type: cty.Bool, Required: false},
|
||||||
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
"sriov_support": &hcldec.AttrSpec{Name: "sriov_support", Type: cty.Bool, Required: false},
|
||||||
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
"force_deregister": &hcldec.AttrSpec{Name: "force_deregister", Type: cty.Bool, Required: false},
|
||||||
@ -182,6 +188,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
"region_kms_key_ids": &hcldec.BlockAttrsSpec{TypeName: "region_kms_key_ids", ElementType: cty.String, Required: false},
|
||||||
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
"skip_save_build_region": &hcldec.AttrSpec{Name: "skip_save_build_region", Type: cty.Bool, Required: false},
|
||||||
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
"snapshot_tags": &hcldec.BlockAttrsSpec{TypeName: "snapshot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"snapshot_tag": &hcldec.BlockListSpec{TypeName: "snapshot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
"snapshot_users": &hcldec.AttrSpec{Name: "snapshot_users", Type: cty.List(cty.String), Required: false},
|
||||||
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
"snapshot_groups": &hcldec.AttrSpec{Name: "snapshot_groups", Type: cty.List(cty.String), Required: false},
|
||||||
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
||||||
@ -197,6 +204,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
"instance_type": &hcldec.AttrSpec{Name: "instance_type", Type: cty.String, Required: false},
|
||||||
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
"security_group_filter": &hcldec.BlockSpec{TypeName: "security_group_filter", Nested: hcldec.ObjectSpec((*common.FlatSecurityGroupFilterOptions)(nil).HCL2Spec())},
|
||||||
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
||||||
|
"run_tag": &hcldec.BlockListSpec{TypeName: "run_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
"security_group_id": &hcldec.AttrSpec{Name: "security_group_id", Type: cty.String, Required: false},
|
||||||
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
"security_group_ids": &hcldec.AttrSpec{Name: "security_group_ids", Type: cty.List(cty.String), Required: false},
|
||||||
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
"source_ami": &hcldec.AttrSpec{Name: "source_ami", Type: cty.String, Required: false},
|
||||||
@ -205,6 +213,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
"spot_price": &hcldec.AttrSpec{Name: "spot_price", Type: cty.String, Required: false},
|
||||||
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
"spot_price_auto_product": &hcldec.AttrSpec{Name: "spot_price_auto_product", Type: cty.String, Required: false},
|
||||||
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
"spot_tags": &hcldec.BlockAttrsSpec{TypeName: "spot_tags", ElementType: cty.String, Required: false},
|
||||||
|
"spot_tag": &hcldec.BlockListSpec{TypeName: "spot_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
"subnet_filter": &hcldec.BlockSpec{TypeName: "subnet_filter", Nested: hcldec.ObjectSpec((*common.FlatSubnetFilterOptions)(nil).HCL2Spec())},
|
||||||
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
"subnet_id": &hcldec.AttrSpec{Name: "subnet_id", Type: cty.String, Required: false},
|
||||||
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/hashicorp/packer/builder/azure/common/constants"
|
"github.com/hashicorp/packer/builder/azure/common/constants"
|
||||||
"github.com/hashicorp/packer/builder/azure/pkcs12"
|
"github.com/hashicorp/packer/builder/azure/pkcs12"
|
||||||
"github.com/hashicorp/packer/common"
|
"github.com/hashicorp/packer/common"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
"github.com/hashicorp/packer/helper/config"
|
"github.com/hashicorp/packer/helper/config"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
@ -240,6 +241,11 @@ type Config struct {
|
|||||||
// 256 characters. Tags are applied to every resource deployed by a Packer
|
// 256 characters. Tags are applied to every resource deployed by a Packer
|
||||||
// build, i.e. Resource Group, VM, NIC, VNET, Public IP, KeyVault, etc.
|
// build, i.e. Resource Group, VM, NIC, VNET, Public IP, KeyVault, etc.
|
||||||
AzureTags map[string]*string `mapstructure:"azure_tags" required:"false"`
|
AzureTags map[string]*string `mapstructure:"azure_tags" required:"false"`
|
||||||
|
// Same as [`azure_tags`](#azure_tags) but defined as a singular repeatable block
|
||||||
|
// containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
AzureTag hcl2template.NameValues `mapstructure:"azure_tag" required:"false"`
|
||||||
// Resource group under which the final artifact will be stored.
|
// Resource group under which the final artifact will be stored.
|
||||||
ResourceGroupName string `mapstructure:"resource_group_name"`
|
ResourceGroupName string `mapstructure:"resource_group_name"`
|
||||||
// Storage account under which the final artifact will be stored.
|
// Storage account under which the final artifact will be stored.
|
||||||
@ -523,6 +529,13 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
|||||||
provideDefaultValues(c)
|
provideDefaultValues(c)
|
||||||
setRuntimeValues(c)
|
setRuntimeValues(c)
|
||||||
setUserNamePassword(c)
|
setUserNamePassword(c)
|
||||||
|
|
||||||
|
// copy singular blocks
|
||||||
|
for _, kv := range c.AzureTag {
|
||||||
|
v := kv.Value
|
||||||
|
c.AzureTags[kv.Name] = &v
|
||||||
|
}
|
||||||
|
|
||||||
err = c.ClientConfig.SetDefaultValues()
|
err = c.ClientConfig.SetDefaultValues()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -3,6 +3,7 @@ package arm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ type FlatConfig struct {
|
|||||||
ManagedImageDataDiskSnapshotPrefix *string `mapstructure:"managed_image_data_disk_snapshot_prefix" required:"false" cty:"managed_image_data_disk_snapshot_prefix"`
|
ManagedImageDataDiskSnapshotPrefix *string `mapstructure:"managed_image_data_disk_snapshot_prefix" required:"false" cty:"managed_image_data_disk_snapshot_prefix"`
|
||||||
ManagedImageZoneResilient *bool `mapstructure:"managed_image_zone_resilient" required:"false" cty:"managed_image_zone_resilient"`
|
ManagedImageZoneResilient *bool `mapstructure:"managed_image_zone_resilient" required:"false" cty:"managed_image_zone_resilient"`
|
||||||
AzureTags map[string]*string `mapstructure:"azure_tags" required:"false" cty:"azure_tags"`
|
AzureTags map[string]*string `mapstructure:"azure_tags" required:"false" cty:"azure_tags"`
|
||||||
|
AzureTag []hcl2template.FlatNameValue `mapstructure:"azure_tag" required:"false" cty:"azure_tag"`
|
||||||
ResourceGroupName *string `mapstructure:"resource_group_name" cty:"resource_group_name"`
|
ResourceGroupName *string `mapstructure:"resource_group_name" cty:"resource_group_name"`
|
||||||
StorageAccount *string `mapstructure:"storage_account" cty:"storage_account"`
|
StorageAccount *string `mapstructure:"storage_account" cty:"storage_account"`
|
||||||
TempComputeName *string `mapstructure:"temp_compute_name" required:"false" cty:"temp_compute_name"`
|
TempComputeName *string `mapstructure:"temp_compute_name" required:"false" cty:"temp_compute_name"`
|
||||||
@ -162,6 +164,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"managed_image_data_disk_snapshot_prefix": &hcldec.AttrSpec{Name: "managed_image_data_disk_snapshot_prefix", Type: cty.String, Required: false},
|
"managed_image_data_disk_snapshot_prefix": &hcldec.AttrSpec{Name: "managed_image_data_disk_snapshot_prefix", Type: cty.String, Required: false},
|
||||||
"managed_image_zone_resilient": &hcldec.AttrSpec{Name: "managed_image_zone_resilient", Type: cty.Bool, Required: false},
|
"managed_image_zone_resilient": &hcldec.AttrSpec{Name: "managed_image_zone_resilient", Type: cty.Bool, Required: false},
|
||||||
"azure_tags": &hcldec.BlockAttrsSpec{TypeName: "azure_tags", ElementType: cty.String, Required: false},
|
"azure_tags": &hcldec.BlockAttrsSpec{TypeName: "azure_tags", ElementType: cty.String, Required: false},
|
||||||
|
"azure_tag": &hcldec.BlockListSpec{TypeName: "azure_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"resource_group_name": &hcldec.AttrSpec{Name: "resource_group_name", Type: cty.String, Required: false},
|
"resource_group_name": &hcldec.AttrSpec{Name: "resource_group_name", Type: cty.String, Required: false},
|
||||||
"storage_account": &hcldec.AttrSpec{Name: "storage_account", Type: cty.String, Required: false},
|
"storage_account": &hcldec.AttrSpec{Name: "storage_account", Type: cty.String, Required: false},
|
||||||
"temp_compute_name": &hcldec.AttrSpec{Name: "temp_compute_name", Type: cty.String, Required: false},
|
"temp_compute_name": &hcldec.AttrSpec{Name: "temp_compute_name", Type: cty.String, Required: false},
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/hashicorp/packer/common"
|
"github.com/hashicorp/packer/common"
|
||||||
"github.com/hashicorp/packer/common/json"
|
"github.com/hashicorp/packer/common/json"
|
||||||
"github.com/hashicorp/packer/common/uuid"
|
"github.com/hashicorp/packer/common/uuid"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
"github.com/hashicorp/packer/helper/config"
|
"github.com/hashicorp/packer/helper/config"
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
"github.com/hashicorp/packer/helper/multistep"
|
||||||
@ -60,9 +61,13 @@ type Config struct {
|
|||||||
ImageName string `mapstructure:"image_name" required:"false"`
|
ImageName string `mapstructure:"image_name" required:"false"`
|
||||||
// The description of the resulting image.
|
// The description of the resulting image.
|
||||||
ImageDescription string `mapstructure:"image_description" required:"false"`
|
ImageDescription string `mapstructure:"image_description" required:"false"`
|
||||||
// Key/value pair tags to
|
// Key/value pair tags to add to the created image.
|
||||||
// add to the created image.
|
|
||||||
ImageTags map[string]string `mapstructure:"image_tags" required:"false"`
|
ImageTags map[string]string `mapstructure:"image_tags" required:"false"`
|
||||||
|
// Same as [`image_tags`](#image_tags) but defined as a singular repeatable
|
||||||
|
// block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
ImageTag hcl2template.NameValues `mapstructure:"image_tag" required:"false"`
|
||||||
// The service of the resulting image.
|
// The service of the resulting image.
|
||||||
ImageService string `mapstructure:"image_service" required:"false"`
|
ImageService string `mapstructure:"image_service" required:"false"`
|
||||||
// ID or name of the type this server should be created with.
|
// ID or name of the type this server should be created with.
|
||||||
@ -72,6 +77,11 @@ type Config struct {
|
|||||||
// Key/value pair tags to
|
// Key/value pair tags to
|
||||||
// add to the created server.
|
// add to the created server.
|
||||||
VmTags map[string]string `mapstructure:"vm_tags" required:"false"`
|
VmTags map[string]string `mapstructure:"vm_tags" required:"false"`
|
||||||
|
// Same as [`vm_tags`](#vm_tags) but defined as a singular repeatable block
|
||||||
|
// containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
VmTag hcl2template.NameValues `mapstructure:"vm_tag" required:"false"`
|
||||||
// The name of the created disk.
|
// The name of the created disk.
|
||||||
DiskName string `mapstructure:"disk_name" required:"false"`
|
DiskName string `mapstructure:"disk_name" required:"false"`
|
||||||
// The type of the created disk. Defaults to ssd.
|
// The type of the created disk. Defaults to ssd.
|
||||||
@ -257,6 +267,9 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
|||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
var errs *packer.MultiError
|
var errs *packer.MultiError
|
||||||
|
errs = packer.MultiErrorAppend(errs, c.ImageTag.CopyOn(&c.ImageTags)...)
|
||||||
|
errs = packer.MultiErrorAppend(errs, c.VmTag.CopyOn(&c.VmTags)...)
|
||||||
|
|
||||||
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
|
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
|
||||||
errs = packer.MultiErrorAppend(errs, es...)
|
errs = packer.MultiErrorAppend(errs, es...)
|
||||||
}
|
}
|
||||||
|
@ -3,93 +3,96 @@ package hyperone
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlatConfig is an auto-generated flat version of Config.
|
// FlatConfig is an auto-generated flat version of Config.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatConfig struct {
|
type FlatConfig struct {
|
||||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
||||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
||||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
||||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
||||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
||||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
||||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
||||||
Type *string `mapstructure:"communicator" cty:"communicator"`
|
Type *string `mapstructure:"communicator" cty:"communicator"`
|
||||||
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
||||||
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
||||||
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
||||||
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
||||||
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
||||||
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
||||||
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
||||||
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
||||||
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
||||||
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
||||||
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
||||||
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
||||||
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
||||||
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
||||||
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
||||||
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
||||||
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
||||||
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
||||||
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
||||||
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
||||||
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
||||||
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
||||||
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
||||||
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
||||||
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
||||||
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
||||||
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
||||||
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
||||||
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
||||||
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
||||||
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
||||||
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
||||||
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
||||||
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
||||||
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
||||||
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
||||||
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
||||||
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
||||||
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
||||||
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
||||||
APIURL *string `mapstructure:"api_url" required:"false" cty:"api_url"`
|
APIURL *string `mapstructure:"api_url" required:"false" cty:"api_url"`
|
||||||
Token *string `mapstructure:"token" required:"true" cty:"token"`
|
Token *string `mapstructure:"token" required:"true" cty:"token"`
|
||||||
Project *string `mapstructure:"project" required:"true" cty:"project"`
|
Project *string `mapstructure:"project" required:"true" cty:"project"`
|
||||||
TokenLogin *string `mapstructure:"token_login" required:"false" cty:"token_login"`
|
TokenLogin *string `mapstructure:"token_login" required:"false" cty:"token_login"`
|
||||||
StateTimeout *string `mapstructure:"state_timeout" required:"false" cty:"state_timeout"`
|
StateTimeout *string `mapstructure:"state_timeout" required:"false" cty:"state_timeout"`
|
||||||
SourceImage *string `mapstructure:"source_image" required:"true" cty:"source_image"`
|
SourceImage *string `mapstructure:"source_image" required:"true" cty:"source_image"`
|
||||||
ImageName *string `mapstructure:"image_name" required:"false" cty:"image_name"`
|
ImageName *string `mapstructure:"image_name" required:"false" cty:"image_name"`
|
||||||
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
||||||
ImageTags map[string]string `mapstructure:"image_tags" required:"false" cty:"image_tags"`
|
ImageTags map[string]string `mapstructure:"image_tags" required:"false" cty:"image_tags"`
|
||||||
ImageService *string `mapstructure:"image_service" required:"false" cty:"image_service"`
|
ImageTag []hcl2template.FlatNameValue `mapstructure:"image_tag" required:"false" cty:"image_tag"`
|
||||||
VmType *string `mapstructure:"vm_type" required:"true" cty:"vm_type"`
|
ImageService *string `mapstructure:"image_service" required:"false" cty:"image_service"`
|
||||||
VmName *string `mapstructure:"vm_name" required:"false" cty:"vm_name"`
|
VmType *string `mapstructure:"vm_type" required:"true" cty:"vm_type"`
|
||||||
VmTags map[string]string `mapstructure:"vm_tags" required:"false" cty:"vm_tags"`
|
VmName *string `mapstructure:"vm_name" required:"false" cty:"vm_name"`
|
||||||
DiskName *string `mapstructure:"disk_name" required:"false" cty:"disk_name"`
|
VmTags map[string]string `mapstructure:"vm_tags" required:"false" cty:"vm_tags"`
|
||||||
DiskType *string `mapstructure:"disk_type" required:"false" cty:"disk_type"`
|
VmTag []hcl2template.FlatNameValue `mapstructure:"vm_tag" required:"false" cty:"vm_tag"`
|
||||||
DiskSize *float32 `mapstructure:"disk_size" required:"true" cty:"disk_size"`
|
DiskName *string `mapstructure:"disk_name" required:"false" cty:"disk_name"`
|
||||||
Network *string `mapstructure:"network" required:"false" cty:"network"`
|
DiskType *string `mapstructure:"disk_type" required:"false" cty:"disk_type"`
|
||||||
PrivateIP *string `mapstructure:"private_ip" required:"false" cty:"private_ip"`
|
DiskSize *float32 `mapstructure:"disk_size" required:"true" cty:"disk_size"`
|
||||||
PublicIP *string `mapstructure:"public_ip" required:"false" cty:"public_ip"`
|
Network *string `mapstructure:"network" required:"false" cty:"network"`
|
||||||
PublicNetAdpService *string `mapstructure:"public_netadp_service" required:"false" cty:"public_netadp_service"`
|
PrivateIP *string `mapstructure:"private_ip" required:"false" cty:"private_ip"`
|
||||||
ChrootDisk *bool `mapstructure:"chroot_disk" cty:"chroot_disk"`
|
PublicIP *string `mapstructure:"public_ip" required:"false" cty:"public_ip"`
|
||||||
ChrootDiskSize *float32 `mapstructure:"chroot_disk_size" cty:"chroot_disk_size"`
|
PublicNetAdpService *string `mapstructure:"public_netadp_service" required:"false" cty:"public_netadp_service"`
|
||||||
ChrootDiskType *string `mapstructure:"chroot_disk_type" cty:"chroot_disk_type"`
|
ChrootDisk *bool `mapstructure:"chroot_disk" cty:"chroot_disk"`
|
||||||
ChrootMountPath *string `mapstructure:"chroot_mount_path" cty:"chroot_mount_path"`
|
ChrootDiskSize *float32 `mapstructure:"chroot_disk_size" cty:"chroot_disk_size"`
|
||||||
ChrootMounts [][]string `mapstructure:"chroot_mounts" cty:"chroot_mounts"`
|
ChrootDiskType *string `mapstructure:"chroot_disk_type" cty:"chroot_disk_type"`
|
||||||
ChrootCopyFiles []string `mapstructure:"chroot_copy_files" cty:"chroot_copy_files"`
|
ChrootMountPath *string `mapstructure:"chroot_mount_path" cty:"chroot_mount_path"`
|
||||||
ChrootCommandWrapper *string `mapstructure:"chroot_command_wrapper" cty:"chroot_command_wrapper"`
|
ChrootMounts [][]string `mapstructure:"chroot_mounts" cty:"chroot_mounts"`
|
||||||
MountOptions []string `mapstructure:"mount_options" cty:"mount_options"`
|
ChrootCopyFiles []string `mapstructure:"chroot_copy_files" cty:"chroot_copy_files"`
|
||||||
MountPartition *string `mapstructure:"mount_partition" cty:"mount_partition"`
|
ChrootCommandWrapper *string `mapstructure:"chroot_command_wrapper" cty:"chroot_command_wrapper"`
|
||||||
PreMountCommands []string `mapstructure:"pre_mount_commands" cty:"pre_mount_commands"`
|
MountOptions []string `mapstructure:"mount_options" cty:"mount_options"`
|
||||||
PostMountCommands []string `mapstructure:"post_mount_commands" cty:"post_mount_commands"`
|
MountPartition *string `mapstructure:"mount_partition" cty:"mount_partition"`
|
||||||
SSHKeys []string `mapstructure:"ssh_keys" required:"false" cty:"ssh_keys"`
|
PreMountCommands []string `mapstructure:"pre_mount_commands" cty:"pre_mount_commands"`
|
||||||
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"`
|
PostMountCommands []string `mapstructure:"post_mount_commands" cty:"post_mount_commands"`
|
||||||
|
SSHKeys []string `mapstructure:"ssh_keys" required:"false" cty:"ssh_keys"`
|
||||||
|
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatConfig.
|
// FlatMapstructure returns a new FlatConfig.
|
||||||
@ -161,10 +164,12 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"image_name": &hcldec.AttrSpec{Name: "image_name", Type: cty.String, Required: false},
|
"image_name": &hcldec.AttrSpec{Name: "image_name", Type: cty.String, Required: false},
|
||||||
"image_description": &hcldec.AttrSpec{Name: "image_description", Type: cty.String, Required: false},
|
"image_description": &hcldec.AttrSpec{Name: "image_description", Type: cty.String, Required: false},
|
||||||
"image_tags": &hcldec.BlockAttrsSpec{TypeName: "image_tags", ElementType: cty.String, Required: false},
|
"image_tags": &hcldec.BlockAttrsSpec{TypeName: "image_tags", ElementType: cty.String, Required: false},
|
||||||
|
"image_tag": &hcldec.BlockListSpec{TypeName: "image_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"image_service": &hcldec.AttrSpec{Name: "image_service", Type: cty.String, Required: false},
|
"image_service": &hcldec.AttrSpec{Name: "image_service", Type: cty.String, Required: false},
|
||||||
"vm_type": &hcldec.AttrSpec{Name: "vm_type", Type: cty.String, Required: false},
|
"vm_type": &hcldec.AttrSpec{Name: "vm_type", Type: cty.String, Required: false},
|
||||||
"vm_name": &hcldec.AttrSpec{Name: "vm_name", Type: cty.String, Required: false},
|
"vm_name": &hcldec.AttrSpec{Name: "vm_name", Type: cty.String, Required: false},
|
||||||
"vm_tags": &hcldec.BlockAttrsSpec{TypeName: "vm_tags", ElementType: cty.String, Required: false},
|
"vm_tags": &hcldec.BlockAttrsSpec{TypeName: "vm_tags", ElementType: cty.String, Required: false},
|
||||||
|
"vm_tag": &hcldec.BlockListSpec{TypeName: "vm_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"disk_name": &hcldec.AttrSpec{Name: "disk_name", Type: cty.String, Required: false},
|
"disk_name": &hcldec.AttrSpec{Name: "disk_name", Type: cty.String, Required: false},
|
||||||
"disk_type": &hcldec.AttrSpec{Name: "disk_type", Type: cty.String, Required: false},
|
"disk_type": &hcldec.AttrSpec{Name: "disk_type", Type: cty.String, Required: false},
|
||||||
"disk_size": &hcldec.AttrSpec{Name: "disk_size", Type: cty.Number, Required: false},
|
"disk_size": &hcldec.AttrSpec{Name: "disk_size", Type: cty.Number, Required: false},
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/common/uuid"
|
"github.com/hashicorp/packer/common/uuid"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
@ -18,13 +19,13 @@ import (
|
|||||||
var reShutdownBehavior = regexp.MustCompile("^(stop|terminate)$")
|
var reShutdownBehavior = regexp.MustCompile("^(stop|terminate)$")
|
||||||
|
|
||||||
type OmiFilterOptions struct {
|
type OmiFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
Owners []string
|
Owners []string
|
||||||
MostRecent bool `mapstructure:"most_recent"`
|
MostRecent bool `mapstructure:"most_recent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *OmiFilterOptions) Empty() bool {
|
func (d *OmiFilterOptions) Empty() bool {
|
||||||
return len(d.Owners) == 0 && len(d.Filters) == 0
|
return len(d.Owners) == 0 && d.KVFilter.Empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *OmiFilterOptions) NoOwner() bool {
|
func (d *OmiFilterOptions) NoOwner() bool {
|
||||||
@ -32,29 +33,17 @@ func (d *OmiFilterOptions) NoOwner() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SubnetFilterOptions struct {
|
type SubnetFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
MostFree bool `mapstructure:"most_free"`
|
MostFree bool `mapstructure:"most_free"`
|
||||||
Random bool `mapstructure:"random"`
|
Random bool `mapstructure:"random"`
|
||||||
}
|
|
||||||
|
|
||||||
func (d *SubnetFilterOptions) Empty() bool {
|
|
||||||
return len(d.Filters) == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetFilterOptions struct {
|
type NetFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
}
|
|
||||||
|
|
||||||
func (d *NetFilterOptions) Empty() bool {
|
|
||||||
return len(d.Filters) == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SecurityGroupFilterOptions struct {
|
type SecurityGroupFilterOptions struct {
|
||||||
Filters map[string]string
|
hcl2template.KVFilter `mapstructure:",squash"`
|
||||||
}
|
|
||||||
|
|
||||||
func (d *SecurityGroupFilterOptions) Empty() bool {
|
|
||||||
return len(d.Filters) == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunConfig contains configuration for running an vm from a source
|
// RunConfig contains configuration for running an vm from a source
|
||||||
@ -115,6 +104,15 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||||||
// Validation
|
// Validation
|
||||||
errs := c.Comm.Prepare(ctx)
|
errs := c.Comm.Prepare(ctx)
|
||||||
|
|
||||||
|
for _, preparer := range []interface{ Prepare() []error }{
|
||||||
|
&c.SourceOmiFilter,
|
||||||
|
&c.SecurityGroupFilter,
|
||||||
|
&c.SubnetFilter,
|
||||||
|
&c.NetFilter,
|
||||||
|
} {
|
||||||
|
errs = append(errs, preparer.Prepare()...)
|
||||||
|
}
|
||||||
|
|
||||||
// Validating ssh_interface
|
// Validating ssh_interface
|
||||||
if c.SSHInterface != "public_ip" &&
|
if c.SSHInterface != "public_ip" &&
|
||||||
c.SSHInterface != "private_ip" &&
|
c.SSHInterface != "private_ip" &&
|
||||||
|
@ -3,6 +3,7 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,7 +47,8 @@ func (*FlatBlockDevice) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatNetFilterOptions is an auto-generated flat version of NetFilterOptions.
|
// FlatNetFilterOptions is an auto-generated flat version of NetFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatNetFilterOptions struct {
|
type FlatNetFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatNetFilterOptions.
|
// FlatMapstructure returns a new FlatNetFilterOptions.
|
||||||
@ -62,6 +64,7 @@ func (*NetFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcl
|
|||||||
func (*FlatNetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatNetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@ -69,9 +72,10 @@ func (*FlatNetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatOmiFilterOptions is an auto-generated flat version of OmiFilterOptions.
|
// FlatOmiFilterOptions is an auto-generated flat version of OmiFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatOmiFilterOptions struct {
|
type FlatOmiFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
Owners []string `cty:"owners"`
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
MostRecent *bool `mapstructure:"most_recent" cty:"most_recent"`
|
Owners []string `cty:"owners"`
|
||||||
|
MostRecent *bool `mapstructure:"most_recent" cty:"most_recent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatOmiFilterOptions.
|
// FlatMapstructure returns a new FlatOmiFilterOptions.
|
||||||
@ -87,6 +91,7 @@ func (*OmiFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]hcl
|
|||||||
func (*FlatOmiFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatOmiFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"owners": &hcldec.AttrSpec{Name: "owners", Type: cty.List(cty.String), Required: false},
|
"owners": &hcldec.AttrSpec{Name: "owners", Type: cty.List(cty.String), Required: false},
|
||||||
"most_recent": &hcldec.AttrSpec{Name: "most_recent", Type: cty.Bool, Required: false},
|
"most_recent": &hcldec.AttrSpec{Name: "most_recent", Type: cty.Bool, Required: false},
|
||||||
}
|
}
|
||||||
@ -96,7 +101,8 @@ func (*FlatOmiFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatSecurityGroupFilterOptions is an auto-generated flat version of SecurityGroupFilterOptions.
|
// FlatSecurityGroupFilterOptions is an auto-generated flat version of SecurityGroupFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatSecurityGroupFilterOptions struct {
|
type FlatSecurityGroupFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatSecurityGroupFilterOptions.
|
// FlatMapstructure returns a new FlatSecurityGroupFilterOptions.
|
||||||
@ -112,6 +118,7 @@ func (*SecurityGroupFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[
|
|||||||
func (*FlatSecurityGroupFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatSecurityGroupFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@ -119,9 +126,10 @@ func (*FlatSecurityGroupFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
// FlatSubnetFilterOptions is an auto-generated flat version of SubnetFilterOptions.
|
// FlatSubnetFilterOptions is an auto-generated flat version of SubnetFilterOptions.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatSubnetFilterOptions struct {
|
type FlatSubnetFilterOptions struct {
|
||||||
Filters map[string]string `cty:"filters"`
|
Filters map[string]string `cty:"filters"`
|
||||||
MostFree *bool `mapstructure:"most_free" cty:"most_free"`
|
Filter []hcl2template.FlatNameValue `cty:"filter"`
|
||||||
Random *bool `mapstructure:"random" cty:"random"`
|
MostFree *bool `mapstructure:"most_free" cty:"most_free"`
|
||||||
|
Random *bool `mapstructure:"random" cty:"random"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatSubnetFilterOptions.
|
// FlatMapstructure returns a new FlatSubnetFilterOptions.
|
||||||
@ -137,6 +145,7 @@ func (*SubnetFilterOptions) FlatMapstructure() interface{ HCL2Spec() map[string]
|
|||||||
func (*FlatSubnetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
func (*FlatSubnetFilterOptions) HCL2Spec() map[string]hcldec.Spec {
|
||||||
s := map[string]hcldec.Spec{
|
s := map[string]hcldec.Spec{
|
||||||
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"most_free": &hcldec.AttrSpec{Name: "most_free", Type: cty.Bool, Required: false},
|
"most_free": &hcldec.AttrSpec{Name: "most_free", Type: cty.Bool, Required: false},
|
||||||
"random": &hcldec.AttrSpec{Name: "random", Type: cty.Bool, Required: false},
|
"random": &hcldec.AttrSpec{Name: "random", Type: cty.Bool, Required: false},
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -72,7 +73,11 @@ func TestRunConfigPrepare_SourceOmiFilterOwnersBlank(t *testing.T) {
|
|||||||
c := testConfigFilter()
|
c := testConfigFilter()
|
||||||
filter_key := "name"
|
filter_key := "name"
|
||||||
filter_value := "foo"
|
filter_value := "foo"
|
||||||
c.SourceOmiFilter = OmiFilterOptions{Filters: map[string]string{filter_key: filter_value}}
|
c.SourceOmiFilter = OmiFilterOptions{
|
||||||
|
KVFilter: hcl2template.KVFilter{
|
||||||
|
Filters: map[string]string{filter_key: filter_value},
|
||||||
|
},
|
||||||
|
}
|
||||||
if err := c.Prepare(nil); len(err) != 1 {
|
if err := c.Prepare(nil); len(err) != 1 {
|
||||||
t.Fatalf("Should error if Owners is not specified)")
|
t.Fatalf("Should error if Owners is not specified)")
|
||||||
}
|
}
|
||||||
@ -83,7 +88,12 @@ func TestRunConfigPrepare_SourceOmiFilterGood(t *testing.T) {
|
|||||||
owner := "123"
|
owner := "123"
|
||||||
filter_key := "name"
|
filter_key := "name"
|
||||||
filter_value := "foo"
|
filter_value := "foo"
|
||||||
goodFilter := OmiFilterOptions{Owners: []string{owner}, Filters: map[string]string{filter_key: filter_value}}
|
goodFilter := OmiFilterOptions{
|
||||||
|
Owners: []string{owner},
|
||||||
|
KVFilter: hcl2template.KVFilter{
|
||||||
|
Filters: map[string]string{filter_key: filter_value},
|
||||||
|
},
|
||||||
|
}
|
||||||
c.SourceOmiFilter = goodFilter
|
c.SourceOmiFilter = goodFilter
|
||||||
if err := c.Prepare(nil); len(err) != 0 {
|
if err := c.Prepare(nil); len(err) != 0 {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
|
@ -3,96 +3,98 @@ package cvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlatConfig is an auto-generated flat version of Config.
|
// FlatConfig is an auto-generated flat version of Config.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatConfig struct {
|
type FlatConfig struct {
|
||||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
||||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
||||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
||||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
||||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
||||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
||||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
||||||
SecretId *string `mapstructure:"secret_id" required:"true" cty:"secret_id"`
|
SecretId *string `mapstructure:"secret_id" required:"true" cty:"secret_id"`
|
||||||
SecretKey *string `mapstructure:"secret_key" required:"true" cty:"secret_key"`
|
SecretKey *string `mapstructure:"secret_key" required:"true" cty:"secret_key"`
|
||||||
Region *string `mapstructure:"region" required:"true" cty:"region"`
|
Region *string `mapstructure:"region" required:"true" cty:"region"`
|
||||||
Zone *string `mapstructure:"zone" required:"true" cty:"zone"`
|
Zone *string `mapstructure:"zone" required:"true" cty:"zone"`
|
||||||
SkipValidation *bool `mapstructure:"skip_region_validation" required:"false" cty:"skip_region_validation"`
|
SkipValidation *bool `mapstructure:"skip_region_validation" required:"false" cty:"skip_region_validation"`
|
||||||
ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"`
|
ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"`
|
||||||
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
||||||
Reboot *bool `mapstructure:"reboot" required:"false" cty:"reboot"`
|
Reboot *bool `mapstructure:"reboot" required:"false" cty:"reboot"`
|
||||||
ForcePoweroff *bool `mapstructure:"force_poweroff" required:"false" cty:"force_poweroff"`
|
ForcePoweroff *bool `mapstructure:"force_poweroff" required:"false" cty:"force_poweroff"`
|
||||||
Sysprep *bool `mapstructure:"sysprep" required:"false" cty:"sysprep"`
|
Sysprep *bool `mapstructure:"sysprep" required:"false" cty:"sysprep"`
|
||||||
ImageForceDelete *bool `mapstructure:"image_force_delete" cty:"image_force_delete"`
|
ImageForceDelete *bool `mapstructure:"image_force_delete" cty:"image_force_delete"`
|
||||||
ImageCopyRegions []string `mapstructure:"image_copy_regions" required:"false" cty:"image_copy_regions"`
|
ImageCopyRegions []string `mapstructure:"image_copy_regions" required:"false" cty:"image_copy_regions"`
|
||||||
ImageShareAccounts []string `mapstructure:"image_share_accounts" required:"false" cty:"image_share_accounts"`
|
ImageShareAccounts []string `mapstructure:"image_share_accounts" required:"false" cty:"image_share_accounts"`
|
||||||
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" required:"false" cty:"associate_public_ip_address"`
|
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" required:"false" cty:"associate_public_ip_address"`
|
||||||
SourceImageId *string `mapstructure:"source_image_id" required:"true" cty:"source_image_id"`
|
SourceImageId *string `mapstructure:"source_image_id" required:"true" cty:"source_image_id"`
|
||||||
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
InstanceType *string `mapstructure:"instance_type" required:"true" cty:"instance_type"`
|
||||||
InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name"`
|
InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name"`
|
||||||
DiskType *string `mapstructure:"disk_type" required:"false" cty:"disk_type"`
|
DiskType *string `mapstructure:"disk_type" required:"false" cty:"disk_type"`
|
||||||
DiskSize *int64 `mapstructure:"disk_size" required:"false" cty:"disk_size"`
|
DiskSize *int64 `mapstructure:"disk_size" required:"false" cty:"disk_size"`
|
||||||
DataDisks []FlattencentCloudDataDisk `mapstructure:"data_disks" cty:"data_disks"`
|
DataDisks []FlattencentCloudDataDisk `mapstructure:"data_disks" cty:"data_disks"`
|
||||||
VpcId *string `mapstructure:"vpc_id" required:"false" cty:"vpc_id"`
|
VpcId *string `mapstructure:"vpc_id" required:"false" cty:"vpc_id"`
|
||||||
VpcName *string `mapstructure:"vpc_name" required:"false" cty:"vpc_name"`
|
VpcName *string `mapstructure:"vpc_name" required:"false" cty:"vpc_name"`
|
||||||
VpcIp *string `mapstructure:"vpc_ip" cty:"vpc_ip"`
|
VpcIp *string `mapstructure:"vpc_ip" cty:"vpc_ip"`
|
||||||
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
SubnetId *string `mapstructure:"subnet_id" required:"false" cty:"subnet_id"`
|
||||||
SubnetName *string `mapstructure:"subnet_name" required:"false" cty:"subnet_name"`
|
SubnetName *string `mapstructure:"subnet_name" required:"false" cty:"subnet_name"`
|
||||||
CidrBlock *string `mapstructure:"cidr_block" required:"false" cty:"cidr_block"`
|
CidrBlock *string `mapstructure:"cidr_block" required:"false" cty:"cidr_block"`
|
||||||
SubnectCidrBlock *string `mapstructure:"subnect_cidr_block" required:"false" cty:"subnect_cidr_block"`
|
SubnectCidrBlock *string `mapstructure:"subnect_cidr_block" required:"false" cty:"subnect_cidr_block"`
|
||||||
InternetChargeType *string `mapstructure:"internet_charge_type" cty:"internet_charge_type"`
|
InternetChargeType *string `mapstructure:"internet_charge_type" cty:"internet_charge_type"`
|
||||||
InternetMaxBandwidthOut *int64 `mapstructure:"internet_max_bandwidth_out" required:"false" cty:"internet_max_bandwidth_out"`
|
InternetMaxBandwidthOut *int64 `mapstructure:"internet_max_bandwidth_out" required:"false" cty:"internet_max_bandwidth_out"`
|
||||||
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
SecurityGroupId *string `mapstructure:"security_group_id" required:"false" cty:"security_group_id"`
|
||||||
SecurityGroupName *string `mapstructure:"security_group_name" required:"false" cty:"security_group_name"`
|
SecurityGroupName *string `mapstructure:"security_group_name" required:"false" cty:"security_group_name"`
|
||||||
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"`
|
UserData *string `mapstructure:"user_data" required:"false" cty:"user_data"`
|
||||||
UserDataFile *string `mapstructure:"user_data_file" required:"false" cty:"user_data_file"`
|
UserDataFile *string `mapstructure:"user_data_file" required:"false" cty:"user_data_file"`
|
||||||
HostName *string `mapstructure:"host_name" required:"false" cty:"host_name"`
|
HostName *string `mapstructure:"host_name" required:"false" cty:"host_name"`
|
||||||
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
RunTags map[string]string `mapstructure:"run_tags" required:"false" cty:"run_tags"`
|
||||||
Type *string `mapstructure:"communicator" cty:"communicator"`
|
RunTag []hcl2template.FlatNameValue `mapstructure:"run_tag" required:"false" cty:"run_tag"`
|
||||||
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
Type *string `mapstructure:"communicator" cty:"communicator"`
|
||||||
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
||||||
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
||||||
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
||||||
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
||||||
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
||||||
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
||||||
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
||||||
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
||||||
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
||||||
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
||||||
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
||||||
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
||||||
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
||||||
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
||||||
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
||||||
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
||||||
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
||||||
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
||||||
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
||||||
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
||||||
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
||||||
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
||||||
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
||||||
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
||||||
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
||||||
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
||||||
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
||||||
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
||||||
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
||||||
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
||||||
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
||||||
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
||||||
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
||||||
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
||||||
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
||||||
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
||||||
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
||||||
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
||||||
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
||||||
SSHPrivateIp *bool `mapstructure:"ssh_private_ip" cty:"ssh_private_ip"`
|
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
||||||
|
SSHPrivateIp *bool `mapstructure:"ssh_private_ip" cty:"ssh_private_ip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatConfig.
|
// FlatMapstructure returns a new FlatConfig.
|
||||||
@ -149,6 +151,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"user_data_file": &hcldec.AttrSpec{Name: "user_data_file", Type: cty.String, Required: false},
|
"user_data_file": &hcldec.AttrSpec{Name: "user_data_file", Type: cty.String, Required: false},
|
||||||
"host_name": &hcldec.AttrSpec{Name: "host_name", Type: cty.String, Required: false},
|
"host_name": &hcldec.AttrSpec{Name: "host_name", Type: cty.String, Required: false},
|
||||||
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
"run_tags": &hcldec.BlockAttrsSpec{TypeName: "run_tags", ElementType: cty.String, Required: false},
|
||||||
|
"run_tag": &hcldec.BlockListSpec{TypeName: "run_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
|
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
|
||||||
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
|
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
|
||||||
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},
|
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/common/uuid"
|
"github.com/hashicorp/packer/common/uuid"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/helper/communicator"
|
"github.com/hashicorp/packer/helper/communicator"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -83,6 +84,11 @@ type TencentCloudRunConfig struct {
|
|||||||
// Tags to apply to the instance that is *launched* to create the image.
|
// Tags to apply to the instance that is *launched* to create the image.
|
||||||
// These tags are *not* applied to the resulting image.
|
// These tags are *not* applied to the resulting image.
|
||||||
RunTags map[string]string `mapstructure:"run_tags" required:"false"`
|
RunTags map[string]string `mapstructure:"run_tags" required:"false"`
|
||||||
|
// Same as [`run_tags`](#run_tags) but defined as a singular repeatable
|
||||||
|
// block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
RunTag hcl2template.NameValues `mapstructure:"run_tag" required:"false"`
|
||||||
|
|
||||||
// Communicator settings
|
// Communicator settings
|
||||||
Comm communicator.Config `mapstructure:",squash"`
|
Comm communicator.Config `mapstructure:",squash"`
|
||||||
@ -183,6 +189,8 @@ func (cf *TencentCloudRunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||||||
cf.RunTags = make(map[string]string)
|
cf.RunTags = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errs = append(errs, cf.RunTag.CopyOn(&cf.RunTags)...)
|
||||||
|
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,81 +3,84 @@ package triton
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlatConfig is an auto-generated flat version of Config.
|
// FlatConfig is an auto-generated flat version of Config.
|
||||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
type FlatConfig struct {
|
type FlatConfig struct {
|
||||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
||||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
||||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
||||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
||||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
||||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
||||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
||||||
Endpoint *string `mapstructure:"triton_url" required:"false" cty:"triton_url"`
|
Endpoint *string `mapstructure:"triton_url" required:"false" cty:"triton_url"`
|
||||||
Account *string `mapstructure:"triton_account" required:"true" cty:"triton_account"`
|
Account *string `mapstructure:"triton_account" required:"true" cty:"triton_account"`
|
||||||
Username *string `mapstructure:"triton_user" required:"false" cty:"triton_user"`
|
Username *string `mapstructure:"triton_user" required:"false" cty:"triton_user"`
|
||||||
KeyID *string `mapstructure:"triton_key_id" required:"true" cty:"triton_key_id"`
|
KeyID *string `mapstructure:"triton_key_id" required:"true" cty:"triton_key_id"`
|
||||||
KeyMaterial *string `mapstructure:"triton_key_material" required:"false" cty:"triton_key_material"`
|
KeyMaterial *string `mapstructure:"triton_key_material" required:"false" cty:"triton_key_material"`
|
||||||
InsecureSkipTLSVerify *bool `mapstructure:"insecure_skip_tls_verify" required:"false" cty:"insecure_skip_tls_verify"`
|
InsecureSkipTLSVerify *bool `mapstructure:"insecure_skip_tls_verify" required:"false" cty:"insecure_skip_tls_verify"`
|
||||||
MachineName *string `mapstructure:"source_machine_name" required:"false" cty:"source_machine_name"`
|
MachineName *string `mapstructure:"source_machine_name" required:"false" cty:"source_machine_name"`
|
||||||
MachinePackage *string `mapstructure:"source_machine_package" required:"true" cty:"source_machine_package"`
|
MachinePackage *string `mapstructure:"source_machine_package" required:"true" cty:"source_machine_package"`
|
||||||
MachineImage *string `mapstructure:"source_machine_image" required:"true" cty:"source_machine_image"`
|
MachineImage *string `mapstructure:"source_machine_image" required:"true" cty:"source_machine_image"`
|
||||||
MachineNetworks []string `mapstructure:"source_machine_networks" required:"false" cty:"source_machine_networks"`
|
MachineNetworks []string `mapstructure:"source_machine_networks" required:"false" cty:"source_machine_networks"`
|
||||||
MachineMetadata map[string]string `mapstructure:"source_machine_metadata" required:"false" cty:"source_machine_metadata"`
|
MachineMetadata map[string]string `mapstructure:"source_machine_metadata" required:"false" cty:"source_machine_metadata"`
|
||||||
MachineTags map[string]string `mapstructure:"source_machine_tags" required:"false" cty:"source_machine_tags"`
|
MachineTags map[string]string `mapstructure:"source_machine_tags" required:"false" cty:"source_machine_tags"`
|
||||||
MachineFirewallEnabled *bool `mapstructure:"source_machine_firewall_enabled" required:"false" cty:"source_machine_firewall_enabled"`
|
MachineTag []hcl2template.FlatNameValue `mapstructure:"source_machine_tag" required:"false" cty:"source_machine_tag"`
|
||||||
MachineImageFilters *FlatMachineImageFilter `mapstructure:"source_machine_image_filter" required:"false" cty:"source_machine_image_filter"`
|
MachineFirewallEnabled *bool `mapstructure:"source_machine_firewall_enabled" required:"false" cty:"source_machine_firewall_enabled"`
|
||||||
ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"`
|
MachineImageFilters *FlatMachineImageFilter `mapstructure:"source_machine_image_filter" required:"false" cty:"source_machine_image_filter"`
|
||||||
ImageVersion *string `mapstructure:"image_version" required:"true" cty:"image_version"`
|
ImageName *string `mapstructure:"image_name" required:"true" cty:"image_name"`
|
||||||
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
ImageVersion *string `mapstructure:"image_version" required:"true" cty:"image_version"`
|
||||||
ImageHomepage *string `mapstructure:"image_homepage" required:"false" cty:"image_homepage"`
|
ImageDescription *string `mapstructure:"image_description" required:"false" cty:"image_description"`
|
||||||
ImageEULA *string `mapstructure:"image_eula_url" required:"false" cty:"image_eula_url"`
|
ImageHomepage *string `mapstructure:"image_homepage" required:"false" cty:"image_homepage"`
|
||||||
ImageACL []string `mapstructure:"image_acls" required:"false" cty:"image_acls"`
|
ImageEULA *string `mapstructure:"image_eula_url" required:"false" cty:"image_eula_url"`
|
||||||
ImageTags map[string]string `mapstructure:"image_tags" required:"false" cty:"image_tags"`
|
ImageACL []string `mapstructure:"image_acls" required:"false" cty:"image_acls"`
|
||||||
Type *string `mapstructure:"communicator" cty:"communicator"`
|
ImageTags map[string]string `mapstructure:"image_tags" required:"false" cty:"image_tags"`
|
||||||
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
ImageTag []hcl2template.FlatNameValue `mapstructure:"image_tag" required:"false" cty:"image_tag"`
|
||||||
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
Type *string `mapstructure:"communicator" cty:"communicator"`
|
||||||
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
||||||
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
||||||
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
||||||
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
||||||
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
||||||
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
||||||
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
||||||
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
||||||
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
||||||
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
||||||
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
||||||
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
||||||
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
||||||
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
||||||
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
||||||
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
||||||
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
||||||
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
||||||
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
||||||
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
SSHBastionInteractive *bool `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive"`
|
||||||
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
||||||
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
||||||
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
||||||
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
||||||
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
||||||
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
||||||
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
||||||
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
||||||
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
||||||
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
||||||
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
||||||
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
||||||
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
||||||
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
||||||
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
||||||
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
||||||
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
||||||
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
||||||
|
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
||||||
|
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlatMapstructure returns a new FlatConfig.
|
// FlatMapstructure returns a new FlatConfig.
|
||||||
@ -111,6 +114,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"source_machine_networks": &hcldec.AttrSpec{Name: "source_machine_networks", Type: cty.List(cty.String), Required: false},
|
"source_machine_networks": &hcldec.AttrSpec{Name: "source_machine_networks", Type: cty.List(cty.String), Required: false},
|
||||||
"source_machine_metadata": &hcldec.BlockAttrsSpec{TypeName: "source_machine_metadata", ElementType: cty.String, Required: false},
|
"source_machine_metadata": &hcldec.BlockAttrsSpec{TypeName: "source_machine_metadata", ElementType: cty.String, Required: false},
|
||||||
"source_machine_tags": &hcldec.BlockAttrsSpec{TypeName: "source_machine_tags", ElementType: cty.String, Required: false},
|
"source_machine_tags": &hcldec.BlockAttrsSpec{TypeName: "source_machine_tags", ElementType: cty.String, Required: false},
|
||||||
|
"source_machine_tag": &hcldec.BlockListSpec{TypeName: "source_machine_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"source_machine_firewall_enabled": &hcldec.AttrSpec{Name: "source_machine_firewall_enabled", Type: cty.Bool, Required: false},
|
"source_machine_firewall_enabled": &hcldec.AttrSpec{Name: "source_machine_firewall_enabled", Type: cty.Bool, Required: false},
|
||||||
"source_machine_image_filter": &hcldec.BlockSpec{TypeName: "source_machine_image_filter", Nested: hcldec.ObjectSpec((*FlatMachineImageFilter)(nil).HCL2Spec())},
|
"source_machine_image_filter": &hcldec.BlockSpec{TypeName: "source_machine_image_filter", Nested: hcldec.ObjectSpec((*FlatMachineImageFilter)(nil).HCL2Spec())},
|
||||||
"image_name": &hcldec.AttrSpec{Name: "image_name", Type: cty.String, Required: false},
|
"image_name": &hcldec.AttrSpec{Name: "image_name", Type: cty.String, Required: false},
|
||||||
@ -120,6 +124,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"image_eula_url": &hcldec.AttrSpec{Name: "image_eula_url", Type: cty.String, Required: false},
|
"image_eula_url": &hcldec.AttrSpec{Name: "image_eula_url", Type: cty.String, Required: false},
|
||||||
"image_acls": &hcldec.AttrSpec{Name: "image_acls", Type: cty.List(cty.String), Required: false},
|
"image_acls": &hcldec.AttrSpec{Name: "image_acls", Type: cty.List(cty.String), Required: false},
|
||||||
"image_tags": &hcldec.BlockAttrsSpec{TypeName: "image_tags", ElementType: cty.String, Required: false},
|
"image_tags": &hcldec.BlockAttrsSpec{TypeName: "image_tags", ElementType: cty.String, Required: false},
|
||||||
|
"image_tag": &hcldec.BlockListSpec{TypeName: "image_tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
|
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
|
||||||
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
|
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
|
||||||
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},
|
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},
|
||||||
|
@ -6,6 +6,7 @@ package triton
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -52,9 +53,13 @@ type SourceMachineConfig struct {
|
|||||||
// set the user-script metadata key to have Triton start a user supplied
|
// set the user-script metadata key to have Triton start a user supplied
|
||||||
// script after the VM has booted.
|
// script after the VM has booted.
|
||||||
MachineMetadata map[string]string `mapstructure:"source_machine_metadata" required:"false"`
|
MachineMetadata map[string]string `mapstructure:"source_machine_metadata" required:"false"`
|
||||||
// Tags applied to the
|
// Tags applied to the VM used to create the image.
|
||||||
// VM used to create the image.
|
|
||||||
MachineTags map[string]string `mapstructure:"source_machine_tags" required:"false"`
|
MachineTags map[string]string `mapstructure:"source_machine_tags" required:"false"`
|
||||||
|
// Same as [`source_machine_tags`](#source_machine_tags) but defined as a
|
||||||
|
// singular block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
MachineTag hcl2template.NameValues `mapstructure:"source_machine_tag" required:"false"`
|
||||||
// Whether or not the firewall
|
// Whether or not the firewall
|
||||||
// of the VM used to create an image of is enabled. The Triton firewall only
|
// of the VM used to create an image of is enabled. The Triton firewall only
|
||||||
// filters inbound traffic to the VM. All outbound traffic is always allowed.
|
// filters inbound traffic to the VM. All outbound traffic is always allowed.
|
||||||
@ -107,9 +112,7 @@ func (c *SourceMachineConfig) Prepare(ctx *interpolate.Context) []error {
|
|||||||
c.MachineTags = make(map[string]string)
|
c.MachineTags = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
errs = append(errs, c.MachineTag.CopyOn(&c.MachineTags)...)
|
||||||
return errs
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return errs
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ package triton
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/hashicorp/packer/template/interpolate"
|
"github.com/hashicorp/packer/template/interpolate"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,12 +37,19 @@ type TargetImageConfig struct {
|
|||||||
ImageACL []string `mapstructure:"image_acls" required:"false"`
|
ImageACL []string `mapstructure:"image_acls" required:"false"`
|
||||||
// Tag applied to the image.
|
// Tag applied to the image.
|
||||||
ImageTags map[string]string `mapstructure:"image_tags" required:"false"`
|
ImageTags map[string]string `mapstructure:"image_tags" required:"false"`
|
||||||
|
// Same as [`image_tags`](#image_tags) but defined as a singular repeatable
|
||||||
|
// block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
// [`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
// will allow you to create those programatically.
|
||||||
|
ImageTag hcl2template.NameValues `mapstructure:"image_tag" required:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare performs basic validation on a TargetImageConfig struct.
|
// Prepare performs basic validation on a TargetImageConfig struct.
|
||||||
func (c *TargetImageConfig) Prepare(ctx *interpolate.Context) []error {
|
func (c *TargetImageConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
var errs []error
|
var errs []error
|
||||||
|
|
||||||
|
errs = append(errs, c.ImageTag.CopyOn(&c.ImageTags)...)
|
||||||
|
|
||||||
if c.ImageName == "" {
|
if c.ImageName == "" {
|
||||||
errs = append(errs, fmt.Errorf("An image_name must be specified"))
|
errs = append(errs, fmt.Errorf("An image_name must be specified"))
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,9 @@ type pParameterClientMatch struct {
|
|||||||
data string
|
data string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e pParameterClientMatch) repr() string { return fmt.Sprintf("match-client:%s=%s", e.name, e.data) }
|
func (e pParameterClientMatch) repr() string {
|
||||||
|
return fmt.Sprintf("match-client:%s=%s", e.name, e.data)
|
||||||
|
}
|
||||||
|
|
||||||
// range 127.0.0.1 127.0.0.255
|
// range 127.0.0.1 127.0.0.255
|
||||||
type pParameterRange4 struct {
|
type pParameterRange4 struct {
|
||||||
|
@ -92,7 +92,9 @@ type FlatNIC struct {
|
|||||||
// FlatMapstructure returns a new FlatNIC.
|
// FlatMapstructure returns a new FlatNIC.
|
||||||
// FlatNIC is an auto-generated flat version of NIC.
|
// FlatNIC is an auto-generated flat version of NIC.
|
||||||
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||||
func (*NIC) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { return new(FlatNIC) }
|
func (*NIC) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||||
|
return new(FlatNIC)
|
||||||
|
}
|
||||||
|
|
||||||
// HCL2Spec returns the hcl spec of a NIC.
|
// HCL2Spec returns the hcl spec of a NIC.
|
||||||
// This spec is used by HCL to read the fields of NIC.
|
// This spec is used by HCL to read the fields of NIC.
|
||||||
|
@ -41,6 +41,8 @@ import (
|
|||||||
"golang.org/x/tools/imports"
|
"golang.org/x/tools/imports"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const mapstructureToHCL2 = "mapstructure-to-hcl2"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
typeNames = flag.String("type", "", "comma-separated list of type names; must be set")
|
typeNames = flag.String("type", "", "comma-separated list of type names; must be set")
|
||||||
output = flag.String("output", "", "output file name; default srcdir/<type>_hcl2.go")
|
output = flag.String("output", "", "output file name; default srcdir/<type>_hcl2.go")
|
||||||
@ -49,15 +51,15 @@ var (
|
|||||||
|
|
||||||
// Usage is a replacement usage function for the flags package.
|
// Usage is a replacement usage function for the flags package.
|
||||||
func Usage() {
|
func Usage() {
|
||||||
fmt.Fprintf(os.Stderr, "Usage of mapstructure-to-hcl2:\n")
|
fmt.Fprintf(os.Stderr, "Usage of "+mapstructureToHCL2+":\n")
|
||||||
fmt.Fprintf(os.Stderr, "\tflatten-mapstructure [flags] -type T[,T...] pkg\n")
|
fmt.Fprintf(os.Stderr, "\t"+mapstructureToHCL2+" [flags] -type T[,T...] pkg\n")
|
||||||
fmt.Fprintf(os.Stderr, "Flags:\n")
|
fmt.Fprintf(os.Stderr, "Flags:\n")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
log.SetPrefix("mapstructure-to-hcl2: ")
|
log.SetPrefix(mapstructureToHCL2 + ": ")
|
||||||
flag.Usage = Usage
|
flag.Usage = Usage
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if len(*typeNames) == 0 {
|
if len(*typeNames) == 0 {
|
||||||
@ -76,7 +78,7 @@ func main() {
|
|||||||
if goFile := os.Getenv("GOFILE"); goFile != "" {
|
if goFile := os.Getenv("GOFILE"); goFile != "" {
|
||||||
outputPath = goFile[:len(goFile)-2] + "hcl2spec.go"
|
outputPath = goFile[:len(goFile)-2] + "hcl2spec.go"
|
||||||
}
|
}
|
||||||
log.SetPrefix(fmt.Sprintf("mapstructure-to-hcl2: %s.%v: ", os.Getenv("GOPACKAGE"), typeNames))
|
log.SetPrefix(fmt.Sprintf(mapstructureToHCL2+": %s.%v: ", os.Getenv("GOPACKAGE"), typeNames))
|
||||||
|
|
||||||
cfg := &packages.Config{
|
cfg := &packages.Config{
|
||||||
Mode: packages.LoadSyntax,
|
Mode: packages.LoadSyntax,
|
||||||
@ -138,7 +140,7 @@ func main() {
|
|||||||
|
|
||||||
out := bytes.NewBuffer(nil)
|
out := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
fmt.Fprintf(out, `// Code generated by "mapstructure-to-hcl2 %s"; DO NOT EDIT.`, strings.Join(os.Args[1:], " "))
|
fmt.Fprintf(out, `// Code generated by "%s %s"; DO NOT EDIT.`, mapstructureToHCL2, strings.Join(os.Args[1:], " "))
|
||||||
fmt.Fprintf(out, "\npackage %s\n", topPkg.Name)
|
fmt.Fprintf(out, "\npackage %s\n", topPkg.Name)
|
||||||
|
|
||||||
delete(usedImports, NamePath{topPkg.Name, topPkg.PkgPath})
|
delete(usedImports, NamePath{topPkg.Name, topPkg.PkgPath})
|
||||||
@ -160,8 +162,8 @@ func main() {
|
|||||||
fmt.Fprintf(out, "\n// %s is an auto-generated flat version of %s.", flatenedStruct.FlatStructName, flatenedStruct.OriginalStructName)
|
fmt.Fprintf(out, "\n// %s is an auto-generated flat version of %s.", flatenedStruct.FlatStructName, flatenedStruct.OriginalStructName)
|
||||||
fmt.Fprintf(out, "\n// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.")
|
fmt.Fprintf(out, "\n// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.")
|
||||||
fmt.Fprintf(out, "\nfunc (*%s) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {", flatenedStruct.OriginalStructName)
|
fmt.Fprintf(out, "\nfunc (*%s) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {", flatenedStruct.OriginalStructName)
|
||||||
fmt.Fprintf(out, "return new(%s)", flatenedStruct.FlatStructName)
|
fmt.Fprintf(out, "\nreturn new(%s)", flatenedStruct.FlatStructName)
|
||||||
fmt.Fprint(out, "}\n")
|
fmt.Fprint(out, "\n}\n")
|
||||||
|
|
||||||
fmt.Fprintf(out, "\n// HCL2Spec returns the hcl spec of a %s.", flatenedStruct.OriginalStructName)
|
fmt.Fprintf(out, "\n// HCL2Spec returns the hcl spec of a %s.", flatenedStruct.OriginalStructName)
|
||||||
fmt.Fprintf(out, "\n// This spec is used by HCL to read the fields of %s.", flatenedStruct.OriginalStructName)
|
fmt.Fprintf(out, "\n// This spec is used by HCL to read the fields of %s.", flatenedStruct.OriginalStructName)
|
||||||
@ -225,7 +227,7 @@ func outputStructHCL2SpecBody(w io.Writer, s *types.Struct) {
|
|||||||
// outputHCL2SpecField writes the values of the `map[string]hcldec.Spec` map
|
// outputHCL2SpecField writes the values of the `map[string]hcldec.Spec` map
|
||||||
// supposed to define the HCL spec of a struct.
|
// supposed to define the HCL spec of a struct.
|
||||||
func outputHCL2SpecField(w io.Writer, accessor string, fieldType types.Type, tag *structtag.Tags) {
|
func outputHCL2SpecField(w io.Writer, accessor string, fieldType types.Type, tag *structtag.Tags) {
|
||||||
if m2h, err := tag.Get(""); err == nil && m2h.HasOption("self-defined") {
|
if m2h, err := tag.Get(mapstructureToHCL2); err == nil && m2h.HasOption("self-defined") {
|
||||||
fmt.Fprintf(w, `(&%s{}).HCL2Spec()`, fieldType.String())
|
fmt.Fprintf(w, `(&%s{}).HCL2Spec()`, fieldType.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,8 @@ func main() {
|
|||||||
fieldType = `duration string | ex: "1h5m2s"`
|
fieldType = `duration string | ex: "1h5m2s"`
|
||||||
case "config.Trilean":
|
case "config.Trilean":
|
||||||
fieldType = `boolean`
|
fieldType = `boolean`
|
||||||
|
case "hcl2template.NameValues":
|
||||||
|
fieldType = `[]{name string, value string}`
|
||||||
}
|
}
|
||||||
|
|
||||||
field := Field{
|
field := Field{
|
||||||
|
@ -47,7 +47,9 @@ type LockedBuilder struct{ unlock chan interface{} }
|
|||||||
|
|
||||||
func (b *LockedBuilder) ConfigSpec() hcldec.ObjectSpec { return nil }
|
func (b *LockedBuilder) ConfigSpec() hcldec.ObjectSpec { return nil }
|
||||||
|
|
||||||
func (b *LockedBuilder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil }
|
func (b *LockedBuilder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (b *LockedBuilder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
func (b *LockedBuilder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
||||||
ui.Say("locking build")
|
ui.Say("locking build")
|
||||||
|
37
hcl2template/types.kv.go
Normal file
37
hcl2template/types.kv.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
//go:generate mapstructure-to-hcl2 -type NameValue,NameValues,KVFilter
|
||||||
|
|
||||||
|
package hcl2template
|
||||||
|
|
||||||
|
type NameValue struct {
|
||||||
|
Name string
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
type NameValues []NameValue
|
||||||
|
|
||||||
|
func (kvs NameValues) CopyOn(to *map[string]string) []error {
|
||||||
|
if len(kvs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if *to == nil {
|
||||||
|
*to = map[string]string{}
|
||||||
|
}
|
||||||
|
for _, kv := range kvs {
|
||||||
|
(*to)[kv.Name] = kv.Value
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type KVFilter struct {
|
||||||
|
Filters map[string]string
|
||||||
|
Filter NameValues
|
||||||
|
}
|
||||||
|
|
||||||
|
func (kvf *KVFilter) Prepare() []error {
|
||||||
|
kvf.Filter.CopyOn(&kvf.Filters)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (kvf *KVFilter) Empty() bool {
|
||||||
|
return len(kvf.Filters) == 0
|
||||||
|
}
|
57
hcl2template/types.kv.hcl2spec.go
Normal file
57
hcl2template/types.kv.hcl2spec.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Code generated by "mapstructure-to-hcl2 -type NameValue,NameValues,KVFilter"; DO NOT EDIT.
|
||||||
|
package hcl2template
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
|
"github.com/zclconf/go-cty/cty"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FlatKVFilter is an auto-generated flat version of KVFilter.
|
||||||
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
|
type FlatKVFilter struct {
|
||||||
|
Filters map[string]string `cty:"filters"`
|
||||||
|
Filter []FlatNameValue `cty:"filter"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FlatMapstructure returns a new FlatKVFilter.
|
||||||
|
// FlatKVFilter is an auto-generated flat version of KVFilter.
|
||||||
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||||
|
func (*KVFilter) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||||
|
return new(FlatKVFilter)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HCL2Spec returns the hcl spec of a KVFilter.
|
||||||
|
// This spec is used by HCL to read the fields of KVFilter.
|
||||||
|
// The decoded values from this spec will then be applied to a FlatKVFilter.
|
||||||
|
func (*FlatKVFilter) HCL2Spec() map[string]hcldec.Spec {
|
||||||
|
s := map[string]hcldec.Spec{
|
||||||
|
"filters": &hcldec.BlockAttrsSpec{TypeName: "filters", ElementType: cty.String, Required: false},
|
||||||
|
"filter": &hcldec.BlockListSpec{TypeName: "filter", Nested: hcldec.ObjectSpec((*FlatNameValue)(nil).HCL2Spec())},
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// FlatNameValue is an auto-generated flat version of NameValue.
|
||||||
|
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||||
|
type FlatNameValue struct {
|
||||||
|
Name *string `cty:"name"`
|
||||||
|
Value *string `cty:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FlatMapstructure returns a new FlatNameValue.
|
||||||
|
// FlatNameValue is an auto-generated flat version of NameValue.
|
||||||
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||||
|
func (*NameValue) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||||
|
return new(FlatNameValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HCL2Spec returns the hcl spec of a NameValue.
|
||||||
|
// This spec is used by HCL to read the fields of NameValue.
|
||||||
|
// The decoded values from this spec will then be applied to a FlatNameValue.
|
||||||
|
func (*FlatNameValue) HCL2Spec() map[string]hcldec.Spec {
|
||||||
|
s := map[string]hcldec.Spec{
|
||||||
|
"name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false},
|
||||||
|
"value": &hcldec.AttrSpec{Name: "value", Type: cty.String, Required: false},
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
@ -148,7 +148,9 @@ type FlatSSH struct {
|
|||||||
// FlatMapstructure returns a new FlatSSH.
|
// FlatMapstructure returns a new FlatSSH.
|
||||||
// FlatSSH is an auto-generated flat version of SSH.
|
// FlatSSH is an auto-generated flat version of SSH.
|
||||||
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||||
func (*SSH) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { return new(FlatSSH) }
|
func (*SSH) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||||
|
return new(FlatSSH)
|
||||||
|
}
|
||||||
|
|
||||||
// HCL2Spec returns the hcl spec of a SSH.
|
// HCL2Spec returns the hcl spec of a SSH.
|
||||||
// This spec is used by HCL to read the fields of SSH.
|
// This spec is used by HCL to read the fields of SSH.
|
||||||
@ -206,7 +208,9 @@ type FlatWinRM struct {
|
|||||||
// FlatMapstructure returns a new FlatWinRM.
|
// FlatMapstructure returns a new FlatWinRM.
|
||||||
// FlatWinRM is an auto-generated flat version of WinRM.
|
// FlatWinRM is an auto-generated flat version of WinRM.
|
||||||
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||||
func (*WinRM) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { return new(FlatWinRM) }
|
func (*WinRM) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||||
|
return new(FlatWinRM)
|
||||||
|
}
|
||||||
|
|
||||||
// HCL2Spec returns the hcl spec of a WinRM.
|
// HCL2Spec returns the hcl spec of a WinRM.
|
||||||
// This spec is used by HCL to read the fields of WinRM.
|
// This spec is used by HCL to read the fields of WinRM.
|
||||||
|
@ -107,6 +107,8 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
|
|||||||
errs, fmt.Errorf("Error parsing oss_key_name template: %s", err))
|
errs, fmt.Errorf("Error parsing oss_key_name template: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errs = packer.MultiErrorAppend(errs, p.config.AlicloudImageTag.CopyOn(&p.config.AlicloudImageTags)...)
|
||||||
|
|
||||||
// Check we have alicloud access variables defined somewhere
|
// Check we have alicloud access variables defined somewhere
|
||||||
errs = packer.MultiErrorAppend(errs, p.config.AlicloudAccessConfig.Prepare(&p.config.ctx)...)
|
errs = packer.MultiErrorAppend(errs, p.config.AlicloudAccessConfig.Prepare(&p.config.ctx)...)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ package alicloudimport
|
|||||||
import (
|
import (
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/builder/alicloud/ecs"
|
"github.com/hashicorp/packer/builder/alicloud/ecs"
|
||||||
|
"github.com/hashicorp/packer/hcl2template"
|
||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ type FlatConfig struct {
|
|||||||
AlicloudImageForceDeleteInstances *bool `mapstructure:"image_force_delete_instances" cty:"image_force_delete_instances"`
|
AlicloudImageForceDeleteInstances *bool `mapstructure:"image_force_delete_instances" cty:"image_force_delete_instances"`
|
||||||
AlicloudImageIgnoreDataDisks *bool `mapstructure:"image_ignore_data_disks" required:"false" cty:"image_ignore_data_disks"`
|
AlicloudImageIgnoreDataDisks *bool `mapstructure:"image_ignore_data_disks" required:"false" cty:"image_ignore_data_disks"`
|
||||||
AlicloudImageTags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
AlicloudImageTags map[string]string `mapstructure:"tags" required:"false" cty:"tags"`
|
||||||
|
AlicloudImageTag []hcl2template.FlatNameValue `mapstructure:"tag" required:"false" cty:"tag"`
|
||||||
ECSSystemDiskMapping *ecs.FlatAlicloudDiskDevice `mapstructure:"system_disk_mapping" required:"false" cty:"system_disk_mapping"`
|
ECSSystemDiskMapping *ecs.FlatAlicloudDiskDevice `mapstructure:"system_disk_mapping" required:"false" cty:"system_disk_mapping"`
|
||||||
ECSImagesDiskMappings []ecs.FlatAlicloudDiskDevice `mapstructure:"image_disk_mappings" required:"false" cty:"image_disk_mappings"`
|
ECSImagesDiskMappings []ecs.FlatAlicloudDiskDevice `mapstructure:"image_disk_mappings" required:"false" cty:"image_disk_mappings"`
|
||||||
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" cty:"associate_public_ip_address"`
|
AssociatePublicIpAddress *bool `mapstructure:"associate_public_ip_address" cty:"associate_public_ip_address"`
|
||||||
@ -153,6 +155,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||||||
"image_force_delete_instances": &hcldec.AttrSpec{Name: "image_force_delete_instances", Type: cty.Bool, Required: false},
|
"image_force_delete_instances": &hcldec.AttrSpec{Name: "image_force_delete_instances", Type: cty.Bool, Required: false},
|
||||||
"image_ignore_data_disks": &hcldec.AttrSpec{Name: "image_ignore_data_disks", Type: cty.Bool, Required: false},
|
"image_ignore_data_disks": &hcldec.AttrSpec{Name: "image_ignore_data_disks", Type: cty.Bool, Required: false},
|
||||||
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
"tags": &hcldec.BlockAttrsSpec{TypeName: "tags", ElementType: cty.String, Required: false},
|
||||||
|
"tag": &hcldec.BlockListSpec{TypeName: "tag", Nested: hcldec.ObjectSpec((*hcl2template.FlatNameValue)(nil).HCL2Spec())},
|
||||||
"system_disk_mapping": &hcldec.BlockSpec{TypeName: "system_disk_mapping", Nested: hcldec.ObjectSpec((*ecs.FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
"system_disk_mapping": &hcldec.BlockSpec{TypeName: "system_disk_mapping", Nested: hcldec.ObjectSpec((*ecs.FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
||||||
"image_disk_mappings": &hcldec.BlockListSpec{TypeName: "image_disk_mappings", Nested: hcldec.ObjectSpec((*ecs.FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
"image_disk_mappings": &hcldec.BlockListSpec{TypeName: "image_disk_mappings", Nested: hcldec.ObjectSpec((*ecs.FlatAlicloudDiskDevice)(nil).HCL2Spec())},
|
||||||
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
"associate_public_ip_address": &hcldec.AttrSpec{Name: "associate_public_ip_address", Type: cty.Bool, Required: false},
|
||||||
|
@ -491,14 +491,14 @@ func TestProvisioner_RemoteFileDefaultsToScriptnnnn(t *testing.T) {
|
|||||||
t.Fatalf("should not have error: %s", err)
|
t.Fatalf("should not have error: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteFileRegex := regexp.MustCompile("script_[0-9]{4}.sh")
|
remoteFileRegex := regexp.MustCompile("script_[0-9]{1,4}.sh")
|
||||||
|
|
||||||
if !remoteFileRegex.MatchString(p.config.RemoteFile) {
|
if !remoteFileRegex.MatchString(p.config.RemoteFile) {
|
||||||
t.Fatalf("remote_file did not default to script_nnnn.sh")
|
t.Fatalf("remote_file did not default to script_nnnn.sh: %q", p.config.RemoteFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !remoteFileRegex.MatchString(p.config.RemotePath) {
|
if !remoteFileRegex.MatchString(p.config.RemotePath) {
|
||||||
t.Fatalf("remote_path did not match script_nnnn.sh")
|
t.Fatalf("remote_path did not match script_nnnn.sh: %q", p.config.RemotePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/tools/imports"
|
||||||
)
|
)
|
||||||
|
|
||||||
const target = "command/plugin.go"
|
const target = "command/plugin.go"
|
||||||
@ -58,6 +60,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
output = string(goFmt(target, []byte(output)))
|
||||||
|
|
||||||
_, err = file.WriteString(output)
|
_, err = file.WriteString(output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed writing to %s: %s", target, err)
|
log.Fatalf("Failed writing to %s: %s", target, err)
|
||||||
@ -66,6 +70,15 @@ func main() {
|
|||||||
log.Printf("Generated %s", target)
|
log.Printf("Generated %s", target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func goFmt(filename string, b []byte) []byte {
|
||||||
|
fb, err := imports.Process(filename, b, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("formatting err: %v", err)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
return fb
|
||||||
|
}
|
||||||
|
|
||||||
type plugin struct {
|
type plugin struct {
|
||||||
Package string // This plugin's package name (iso)
|
Package string // This plugin's package name (iso)
|
||||||
PluginName string // Name of plugin (vmware-iso)
|
PluginName string // Name of plugin (vmware-iso)
|
||||||
|
@ -49,6 +49,10 @@
|
|||||||
- `skip_region_validation` (bool) - The region validation can be skipped
|
- `skip_region_validation` (bool) - The region validation can be skipped
|
||||||
if this value is true, the default value is false.
|
if this value is true, the default value is false.
|
||||||
|
|
||||||
- `tags` (map[string]string) - Tags applied to the destination
|
- `tags` (map[string]string) - Tags applied to the destination image and relevant snapshots.
|
||||||
image and relevant snapshots.
|
|
||||||
|
- `tag` ([]{name string, value string}) - Same as [`tags`](#tags) but defined as a singular repeatable block
|
||||||
|
containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
@ -121,10 +121,15 @@
|
|||||||
criteria provided in `source_ami_filter`; this pins the AMI returned by the
|
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.
|
filter, but will cause Packer to fail if the `source_ami` does not exist.
|
||||||
|
|
||||||
- `root_volume_tags` (awscommon.TagMap) - Tags to apply to the volumes that are *launched*. This is a [template
|
- `root_volume_tags` (map[string]string) - Tags to apply to the volumes that are *launched*. This is a [template
|
||||||
engine](/docs/templates/engine.html), see [Build template
|
engine](/docs/templates/engine.html), see [Build template
|
||||||
data](#build-template-data) for more information.
|
data](#build-template-data) for more information.
|
||||||
|
|
||||||
|
- `root_volume_tag` ([]{name string, value string}) - Same as [`root_volume_tags`](#root_volume_tags) but defined as a
|
||||||
|
singular block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `ami_architecture` (string) - what architecture to use when registering the final AMI; valid options
|
- `ami_architecture` (string) - what architecture to use when registering the final AMI; valid options
|
||||||
are "x86_64" or "arm64". Defaults to "x86_64".
|
are "x86_64" or "arm64". Defaults to "x86_64".
|
||||||
|
|
@ -28,10 +28,15 @@
|
|||||||
- `skip_region_validation` (bool) - Set to true if you want to skip
|
- `skip_region_validation` (bool) - Set to true if you want to skip
|
||||||
validation of the ami_regions configuration option. Default false.
|
validation of the ami_regions configuration option. Default false.
|
||||||
|
|
||||||
- `tags` (TagMap) - Tags applied to the AMI. This is a
|
- `tags` (map[string]string) - Tags applied to the AMI. This is a
|
||||||
[template engine](/docs/templates/engine.html), see [Build template
|
[template engine](/docs/templates/engine.html), see [Build template
|
||||||
data](#build-template-data) for more information.
|
data](#build-template-data) for more information.
|
||||||
|
|
||||||
|
- `tag` ([]{name string, value string}) - Same as [`tags`](#tags) but defined as a singular repeatable block
|
||||||
|
containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) on
|
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) on
|
||||||
HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your
|
HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your
|
||||||
AWS IAM policy.
|
AWS IAM policy.
|
||||||
@ -93,11 +98,16 @@
|
|||||||
the intermediary AMI into any regions provided in `ami_regions`, then
|
the intermediary AMI into any regions provided in `ami_regions`, then
|
||||||
delete the intermediary AMI. Default `false`.
|
delete the intermediary AMI. Default `false`.
|
||||||
|
|
||||||
- `snapshot_tags` (TagMap) - Tags to apply to snapshot.
|
- `snapshot_tags` (map[string]string) - Tags to apply to snapshot.
|
||||||
They will override AMI tags if already applied to snapshot. This is a
|
They will override AMI tags if already applied to snapshot. This is a
|
||||||
[template engine](../templates/engine.html), see [Build template
|
[template engine](../templates/engine.html), see [Build template
|
||||||
data](#build-template-data) for more information.
|
data](#build-template-data) for more information.
|
||||||
|
|
||||||
|
- `snapshot_tag` ([]{name string, value string}) - Same as [`snapshot_tags`](#snapshot_tags) but defined as a singular
|
||||||
|
repeatable block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `snapshot_users` ([]string) - A list of account IDs that have
|
- `snapshot_users` ([]string) - A list of account IDs that have
|
||||||
access to create volumes from the snapshot(s). By default no additional
|
access to create volumes from the snapshot(s). By default no additional
|
||||||
users other than the user creating the AMI has permissions to create
|
users other than the user creating the AMI has permissions to create
|
||||||
|
@ -113,6 +113,11 @@
|
|||||||
EBS volumes. This is a [template engine](/docs/templates/engine.html),
|
EBS volumes. This is a [template engine](/docs/templates/engine.html),
|
||||||
see [Build template data](#build-template-data) for more information.
|
see [Build template data](#build-template-data) for more information.
|
||||||
|
|
||||||
|
- `run_tag` ([]{name string, value string}) - Same as [`run_tags`](#run_tags) but defined as a singular repeatable
|
||||||
|
block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `security_group_id` (string) - The ID (not the name) of the security
|
- `security_group_id` (string) - The ID (not the name) of the security
|
||||||
group to assign to the instance. By default this is not set and Packer will
|
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.
|
automatically create a new temporary security group to allow SSH access.
|
||||||
@ -197,8 +202,13 @@
|
|||||||
Windows, Linux/UNIX (Amazon VPC), SUSE Linux (Amazon VPC),
|
Windows, Linux/UNIX (Amazon VPC), SUSE Linux (Amazon VPC),
|
||||||
Windows (Amazon VPC)
|
Windows (Amazon VPC)
|
||||||
|
|
||||||
- `spot_tags` (map[string]string) - Requires spot_price to be
|
- `spot_tags` (map[string]string) - Requires spot_price to be set. This tells Packer to apply tags to the
|
||||||
set. This tells Packer to apply tags to the spot request that is issued.
|
spot request that is issued.
|
||||||
|
|
||||||
|
- `spot_tag` ([]{name string, value string}) - Same as [`spot_tags`](#spot_tags) but defined as a singular repeatable block
|
||||||
|
containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `subnet_filter` (SubnetFilterOptions) - Filters used to populate the `subnet_id` field.
|
- `subnet_filter` (SubnetFilterOptions) - Filters used to populate the `subnet_id` field.
|
||||||
Example:
|
Example:
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<!-- Code generated from the comments of the BlockDevice struct in builder/amazon/ebsvolume/block_device.go; DO NOT EDIT MANUALLY -->
|
<!-- Code generated from the comments of the BlockDevice struct in builder/amazon/ebsvolume/block_device.go; DO NOT EDIT MANUALLY -->
|
||||||
|
|
||||||
- `tags` (awscommon.TagMap) - Tags to apply to the volume. These are retained after the builder
|
- `tags` (map[string]string) - Tags to apply to the volume. These are retained after the builder
|
||||||
completes. This is a [template engine](/docs/templates/engine.html), see
|
completes. This is a [template engine](/docs/templates/engine.html), see
|
||||||
[Build template data](#build-template-data) for more information.
|
[Build template data](#build-template-data) for more information.
|
||||||
|
|
||||||
|
- `tag` ([]{name string, value string}) - Same as [`tags`](#tags) but defined as a singular repeatable block
|
||||||
|
containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
@ -23,7 +23,7 @@
|
|||||||
source instance. See the [BlockDevices](#block-devices-configuration)
|
source instance. See the [BlockDevices](#block-devices-configuration)
|
||||||
documentation for fields.
|
documentation for fields.
|
||||||
|
|
||||||
- `run_volume_tags` (awscommon.TagMap) - Tags to apply to the volumes of the instance that is *launched* to
|
- `run_volume_tags` (map[string]string) - Tags to apply to the volumes of the instance that is *launched* to
|
||||||
create EBS Volumes. These tags will *not* appear in the tags of the
|
create EBS Volumes. These tags will *not* appear in the tags of the
|
||||||
resulting EBS volumes unless they're duplicated under `tags` in the
|
resulting EBS volumes unless they're duplicated under `tags` in the
|
||||||
`ebs_volumes` setting. This is a [template
|
`ebs_volumes` setting. This is a [template
|
||||||
@ -35,4 +35,10 @@
|
|||||||
created. Packer will replace all tags on the volume with the tags
|
created. Packer will replace all tags on the volume with the tags
|
||||||
configured in the `ebs_volumes` section as soon as the instance is
|
configured in the `ebs_volumes` section as soon as the instance is
|
||||||
reported as 'ready'.
|
reported as 'ready'.
|
||||||
|
|
||||||
|
- `run_volume_tag` ([]{name string, value string}) - Same as [`run_volume_tags`](#run_volume_tags) but defined as a singular
|
||||||
|
repeatable block containing a `name` and a `value` field. In HCL2 mode
|
||||||
|
the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
@ -100,6 +100,11 @@
|
|||||||
256 characters. Tags are applied to every resource deployed by a Packer
|
256 characters. Tags are applied to every resource deployed by a Packer
|
||||||
build, i.e. Resource Group, VM, NIC, VNET, Public IP, KeyVault, etc.
|
build, i.e. Resource Group, VM, NIC, VNET, Public IP, KeyVault, etc.
|
||||||
|
|
||||||
|
- `azure_tag` ([]{name string, value string}) - Same as [`azure_tags`](#azure_tags) but defined as a singular repeatable block
|
||||||
|
containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `resource_group_name` (string) - Resource group under which the final artifact will be stored.
|
- `resource_group_name` (string) - Resource group under which the final artifact will be stored.
|
||||||
|
|
||||||
- `storage_account` (string) - Storage account under which the final artifact will be stored.
|
- `storage_account` (string) - Storage account under which the final artifact will be stored.
|
||||||
|
@ -15,8 +15,12 @@
|
|||||||
|
|
||||||
- `image_description` (string) - The description of the resulting image.
|
- `image_description` (string) - The description of the resulting image.
|
||||||
|
|
||||||
- `image_tags` (map[string]string) - Key/value pair tags to
|
- `image_tags` (map[string]string) - Key/value pair tags to add to the created image.
|
||||||
add to the created image.
|
|
||||||
|
- `image_tag` ([]{name string, value string}) - Same as [`image_tags`](#image_tags) but defined as a singular repeatable
|
||||||
|
block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `image_service` (string) - The service of the resulting image.
|
- `image_service` (string) - The service of the resulting image.
|
||||||
|
|
||||||
@ -25,6 +29,11 @@
|
|||||||
- `vm_tags` (map[string]string) - Key/value pair tags to
|
- `vm_tags` (map[string]string) - Key/value pair tags to
|
||||||
add to the created server.
|
add to the created server.
|
||||||
|
|
||||||
|
- `vm_tag` ([]{name string, value string}) - Same as [`vm_tags`](#vm_tags) but defined as a singular repeatable block
|
||||||
|
containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `disk_name` (string) - The name of the created disk.
|
- `disk_name` (string) - The name of the created disk.
|
||||||
|
|
||||||
- `disk_type` (string) - The type of the created disk. Defaults to ssd.
|
- `disk_type` (string) - The type of the created disk. Defaults to ssd.
|
||||||
|
@ -55,4 +55,9 @@
|
|||||||
- `run_tags` (map[string]string) - Tags to apply to the instance that is *launched* to create the image.
|
- `run_tags` (map[string]string) - Tags to apply to the instance that is *launched* to create the image.
|
||||||
These tags are *not* applied to the resulting image.
|
These tags are *not* applied to the resulting image.
|
||||||
|
|
||||||
|
- `run_tag` ([]{name string, value string}) - Same as [`run_tags`](#run_tags) but defined as a singular repeatable
|
||||||
|
block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `ssh_private_ip` (bool) - SSH Private Ip
|
- `ssh_private_ip` (bool) - SSH Private Ip
|
@ -23,8 +23,12 @@
|
|||||||
set the user-script metadata key to have Triton start a user supplied
|
set the user-script metadata key to have Triton start a user supplied
|
||||||
script after the VM has booted.
|
script after the VM has booted.
|
||||||
|
|
||||||
- `source_machine_tags` (map[string]string) - Tags applied to the
|
- `source_machine_tags` (map[string]string) - Tags applied to the VM used to create the image.
|
||||||
VM used to create the image.
|
|
||||||
|
- `source_machine_tag` ([]{name string, value string}) - Same as [`source_machine_tags`](#source_machine_tags) but defined as a
|
||||||
|
singular block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
||||||
- `source_machine_firewall_enabled` (bool) - Whether or not the firewall
|
- `source_machine_firewall_enabled` (bool) - Whether or not the firewall
|
||||||
of the VM used to create an image of is enabled. The Triton firewall only
|
of the VM used to create an image of is enabled. The Triton firewall only
|
||||||
|
@ -14,4 +14,9 @@
|
|||||||
credentials are used) will have access to the image.
|
credentials are used) will have access to the image.
|
||||||
|
|
||||||
- `image_tags` (map[string]string) - Tag applied to the image.
|
- `image_tags` (map[string]string) - Tag applied to the image.
|
||||||
|
|
||||||
|
- `image_tag` ([]{name string, value string}) - Same as [`image_tags`](#image_tags) but defined as a singular repeatable
|
||||||
|
block containing a `name` and a `value` field. In HCL2 mode the
|
||||||
|
[`dynamic_block`](https://packer.io/docs/configuration/from-1.5/expressions.html#dynamic-blocks)
|
||||||
|
will allow you to create those programatically.
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user