Amazon web services 如何在aws elastic beanstalk环境实例启动上运行shell脚本

Amazon web services 如何在aws elastic beanstalk环境实例启动上运行shell脚本,amazon-web-services,terraform,user-data,launch-configuration,Amazon Web Services,Terraform,User Data,Launch Configuration,我正在使用Terraform脚本创建aws elastic beanstalk环境,我需要在实例启动时启动一个shell脚本 我已经尝试了以下方法 resource "aws_elastic_beanstalk_environment" "Environment" { name = "${var.ebs_env_name}" application = "${var.ebs_app_name}" --- --- --- setting = {

我正在使用Terraform脚本创建aws elastic beanstalk环境,我需要在实例启动时启动一个shell脚本

我已经尝试了以下方法

resource "aws_elastic_beanstalk_environment" "Environment" {
    name = "${var.ebs_env_name}"
    application = "${var.ebs_app_name}"
    ---
    ---
    ---
    setting = {
      namespace = "aws:autoscaling:launchconfiguration"
      name = "user_data"
      value = "${file("user-data.sh")}"
   }
}
这是投掷错误

应用计划时出错:

发生1个错误:

aws_elastic_beanstalk_environment.environment:ConfigurationValidationException:配置验证异常:无效的选项规范(命名空间:“aws:autoscaling:launchconfiguration”,选项名称:“user_data”):未知的配置设置。 状态代码:400,请求id:xxxxx-xxxxxx


请提供帮助

我找不到有关AWS Elastic Beanstalk服务的任何信息,该服务提供了修改实例上用户数据的方法。但是,您可以调整所使用的AMI,这样您就可以使用类似于构建自定义AMI的工具,其中包含
用户\u数据

谢谢你的回答,我找到了解决办法

我已经创建了一个文件夹.ebextensions,并在文件夹中创建了一个名为99delayed_job.config的文件(您可以给出任何名称)

命令:
创建发布目录:
命令:“mkdir/opt/elasticbeanstalk/hooks/appdeploy/pre”
忽略错误:正确
文件夹:
/opt/elasticbeanstalk/hooks/appdeploy/pre/99_restart_delayed_job.sh:
组:根
模式:“000755”
所有者:root
内容:|-
#!/usr/bin/env bash
A,并用“dockrun.aws.json”压缩我发送到s3并用于部署的这个压缩文件


工作正常:)

如果希望在不阻止部署的情况下运行长期任务,该怎么办。在我的情况下,在尝试之后,您建议eb部署人员在此步骤中堆叠,并且从不将节点状态更改为绿色
commands: 
  create_post_dir: 
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/pre"
    ignoreErrors: true
files: 
  /opt/elasticbeanstalk/hooks/appdeploy/pre/99_restart_delayed_job.sh: 
    group: root
    mode: "000755"
    owner: root
    content: |-
        #!/usr/bin/env bash
        <My shell script here>