I'm revisiting the post I did and creating the same EC2 instance using Terraform instead of going through the AWS Console.
I used the reference from Terraform's Registry to create my HCL script: aws-instance documentation
Here is my main.tf file that I created.
terraform { required_providers { aws = { source = "hashicorp/aws" version = ">= 4.49.0" } } required_version = ">= 1.2.0" } provider "aws" { region = "us-east-1" } resource "aws_instance" "spring_boot_webserver" { ami = "ami-0b5eea76982371e91" instance_type = "t2.micro" tags = { Name = "iac-java-webapp" } key_name = "java-demo-keypair" associate_public_ip_address = true subnet_id = "subnet-01b088baff86159af" vpc_security_group_ids = [ "sg-0a5cddc1e38f7b9b5" ] }
It was pretty cool to go into my AWS Console (after waiting about 30 seconds) and seeing the EC2 Instance that was created by running my Terraform script:
No comments:
Post a Comment