As certain cloud environments enforce the tagging of resources, DKP platform users have inquired about whether is possible adding custom tags to AMIs built with Konvoy Image Builder (KIB).
As of now, adding a custom tag as an attribute to the AMI is only possible by modifying the packer.json file. Below we describe the steps to do so.
- Generate manifest files for the KIB run by executing:
and sending./konvoy-image build images/ami/centos-79.yaml
SIGINT
to the process to kill it. During the attempt to build the AMI a packer.json is generated under the pathwork/centos-7-xxxxxxx-yyyyy/packer.json
. - Edit the packer.json by adding the parameter "run_tags" to the packer.json file.
"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"
}, - Use the packer manifest option to build the AMI:
./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.23.7-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...
Our engineering team is working on adding a feature to KIB that allows adding tags just by passing a flag.