dockerhttpamazon-ec2amazon-vpcsubnet

AWS Ec2- need to create VPC and Subnets before Ec2 instance?


I am trying to create a basic ec2 instance on which I will run a docker container that runs a spring boot web app.

When I go to create the instance I see the below screen.

Do I need to create a VPC and subnets first before I can create an Ec2 instance? And is this a new feature of AWS?

I want my instance and docker container to be accessible via http and https on the public internet as spring boot exposes a rest api.

enter image description here


Solution

  • If you don't already have one, you can create your own VPC or use the default one then create a public subnet (with auto-assigned public addresses) in this VPC.

    I would recommend to directly create your own VPC.

    Since you want your instance being reachable on http and https you want to create a security group that allows connections on ports 80 & 443 and allows connection on port 22 from your personal IP address only.

    The port 22 will allow you to connect via SSH in the instance to set up your docker container.

    Hope it helped!