Added hcl files for terraform ec2 launched on aws. w/ ec2+security group
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
provider "aws" {
|
||||||
|
region = "ap-south-1"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_instance" "terra-ec2" {
|
||||||
|
ami = "ami-0861f4e788f5069dd"
|
||||||
|
instance_type = "t2.micro"
|
||||||
|
key_name = "kshitij-personal-ed25519"
|
||||||
|
subnet_id = "subnet-0f2515644bbe8e603"
|
||||||
|
associate_public_ip_address = true
|
||||||
|
vpc_security_group_ids = [aws_security_group.allow_ssh_terra-ec2.id]
|
||||||
|
|
||||||
|
tags = {
|
||||||
|
name = "terra-ec2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "allow_ssh_terra-ec2" {
|
||||||
|
name = "allow_ssh_terra-ec2"
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
from_port = 22
|
||||||
|
to_port = 22
|
||||||
|
protocol = "tcp"
|
||||||
|
cidr_blocks = ["${var.internal_ip}", "${var.personal_ip}"]
|
||||||
|
}
|
||||||
|
egress {
|
||||||
|
from_port = 0
|
||||||
|
to_port = 0
|
||||||
|
protocol = -1
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
variable "internal_ip" {
|
||||||
|
description = "Internal IP allowing SSH access to terra-ec2"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "personal_ip" {
|
||||||
|
description = "Personal IP allowing SSH access to terra-ec2"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user