提供商“aws”{access_key =“AKIAJ7STPAZVP4ZT74HQ”secret_key =“YRxdYqpOLDRCnPcKMBTL0dCSTFGILdd0brw2LlWq”区域 =“us-east-1”}资源“aws_instance”“示例”{ami =“ami-0063927a”instance_type =“t2.micro”vpc_security_group_ids = [“${aws_security_group.instance.id}”]标签 = {名称 =“main-example”}用户数据 =<<-EOF #!/bin/bash yum -y java-1.8.0-openjdk-devel yum -y 安装 tomcat systemctl 启用 tomcat systemctl 启动 tomcat echo”
欢迎使用 tomcat,Hello World
“ //etc/systemd/system/{{to muser}}.service EOF} 资源“aws_security_group” “实例” { 名称 = “main-example-instance” 入口 { from_port = 8080 to_port = 8080 协议 = “tcp” cidr_blocks = [“0.0.0.0/0”] } 出口 { from_port = 0 to_port = 0 协议 = “-1” cidr_blocks =[“0.0.0.0/0”]
} }