• yayiyaya
    2024-03-27 来自浙江
    思考题: provider "aws" { region = "us-east-1" } resource "aws_instance" "example" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t2.micro" tags = { Name = "example-instance" } provisioner "remote-exec" { inline = [ "sudo yum install -y httpd", "sudo systemctl start httpd", "sudo systemctl enable httpd" ] } connection { type = "ssh" user = "ec2-user" private_key = file("~/.ssh/your_private_key.pem") host = self.public_ip } } resource "aws_security_group" "http_sg" { name = "http_sg" description = "Allow HTTP inbound traffic" ingress { from_port = 80 to_port = 80 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"] } }
    展开
    
    