fix(Packer): AWS images bugs
[csit.git] / fdio.infra.packer / aws_c5n / ubuntu_focal.pkr.hcl
@@ -8,13 +8,21 @@ packer {
 }
 
 variable "first_run_commands" {
-  description = "Commands to run after deployment via remote-exec"
+  description = "Commands to run before deployment via remote-exec"
   type        = list(string)
   default     = [
     ""
   ]
 }
 
+variable "last_run_commands" {
+  description = "Commands to run after deployment via remote-exec"
+  type        = list(string)
+  default     = [
+    "sudo sed -i 's/Unattended-Upgrade \"1\"/Unattended-Upgrade \"0\"/g' /etc/apt/apt.conf.d/20auto-upgrades"
+  ]
+}
+
 variable "ansible_file_path" {
   description = "Path to Ansible playbook"
   type        = string
@@ -43,7 +51,7 @@ source "amazon-ebs" "csit_c5n_ubuntu_focal_sut" {
   ami_name         = "csit_c5n_ubuntu_focal_sut"
   ami_description  = "CSIT SUT image based on Ubuntu Focal"
   ena_support      = true
-  instance_type    = "c5n.9xlarge"
+  instance_type    = "c5n.4xlarge"
   launch_block_device_mappings {
     device_name = "/dev/sda1"
     volume_size = 40
@@ -60,7 +68,7 @@ source "amazon-ebs" "csit_c5n_ubuntu_focal_tg" {
   ami_name         = "csit_c5n_ubuntu_focal_tg"
   ami_description  = "CSIT TG image based on Ubuntu Focal"
   ena_support      = true
-  instance_type    = "c5n.9xlarge"
+  instance_type    = "c5n.4xlarge"
   launch_block_device_mappings {
     device_name = "/dev/sda1"
     volume_size = 40
@@ -91,6 +99,9 @@ build {
       "--extra-vars", "aws=true"
     ]
   }
+  provisioner "shell" {
+    inline = var.last_run_commands
+  }
 }
 
 build {
@@ -111,4 +122,7 @@ build {
       "--extra-vars", "aws=true"
     ]
   }
+  provisioner "shell" {
+    inline = var.last_run_commands
+  }
 }