Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 启动配置中提供的用户数据不起作用_Amazon Web Services_Terraform - Fatal编程技术网

Amazon web services 启动配置中提供的用户数据不起作用

Amazon web services 启动配置中提供的用户数据不起作用,amazon-web-services,terraform,Amazon Web Services,Terraform,我是Terraform的新手,正在使用一些用户数据创建启动配置&使用自动缩放组启动启动配置,但定义为“用户数据不工作” 我的代码: resource“aws\u启动\u配置”“mylc”{ name=“lc-1”#启动配置的名称 image_id=“ami-0e306788ff2473ccb”#image id 实例类型_type=“t2.micro”#实例类型 security_groups=[“${aws_security_group.webserver sg.id}”]#附加创建的安全组

我是Terraform的新手,正在使用一些用户数据创建启动配置&使用自动缩放组启动启动配置,但定义为“用户数据不工作” 我的代码:

resource“aws\u启动\u配置”“mylc”{
name=“lc-1”#启动配置的名称
image_id=“ami-0e306788ff2473ccb”#image id
实例类型_type=“t2.micro”#实例类型
security_groups=[“${aws_security_group.webserver sg.id}”]#附加创建的安全组
key_name=“terraform”#附加ssh密钥

user_data=用户数据作为根用户运行。不应在用户数据脚本中使用
sudo

您还可以检查用户数据日志以查看任何错误消息:
/var/log/cloud init output.log

有关“不工作”的一些详细信息会有所帮助。实例是否已启动,但脚本未执行,或者是什么?
resource "aws_launch_configuration" "mylc" {
  name          = "lc-1" # Name of Launch config
  image_id      = "ami-0e306788ff2473ccb"  #Image-id
  instance_type = "t2.micro" #type of Instance
  security_groups = ["${aws_security_group.webserver-sg.id}"]  #Attaching created Security groups
  key_name     = "terraform" # Attaching ssh key
  user_data= <<-EOF # creating user Data
  #!/bin/bash
  sudo su -
  yum update -y
  yum install httpd - y
  service httpd start
  yum install java -y
  EOF
}