Compare commits

..

No commits in common. 'e96b52b85fa9743519d76d9b8814af33d4269a4f' and 'af7dab9c4010f3c0e83c682c905865d3aeeb5016' have entirely different histories.

  1. 6
      ec2ml/config.tf
  2. 40
      ec2ml/ec2.tf
  3. 43
      ec2ml/network.tf
  4. 9
      ec2ml/outputs.tf
  5. 7
      ec2ml/variables.tf
  6. 1
      ec2ml/variables/prod.tfvars
  7. 1
      ec2ml/variables/sample.tfvars
  8. 1
      ec2ml/variables/test.tfvars
  9. 0
      simple-ec2/compose-app/docker-compose.yaml
  10. 0
      simple-ec2/main.tf
  11. 0
      simple-ec2/scripts/01-install-docker.sh

6
ec2ml/config.tf

@ -1,6 +0,0 @@
provider "aws" {
profile = "superuser"
region = "ap-southeast-2"
}

40
ec2ml/ec2.tf

@ -1,40 +0,0 @@
resource "tls_private_key" "mlkey" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "aws_key_pair" "mlkey" {
key_name = "mlboxkey"
public_key = tls_private_key.mlkey.public_key_openssh
provisioner "local-exec" {
command = "echo '${tls_private_key.mlkey.private_key_pem}' > ./${var.output_ssh_key} & chmod 400 ${var.output_ssh_key}"
}
}
data "aws_ami" "aws_linux_ami" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["debian-12-amd64-*"]
}
}
resource "aws_instance" "ml-box" {
ami = data.aws_ami.aws_linux_ami.id
instance_type = var.instance_type
key_name = aws_key_pair.mlkey.key_name
vpc_security_group_ids = [ aws_security_group.allow_tls.id ]
tags = {
Name = "terragenerated-simple-ec2"
}
}
# resource "ansible_host" "ml-box" {
# name = aws_instance.ml-box.public-ip
# groups = [ ]
# }

43
ec2ml/network.tf

@ -1,43 +0,0 @@
resource "aws_security_group" "allow_tls" {
name = "allow_tls"
description = "Allow TLS inbound traffic plys ssh"
ingress {
description = "TLS from VPC"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
ingress {
description = "TLS from VPC"
from_port = 8000
to_port = 8999
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "allow_tls"
}
}

9
ec2ml/outputs.tf

@ -1,9 +0,0 @@
output "ml-instance-url" {
value = aws_instance.ml-box.public_dns
}
output "key" {
value = tls_private_key.mlkey.public_key_openssh
sensitive = true
}

7
ec2ml/variables.tf

@ -1,7 +0,0 @@
variable "instance_type" {
default = "t2.micro"
}
variable "output_ssh_key" {
default = "my_ssh.pem"
}

1
ec2ml/variables/prod.tfvars

@ -1 +0,0 @@
instance_type = "g3.4xlarge"

1
ec2ml/variables/sample.tfvars

@ -1 +0,0 @@
instance_type =

1
ec2ml/variables/test.tfvars

@ -1 +0,0 @@
instance_type = "t2.micro"

0
simple-ec2-web-server/compose-app/docker-compose.yaml → simple-ec2/compose-app/docker-compose.yaml

0
simple-ec2-web-server/main.tf → simple-ec2/main.tf

0
simple-ec2-web-server/scripts/01-install-docker.sh → simple-ec2/scripts/01-install-docker.sh

Loading…
Cancel
Save