58 lines
1.3 KiB
Terraform
58 lines
1.3 KiB
Terraform
|
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
|