Skip to main content
Skip table of contents

Add Custom Tags to Image

As certain cloud environments enforce the tagging of resources, DKP platform users have inquired about whether is possible to add custom tags on an AMI that was built with Konvoy Image Builder (KIB). Currently, adding a custom tag as an attribute to the AMI is only possible by modifying the packer.json file.

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

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

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

  2. 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 AMI a packer.json is generated under the path work/centos-7-xxxxxxx-yyyyy/packer.json.

  3.  Edit the packer.json file by adding the parameter "run_tags" to the packer.json file as seen in the 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"
    },

  4. Use the packer manifest option to build the AMI:

    CODE
    ./konvoy-image build aws images/ami/centos-79.yaml --packer-manifest=work/centos-7-1658174984-TycMM/packer.json
    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.25.4-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 AMI, you can continue to Advanced Configuration for AWS and finish building your clusters.

JavaScript errors detected

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

If this problem persists, please contact our support.