From c5041cb83dc41be0d5d34a46237705587eabc504 Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Sun, 22 Jan 2023 11:17:06 +0100 Subject: [PATCH] Baseline terraforms --- .create.tf | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ beanstalk.tf | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 .create.tf create mode 100644 beanstalk.tf diff --git a/.create.tf b/.create.tf new file mode 100644 index 0000000..a160eed --- /dev/null +++ b/.create.tf @@ -0,0 +1,58 @@ +provider "aws" { + region = "us-east-1" +} + +resource "aws_key_pair" "banda" { + key_name = "banda" + public_key = file("~/.ssh/banda.pub") +} + +resource "aws_security_group" "banda" { + name = "banda" + description = "Banda security group" + + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + ingress { + from_port = 8080 + to_port = 8080 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } +} + +resource "aws_instance" "banda" { + ami = "ami-0ff8a91507f77f867" + instance_type = "t2.micro" + key_name = aws_key_pair.banda.key_name + security_groups = [aws_security_group.banda.name] + + connection { + type = "ssh" + host = aws_instance.banda.public_ip + user = "ec2-user" + private_key = file("~/.ssh/banda") + } + + provisioner "remote-exec" { + inline = [ + "sudo yum install -y amazon-linux-extras", + "sudo amazon-linux-extras enable", + "sudo amazon-linux-extras install -y docker", + "sudo service docker start", + "sudo usermod -a -G docker ec2-user" + ] + } +} diff --git a/beanstalk.tf b/beanstalk.tf new file mode 100644 index 0000000..f69792c --- /dev/null +++ b/beanstalk.tf @@ -0,0 +1,60 @@ +resource "aws_elastic_beanstalk_application" "banda" { + name = "banda" +} + +resource "aws_iam_role" "banda" { + name = "banda-role" + assume_role_policy = <