Creating an custom module for ec2 instance with a amazon linux 2 ami ID

Terraform and EC2
Providers section from the ec2.tf file in the root directory cut and pasted into providers.tf
This resource was cut and pasted from the original ec2.tf file in the root directory. The EC2 resource here is given an ami-id, instance type and server name. Also, be sure to have the ami in the same AZ as the one your working in or it will not operate.
module “my-ec2” created above
  • Terraform init.
  • Terraform fmt
  • Terraform Validate.
  • Terraform Plan.
  • Terraform apply.
As shown above the server was started successfully.
Be sure the ami is from the same AZ your currently working from.
child variable for ec2 instance
.gitignore file above
code successfully pushed to github and gist have been created as well
Code pushed to github and you can see the Directory folder my-ec2

--

--

DevOps engineer in search of Cloud Engineer role. Looking for Cloud Operations or Cloud Infrastructure opportunities.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eric Wainwright

DevOps engineer in search of Cloud Engineer role. Looking for Cloud Operations or Cloud Infrastructure opportunities.