简体   繁体   English

使用运行命令执行 SSM 文档失败 json:无法将数组解组为 Go 结构字段 RunScriptPluginInput.RunCommand 类型为 string\"

[英]SSM document execution using run command failed json: cannot unmarshal array into Go struct field RunScriptPluginInput.RunCommand of type string\"

I'm creating aws ssm document in json code for one of the application installation and configuration.我正在 json 代码中为应用程序安装和配置之一创建 aws ssm 文档。 SSM document execution using run command failed json: cannot unmarshal array into Go struct field RunScriptPluginInput.RunCommand of type string". Please note, i have added only some portion of the bash scripts, this is a lengthy script. The issue seems like something with the json code syntax. Great if anyone help on this? SSM document execution using run command failed json: cannot unmarshal array into Go struct field RunScriptPluginInput.RunCommand of type string". Please note, i have added only some portion of the bash scripts, this is a lengthy script. The issue seems like something with json 代码语法。如果有人能帮上忙吗?

{
  "schemaVersion": "2.2",
   "description": "SSM Document to install and configure xyz application",
     "parameters": {
  "TimeoutSeconds": {
  "type": "String",
  "description": "(Optional) The time in seconds for a command to be completed before it is considered to have failed.",
   "default": "3600"
  }
  },
  "mainSteps": [
    {
    "action": "aws:runShellScript",`
    "name": "runShellScript",     
        "timeoutSeconds": "{{ TimeoutSeconds }}",
        "runCommand": [
          "#/bin/bash",
           "aws configure set aws_access_key_id ${sts[0]} --profile $PROFILE",
          "aws configure set aws_secret_access_key ${sts[1]} --profile $PROFILE",
          "aws configure set aws_session_token ${sts[2]} --profile $PROFILE",
          "echo \"credentials stored in the profile named $PROFILE\"",
          "wget -c https://downloads.apache.org/tomcat/tomcat-9/v9.0.34/bin/apache-tomcat-9.0.34.tar.gz",
          "tar xf apache-tomcat-9.0.34.tar.gz -C /opt/tomcat",

This code is messy and impossible to deploy.这段代码很乱,无法部署。 Could you please underline the error message, and provide complex information about how you execute this document?您能否在错误消息下划线,并提供有关您如何执行此文档的复杂信息?

  1. content is unreadable, please reformate it... and please, close the sections - then anybody will be able to easily test your code.内容不可读,请重新格式化...并请关闭这些部分-然后任何人都可以轻松测试您的代码。
  2. at the end of "action": "aws:runShellScript", you have additional, unexpected sign,"action": "aws:runShellScript",你有额外的,意想不到的标志,
  3. you forgot about inputs property - https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-plugins.html#aws-runShellScript您忘记了inputs属性 - https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-plugins.html#aws-runShellScript
  4. there should be #!/bin/bash instead #/bin/bash应该有#!/bin/bash而不是#/bin/bash

Anyway, finally, I did the above changes and it is working - I mean it's executable (on ec2 instance) - shell commands with aws cli don't work, as well as curl, which returns 404...无论如何,最后,我做了上述更改并且它正在工作 - 我的意思是它是可执行的(在 ec2 实例上) - 带有aws cli 的 shell 命令不起作用,以及返回 404 的 curl ......

I strongly recommend using yml standard, due to more readability and more build-in features.我强烈建议使用yml标准,因为它具有更高的可读性和更多的内置功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 json:无法将数字解组为 Go 结构字段。字符串类型的数量 - json: cannot unmarshal number into Go struct field .Amount of type string Docker:b'json:无法将数字解组为Go结构字段LogConfig.Config,类型为string' - Docker: b'json: cannot unmarshal number into Go struct field LogConfig.Config of type string' 松露测试:ProviderError: json: cannot unmarshal number into Go struct field params.fromBlock of type string - Truffle test: ProviderError: json: cannot unmarshal number into Go struct field params.fromBlock of type string json:无法将字符串解组为 main.CaseReport 类型的 Go struct field.result.case_report - json: cannot unmarshal string into Go struct field .result.case_report of type main.CaseReport 无法将 JSON 字符串解组为 Go 中的结构 - Cannot Unmarshal JSON String to struct in Go 无法将字符串解组到Go结构字段中 - cannot unmarshal string into Go struct field 无法将字符串解组到类型模型的Go struct字段Article.article_type中。 - cannot unmarshal string into Go struct field Article.article_type of type models.ArticleType 将json数组解组到go struct中(数组位于JSON字符串的中间 - unmarshal json array into go struct (array is in the middle of the JSON string 使用Web GUI的Bluemix部署错误:失败来自服务器的无效JSON响应:JSON:无法将数字解组为字符串类型的Go值 - Bluemix deployment error using web gui: FAILED Invalid JSON response from server: json: cannot unmarshal number into Go value of type string json:无法将字符串解组为main.test_struct类型的Go值 - json: cannot unmarshal string into Go value of type main.test_struct
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM