hashicorp / hashicorp/packer-plugin-amazon

WinRM I/O timeout during packer build when using private subnet

Open
#190 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
91
Forks
141
Avg merge
2d 18h
Merged PRs (30d)
3

Description

_This issue was originally opened by @JrInfra in https://github.com/hashicorp/packer/issues/11444 and has been migrated to this repository. The original issue description is below._

---
### Overview of the Issue
I'm trying to create an AWS AMI with packer but it seems like I am running into an issue where it seems WinRM keeps timing out when I use a private subnet.

I've taken a look and can see there is a IGW attached to the VPC and when I do try this with a public subnet, its able to connect to WinRM just fine with no issues.

My question is what can be stopping winRM from connecting and how to prevent timeouts from occurring?

### Reproduction Steps:
Launch the template and attempt to create AMI (packer build .)

### Packer version
1.7.8

### Simplified Packer Template:
`packer {
required_plugins {
amazon = {
version = ">= 0.0.2"
source = "github.com/hashicorp/amazon"
}
}
}

source "amazon-ebs" "windows_server" {
ami_description = "TestAMI"
ami_name = "TestAMI"
ami_users = ["${var.ami_users}"]
associate_public_ip_address = false
communicator = "winrm"
instance_type = "${var.instance_type}"
region = "${var.aws_region}"
security_group_id = "${var.security_group_id}"
force_deregister = true
force_delete_snapshot = true
source_ami_filter {
filters = {
architecture = "x86_64"
name = "Windows_Server-2019-English-Full-ContainersLatest-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["amazon"]
}
subnet_id = "${var.subnet_id}"
user_data_file = "./bootstrap_windows.txt"
vpc_id = "${var.vpc_id}"
winrm_insecure = true
winrm_port = 5986
winrm_use_ssl = true
winrm_timeout = "60m"
winrm_username = "Administrator"
}

build {
sources = ["source.amazon-ebs.windows_server"]

provisioner "powershell" {
script = "./SetNetwork.ps1"

]

}

}`

### Operating system:

The EC2 is Windows Server 2019

### Packerlog output:
2021/12/13 09:02:59 Using host value: **EC2InstancePrivateIP**
2021/12/13 09:02:59 packer-plugin-amazon_v1.0.1_x5.0_linux_amd64 plugin: 2021/12/13 09:02:59 [INFO] Attempting WinRM connection...
2021/12/13 09:02:59 packer-plugin-amazon_v1.0.1_x5.0_linux_amd64 plugin: 2021/12/13 09:02:59 [DEBUG] connecting to remote shell using WinRM
2021/12/13 09:03:29 packer-plugin-amazon_v1.0.1_x5.0_linux_amd64 plugin: 2021/12/13 09:03:29 [ERROR] connection error: unknown error Post "**EC2InstancePrivateIP**:5986/wsman": dial tcp **EC2InstancePrivateIP**:5986: i/o timeout
2021/12/13 09:03:29 packer-plugin-amazon_v1.0.1_x5.0_linux_amd64 plugin: 2021/12/13 09:03:29 [ERROR] WinRM connection err: unknown error Post "**EC2InstancePrivateIP**:5986/wsman": dial tcp **EC2InstancePrivateIP**:5986: i/o timeout

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.