How To Create An AWS EC2 Instance Using PowerShell

How To Create An AWS EC2 Instance Using PowerShell

How To Create An AWS EC2 Instance Using PowerShell

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In this blog post, we will discuss how to create an AWS EC2 instance using PowerShell. We will create a new EC2 instance from scratch including VPC, Subnets, Security Groups, etc.

Prerequisites:

  • One Windows system with PowerShell version 5.0 or higher.
  • AWSPowerShell module installed and configured with proper access.

You can follow the below blog post to install and configure PowerShell for AWS.

https://cloudaffaire.com/how-to-install-and-configure-powershell-for-aws/

How To Create An AWS EC2 Instance Using PowerShell:

Step 1: Create a new VPC.

Step 2: Create a new public subnet on your VPC.

Step 3: Create a new security group with port 22 for SSH connection.

Step 4: Get the AMI ID for your new EC2 instance. In this demo, I am using Amazon provided Amazon Linux 2 AMI for our EC2 instance. I have also given the code to fetch the latest AMI ID for some popular OS.

Step 5: Create a new key pair and save the key pair to your local system.

Step 6: Create a new EC2 instance using PowerShell.

Step 7: Add a tag to all the resources created in this demo (Optional).

Step 8: Try to connect to your EC2 instance.

Step 9: Cleanup.

Hope you have enjoyed this blog post. Please refer below AWS documentation for more details

https://docs.aws.amazon.com/powershell/latest/userguide/pstools-ec2-launch.html

https://docs.aws.amazon.com/powershell/latest/reference/

 

 

Leave a Reply

Close Menu