Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boolean to make run_tags the same as tags #8695

Closed
nitrocode opened this issue Feb 5, 2020 · 5 comments
Closed

boolean to make run_tags the same as tags #8695

nitrocode opened this issue Feb 5, 2020 · 5 comments

Comments

@nitrocode
Copy link
Contributor

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Feature Description

I'd like to make run_tags the same as tags using a boolean like "tags_same" = true, or similar which can make all tagging the same as what is defined in tags.

Use Case(s)

Tired of adding new tags to one but not the other. I'd like to keep things DRY as much as possible.

@azr
Copy link
Contributor

azr commented Feb 6, 2020

Hello @nitrocode, thanks for opening. We recently merged #8588 that allows to use variables in HCL2. I would like to talk about the feasibility of this in Packer HCL2 and how I think it should/will proably work ( we are not quite there yet ):

1/ I think we should add the possibility to define the tag field instead of tags, to be defined like this:

source "amazon-ebs" "example-source" {
  tag {
    key                 = "Name"
    value               = "example-asg-name"
    propagate_at_launch = false
  }
  //...

I think this would solve one issue here.

2/ from there we will need to introduce the dynamic block from Terraform

locals {
  standard_tags = {
    Component   = "user-service"
    Environment = "production"
  }
}

source "amazon-ebs" "example-source" {
  // same as before
  dynamic "tag" {
    for_each = local.standard_tags

    content {
      key                 = tag.key
      value               = tag.value
      propagate_at_launch = true
    }
}

@azr
Copy link
Contributor

azr commented Feb 6, 2020

Here are the places where that could be handy:

Builders: https://github.com/hashicorp/packer/blob/ecaec1ac584895dd8588ba3ffa4e74afad2be20b/builder/alicloud/ecs/image_config.go#L194

AMIRegionKMSKeyIDs map[string]string `mapstructure:"region_kms_key_ids" required:"false"`

RunTags map[string]string `mapstructure:"run_tags" required:"false"`

SpotTags map[string]string `mapstructure:"spot_tags" required:"false"`

AMITags TagMap `mapstructure:"tags" required:"false"`

Tags awscommon.TagMap `mapstructure:"tags" required:"false"`

Tags map[string]string `mapstructure:"tags"`

Volumes map[string]string `mapstructure:"volumes" required:"false"`

ImageLabels map[string]string `mapstructure:"image_labels" required:"false"`

ImageLabels map[string]string `mapstructure:"image_labels" required:"false"`

Metadata map[string]string `mapstructure:"metadata" required:"false"`

MetadataFiles map[string]string `mapstructure:"metadata_files"`

SnapshotLabels map[string]string `mapstructure:"snapshot_labels"`

ImageTags map[string]string `mapstructure:"image_tags" required:"false"`

VmTags map[string]string `mapstructure:"vm_tags" required:"false"`

PublishProperties map[string]string `mapstructure:"publish_properties" required:"false"`

LaunchConfig map[string]string `mapstructure:"launch_config" required:"false"`

ImageTags []string `mapstructure:"image_tags"`

InstanceMetadata map[string]string `mapstructure:"instance_metadata" required:"false"`

Properties map[string]string `mapstructure:"properties"`

Tags map[string]string `mapstructure:"tags"`

Tags osccommon.TagMap `mapstructure:"tags"`

OMITags TagMap `mapstructure:"tags"`

MachineMetadata map[string]string `mapstructure:"source_machine_metadata" required:"false"`
// Tags applied to the
// VM used to create the image.
MachineTags map[string]string `mapstructure:"source_machine_tags" required:"false"`

ImageTags map[string]string `mapstructure:"image_tags" required:"false"`

VMXData map[string]string `mapstructure:"vmx_data" required:"false"`
// Identical to vmx_data,
// except that it is run after the virtual machine is shutdown, and before the
// virtual machine is exported.
VMXDataPost map[string]string `mapstructure:"vmx_data_post" required:"false"`

ConfigParams map[string]string `mapstructure:"configuration_parameters"`

ImageLabels map[string]string `mapstructure:"image_labels" required:"false"`

Labels map[string]string `mapstructure:"labels" required:"false"`

Metadata map[string]string `mapstructure:"metadata" required:"false"`
// Metadata applied to the launched instance. Value are file paths.
MetadataFromFile map[string]string `mapstructure:"metadata_from_file"`

There are also post-processors where that could be used.

Note that this wouldn't necessarily be a breaking change as a new tag/property field would be introduced. We would have to sort of deprecate tags/properties fields and may be come up with a way to help users fix their templates, ( or don't, and not deprecate anything ).

@azr
Copy link
Contributor

azr commented Feb 12, 2020

Hey there, yesterday I opened #8720 that adds support for dynamic blocks. Up next we will need to add that new tag specific type.

@ghost
Copy link

ghost commented Mar 29, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-amazon#10 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-amazon#10.

@ghost
Copy link

ghost commented Apr 29, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 29, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants