Note:
- setup-ec2-windows.ps1doesn't have SSH's setup script because of some bug. You need to set it up manually after deployment
- 
Create file opts.ymlwith options:- MyIP: ip for access to server
- KeyName: aws key pair for ec2
 
- 
Run serverless deploy
- 
Log of setup-ec2-windows.ps1script can view inC:\ProgramData\Amazon\EC2-Windows\Launch\Log\UserdataExecution.log
- Connect to ec2 via RDC
- Run these commands
# Instal ssh
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Set-Service -Name ssh-agent -StartupType 'Automatic'
Set-Service -Name sshd -StartupType 'Automatic'
# check install
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Start-Service sshd
Start-Service ssh-agent
# check firewall
Get-NetFirewallRule -Name *ssh*- 
For connect server without password: - Generate new key in your device
 ssh-keygen -t rsa-sha2-512 -f $env:USERPROFILE\.ssh\ec2-windows-key - Add your public key (ec2-windows-key.pub) to C:\Users\Administrator\.ssh\authorized_keys
- Comment out the following lines in C:\ProgramData\ssh\sshd_configfile. Then restart the sshd serviceRestart-Service sshd
 #Match Group administrators # AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu -OutFile Ubuntu.zip -UseBasicParsing
Expand-Archive .\Ubuntu.zip c:\ubuntu
c:\ubuntu\ubuntu.exe- Remove service pm2-service-uninstall
- Recheck it wmic service where 'name like "%pm2serv.exe%"' get /value
- Remove root pm2 folder Remove-Item D:\pm2
- Reinstall it pm2-service-install -n pm2-serv
- Create and attach role have 2 polices: CloudWatchAgentServerPolicy,AmazonSSMManagedInstanceCoreto ec2
- Install cloudwatch agent curl https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi -OutFile amazon-cloudwatch-agent.msi
- Install msi file msiexec /i amazon-cloudwatch-agent.msi
- Move to cloudwatch folder cd 'C:\Program Files\Amazon\AmazonCloudWatchAgent\'
- Start agent ./amazon-cloudwatch-agent-ctl -a start
curl https://dl.eff.org/certbot-beta-installer-win32.exe  -OutFile certbot-beta-installer-win32.exe
Start-Process -Wait -FilePath "certbot-beta-installer-win32.exe" -ArgumentList '/S','/v','/qn' -passthru
cd 'C:\Program Files (x86)\Certbot\bin'
.\certbot certonly --webroot
cp C:\Certbot\live\yourwebsite.com\fullchain.pem D:\nginx\nginx-1.18.0\
cp C:\Certbot\live\yourwebsite.com\privkey.pem D:\nginx\nginx-1.18.0\
# test re-new SSL
.\certbot renew --dry-run