commit 77c2f1c4d8f25e69c79b2e35fc531afccdd82947 Author: Ryan Malloy Date: Mon Nov 11 21:18:50 2024 +0000 Add main.tf diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..5687c9a --- /dev/null +++ b/main.tf @@ -0,0 +1,57 @@ +data "aws_ami" "mac" { + most_recent = true + owners = ["amazon"] + filter { + name = "name" + values = [ + "amzn-ec2-macos-10.15.7-*-*" + ] + } + filter { + name = "owner-alias" + values = [ + "amazon", + ] + } +} +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "2.64.0" + name = "mac-instance-vpc" + azs = var.availability_zones + cidr = var.vpc_cidr + public_subnets = var.public_subnets_cidrs + enable_dns_hostnames = true + enable_dns_support = true +} +resource "aws_security_group" "ssh" { + name_prefix = "mac-ssh-sg-" + vpc_id = module.vpc.vpc_id + ingress { + from_port = 22 + to_port = 22 + 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"] + } + lifecycle { + create_before_destroy = true + } +} + +resource "aws_instance" "mac_instance_b" { + ami = data.aws_ami.mac.image_id + instance_type = "mac1.metal" + key_name = var.ssh_key_name + availability_zone = "eu-west-1b" + host_id = "h-002de77f93125e3c2" + subnet_id = module.vpc.public_subnets[1] + vpc_security_group_ids = [aws_security_group.ssh.id] +} + +# ssh -i private_key.pem ec2-user@52.53.52.53