cat < main.tf provider "aws" { region = "ap-northeast-2" } resource "aws_instance" "example" { ami = "ami-0e9bfdb247cc8de84" instance_type = "t2.micro" vpc_security_group_ids = [aws_security_group.instance.id] user_data = <<-EOF #!/bin/bash apt-get update -y apt install apache2 -y sudo sed -i "s/^Listen 80/Listen 50000/g" /etc/apache2/ports.conf sudo systemctl restart apache2.service echo '

Master seo 50000 port Web Server!

' > /var/www/html/index.html EOF tags = { Name = "Single-MyWebSrv8" } } resource "aws_security_group" "instance" { name = var.security_group_name ingress { from_port = var.server_port to_port = var.server_port protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } egress { protocol = "-1" from_port = 0 to_port = 0 cidr_blocks = ["0.0.0.0/0"] } } variable "security_group_name" { description = "The name of the security group" type = string default = "terraform-my-instance8" } output "public_ip" { value = aws_instance.example.public_ip description = "The public IP of the Instance" } EOT