wip
This commit is contained in:
parent
b5e8750f5f
commit
911dc5ad95
|
@ -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"
|
||||||
|
@ -65,6 +66,12 @@ type Config struct {
|
||||||
// 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 map[string]string `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)...)
|
||||||
|
|
|
@ -152,6 +152,7 @@ type FlatConfig struct {
|
||||||
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 map[string]string `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.
|
||||||
|
@ -262,6 +263,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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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` (hcl2template.NameValues) - 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.
|
||||||
|
|
Loading…
Reference in New Issue