diff --git a/Ec2_instance/main.tf b/Ec2_instance/main.tf new file mode 100644 index 0000000..fdabd83 --- /dev/null +++ b/Ec2_instance/main.tf @@ -0,0 +1,8 @@ +resource "aws_instance" "app_server" { + ami = var.ami_id + instance_type = var.instance + + tags = { + Name = var.tag + } +} \ No newline at end of file diff --git a/Ec2_instance/outputs.tf b/Ec2_instance/outputs.tf new file mode 100644 index 0000000..b942a3a --- /dev/null +++ b/Ec2_instance/outputs.tf @@ -0,0 +1,9 @@ +output "instance_id" { + description = "ID of the EC2 instance" + value = aws_instance.app_server.id +} + +output "instance_public_ip" { + description = "Public IP address of the EC2 instance" + value = aws_instance.app_server.public_ip +} \ No newline at end of file diff --git a/Ec2_instance/provider.tf b/Ec2_instance/provider.tf new file mode 100644 index 0000000..d3a444b --- /dev/null +++ b/Ec2_instance/provider.tf @@ -0,0 +1,15 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.27" + } + } + + required_version = ">= 0.14.9" +} + +provider "aws" { + profile = "default" + region = var.region +} diff --git a/Ec2_instance/variables.tf b/Ec2_instance/variables.tf new file mode 100644 index 0000000..572be2b --- /dev/null +++ b/Ec2_instance/variables.tf @@ -0,0 +1,19 @@ +variable "ami_id" { + type = string + default = "ami-09d3b3274b6c5d4aa" +} + +variable "instance" { + type = string + default = "t2.micro" +} + +variable "tag" { + type = string + default = "Bmoore_Instance" +} + +variable "region" { + type = string + default = "us-east-1" +} \ No newline at end of file