Windows AMI Creation hang at "Waiting for WinRM to become available..."

Packer build hang at “Waiting for WinRM to become available…” & timedout with error - Build ‘amazon-ebs.firstrun-windows’ errored after 31 minutes 34 seconds: Timeout waiting for WinRM. Please suggest the resolution for this.

The packer template used is:

packer {

  • required_plugins {*
  • amazon = {*
  •  version = ">= 1.2.6"*
    
  •  source  = "github.com/hashicorp/amazon"*
    
  • }*
  • }*
    }

locals {

  • timestamp = regex_replace(timestamp(), “[- TZ:]”, “”)*
    }

source “amazon-ebs” “firstrun-windows” {

  • ami_name = “windows-AMI-${local.timestamp}”*
  • communicator = “winrm”*
  • instance_type = “t2.micro”*
  • region = “eu-west-1”*
  • source_ami = “ami-0855cc7dacc5f76eb”*
  • vpc_id = “vpc-0a0da2b55ae0d823f”*
  • subnet_id = “subnet-06a81422c8db10488”*
  • winrm_username = “Administrator”*
    }

build {

  • sources = [*
  • “source.amazon-ebs.firstrun-windows”*
  • ]*

}