Below the screenshot, it seems to be successful only in one Availability Zone.
I checked the codedeploy logs for a failed instance, and I found that there was an error, I think it is recognized as an on-premise instance.
2018-01-10 04:40:22 INFO [codedeploy-agent(2696)]: On Premises config file does not exist or not readable
2018-01-10 04:40:43 ERROR [codedeploy-agent(2696)]: CodeDeploy Instance Agent Service: CodeDeploy Instance Agent Service: error during start or run: InstanceMetadata::InstanceMetadataError - Not an EC2 instance and region not provided in the environment variable AWS_REGION. Please specify your region using environment variable AWS_REGION.......
I've searched for about three days for this issue, but there was no mention in the AWS documentation. In the production env, I plan to use two Availability Zones attached to the auto scaling group. I wonder if I'm overlooking the other thing except CodeDeploy... What should I check? Thank you in advance.
[Updated] I update with ASG and ASG Config screent shot. There's no special, it's vanila and default process. I waiting 5 days from AWS support center but still pending response.
Finally, I found out why codedeploy failed across multiple availability zones on Windows 2016. Also, this problem seems to be an issue with Windows 2016 EC2 itself rather than ASG or codedeploy(I have not tested it on linux). There are 2 solutions I found,
The first method is an intuitive and convenient way(GUI), and the second method is appropriate for automate a powershell script. I have confirmed that both methods succeed in deploying to multiple AZs. There were no errors in the logs recorded by codedeployagent.
To be more specific, codedeployagent leaves various logs at the time of deployment, and I found that the agent seems to use meta-info from 169.254.169.254. When I failed, the log say "You are On-Premise Instance.". Probably the deployment fails because the instance can not get meta-info. In the following document, I have received a lot of help and all of my solutions are listed.
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch.html
Especially, in the document
.....In Windows PowerShell, run the following command so that the system schedules the script to run as a Windows Scheduled Task. The script runs one time during the next boot and then disables these tasks from running again....
C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule