Creating a Windows 2019 AMI using Packer, being driven with codebuild

I am down to the end of creating my custom Windows Server 2019, and I am trying to finish with a Sysprep. I can get it to work logged into the server via RDP or sessions manager, but I can’t get it to work when it runs through Packer. The documentation on this is shit, both from the AWS side, no clear directions on how to Sysprep and keep it working in AWS, and nothing that works or makes much sense from the packer side.
{
“type”: “powershell”,
“inline”: [
“C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule”,
"C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\SendWindowsIsReady.ps1 -Schedule”
]
}
When I use this, it just hangs and fails.
I tried installing the latest version of EC2Lanunch and putting these setting in the Launchconfig, and this seemed to make it all work better logged into the server, but it still hangs when I run this in Win_config.ps1 in packer>

$EC2LaunchZip = ‘https://s3.amazonaws.com/amazon-ec2launch-v2/windows/amd64/latest/AmazonEC2Launch.msi
$OutPath = ‘C:\ProgramData\Amazon\EC2-Windows\Launch\AmazonEC2Launch.msi’
$LPath = ‘C:\ProgramData\Amazon\EC2-Windows\Launch’
Push-Location -Path $LPath
Invoke-WebRequest -Uri $EC2LaunchZip -OutFile $OutPath
msiexec /i AmazonEC2Launch.msi /qn /log Ec2Launch.log
Start-Sleep -Seconds 10
Get-Content .\Ec2Launch.log | Select -Last 5

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch-v2-settings.html#ec2launch-v2-cli

Push-Location -Path ‘C:\Program Files\Amazon\EC2Launch’
$env:Path = $env:Path + ‘;C:\Program Files\Amazon\EC2Launch’
#EC2Launch.exe

$LaunchConfig = @’
{
“SetComputerName”: false,
“SetMonitorAlwaysOn”: true,
“SetWallpaper”: true,
“AddDnsSuffixList”: true,
“ExtendBootVolumeSize”: true,
“HandleUserData”: true,
“AdminPasswordType”: “Specify”,
“AdminPassword”: “56%^koDD9e3z0ekk”
}
'@
$LCJson = $LaunchConfig | ConvertTo-Json | ConvertFrom-Json
$LConPath = ‘C:\ProgramData\Amazon\EC2-Windows\Launch\Config\LaunchConfig.json’
Set-Content -Value $LCJson -Path $LConPath -Encoding UTF8 -NoNewline

Hi, I was using default options for ec2launch so it’s a bit different but this was only way I have succeeded to run sysprep with it so maybe it helps someone. I didn’t have luck with scripts from program data or adding path to $env:PATH
{
“type”: “powershell”,
“inline”: [
“New-Item -ItemType SymbolicLink -Path “c:\windows\system32\ec2launch.exe” -Target “C:\Program Files\Amazon\EC2Launch\EC2Launch.exe””
]
},
{
“type”: “windows-shell”,
“inline”: [
“ec2launch.exe sysprep”
]
}