Skip to main content
Skip table of contents

Add Custom Tags to your Image

Some cloud environments enforce the tagging of resources. Is it possible to add custom tags on an image that was built with Konvoy Image Builder(KIB)? Currently, adding a custom tag as an attribute to the image is only possible by modifying the packer.pkr.hcl file.

In order to add a tag, perform the commands below: 

  1. Generate manifest files for KIB by executing the following command. In this AWS example, we're building a CentOS 7.9 image:

    CODE
    ./konvoy-image build images/ami/centos-79.yaml

Other provider commands are located in the Konvoy Image Builder under each provider.

  1. Send SIGINT to the process to kill it after seeing the output ...writing new packer configuration to work/centos-7-xxxxxxx-yyyyy. During the attempt to build the image, a packer.pkr.hcl is generated under the path work/centos-7-xxxxxxx-yyyyy/packer.pkr.hcl.

  2.  Edit the packer.pkr.hcl file by adding the parameter "run_tags" to the packer.pkr.hcl file as seen in the AWS example below:

    CODE
     "builders": [
    {
    "name": "{{(user `distribution`) | lower}}-{{user `distribution_version`}}{{user `build_name_extra`}}",
    "type": "amazon-ebs",
    "run_tags": {"my_custom_tag": "tag"},
    "instance_type": "{{user `aws_instance_type`}}",
    "source_ami_filter": {
    "filters": {
    "virtualization-type": "hvm",
    "name": "{{user `ami_filter_name`}}",
    "root-device-type": "ebs",
    "architecture": "x86_64"
    },

  3. Use the --packer-manifest flag to apply it when you build the image:

    CODE
    ./konvoy-image build aws images/ami/centos-79.yaml --packer-manifest=work/centos-7-1658174984-TycMM/packer.pkr.hcl
    2022/09/07 18:23:33 writing new packer configuration to work/centos-7-1662575013-zJUhP
    2022/09/07 18:23:33 starting packer build
    centos-7.9: output will be in this color.
    
    ==> centos-7.9: Prevalidating any provided VPC information
    ==> centos-7.9: Prevalidating AMI Name: konvoy-ami-centos-7-1.26.3-1662575013
    centos-7.9: Found Image ID: ami-0686851c4e7b1a8e1
    ==> centos-7.9: Creating temporary keypair: packer_6318e1a6-9f45-c01b-c7ca-f5404735f709
    ==> centos-7.9: Creating temporary security group for this instance: packer_6318e1aa-7448-d74b-9b90-166f26d21619
    ==> centos-7.9: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
    ==> centos-7.9: Launching a source AWS instance...
    centos-7.9: Adding tag: "my_custom_tag": "tag"
    centos-7.9: Instance ID: i-04d457b20713dcf7d
    ==> centos-7.9: Waiting for instance (i-04d457b20713dcf7d) to become ready...
    ==> centos-7.9: Using SSH communicator to connect: 34.222.153.107
    ==> centos-7.9: Waiting for SSH to become available...


    Now that your tags have been added to the image, you can continue to Custom Installation and Additional Infrastructure Tools. There you will build the image with your edited manifest and finish building your clusters under your infrastructure.

Next Topic

Using Override Files with Konvoy Image Builder

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.