在 .ebextension 中解析 .config YAML 文件时出现 AWS 错误

AWS error while parsing .config YAML file in .ebextension

部署到 Elasticbeanstalk 时,我的部署失败并出现解析错误,原因是我在 .ebextension 文件夹中有一个 .config 文件,但对我来说似乎没问题。任何人都可以告诉我如何解决它? .config 文件如下所示:

files:
   "/opt/elasticbeanstalk/hooks/appdeploy/post/01_copy_htaccess_after_deployment.sh":
     mode: "000755",
     owner: root,
     group: root,
     content: |
       yes | /bin/cp /var/app/current/.htaccess.new /var/app/current/.htaccess

错误:

The configuration file .ebextensions/08_htaccess_create_script_post_deploy.config in application version git-bce52a5381c7ac6735249419c48b1fe116168610-1494415808045 contains invalid YAML or JSON. YAML exception: Invalid Yaml: while parsing a block mapping in "", line 3, column 10: mode: "000755", ^ expected , but found FlowEntry in "", line 3, column 24: mode: "000755", ^ , JSON exception: Invalid JSON: Unexpected character (f) at position 0.. Update the configuration file.

根据 aws 文档,您不需要在模式所有者和组后面使用逗号。所以你的 yml 配置文件应该是这样的:

files:
   "/opt/elasticbeanstalk/hooks/appdeploy/post/01_copy_htaccess_after_deployment.sh":
     mode: "000755"
     owner: root
     group: root
     content: |
       yes | /bin/cp /var/app/current/.htaccess.new /var/app/current/.htaccess

这里是一个语法示例

files:  
  "target file location on disk": 
     mode: "six-digit octal value"
     owner: name of owning user for file
     group: name of owning group for file
     source: URL
     authentication: authentication name:

  "target file location on disk": 
     mode: "six-digit octal value"
     owner: name of owning user for file
     group: name of owning group for file
     content: |
    this is my content
     encoding: encoding format
     authentication: authentication name: