Create EC2 instance

In this section, you will use the AWS Console to create 2 Windows EC2 virtual machines and access them remotely.

  1. Navigate to EC2 console, select Instances and click Launch instance.

CreateEC2Instance

  1. Enter instance name, such as: idevelop.
  • Enter 2 for number of instances.
  • Select Windows type for AMI.
  • Select Microsoft Windows Server 2022 Base AMI

CreateEC2Instance

  1. Select KPforDevAxInstances for Keypair.
  • Leave the default configuration for the Network settings section.

CreateEC2Instance

  1. In Advanced details:
  • On IAM Role section, select awscodestar-travelbuddy-xxx

CreateEC2Instance

  1. Scroll to User data section, paste in the following content:
<powershell>
Set-ExecutionPolicy RemoteSigned -Force
Import-Module AWSPowerShell
$REGION = (ConvertFrom-Json (Invoke-WebRequest -Uri http://169.254.169.254/latest/dynamic/instance-identity/document -UseBasicParsing).Content).region
New-Item -Path c:\temp -ItemType "directory" -Force
powershell.exe -Command Read-S3Object -BucketName aws-codedeploy-$REGION -Key latest/codedeploy-agent-updater.msi -File c:\temp\codedeploy-agent-updater.msi
// Start-Sleep -Seconds 30 *optional
c:\temp\codedeploy-agent-updater.msi /quiet /l c:\temp\host-agent-updater-log.txt
</powershell>

Here is a Powershell script to automatically download and install CodeDeploy Agent for Windows.

  • Click Launch instance.

CreateEC2Instance

  1. Instances have been created.

CreateEC2Instance

You don’t have to wait for instances to complete initialization - continue to the next sections.