ข้อผิดพลาดในการแยกวิเคราะห์ Json เมื่อเรียกใช้ 'aws stepfunctions update-state-machine' ผ่าน Terraform

ฉันกำลังติดตามคำตอบใน สิ่งนี้ คำถาม ฉันพยายามเปิดใช้งานการเอ็กซเรย์แล้วได้ผล รหัสที่ฉันใช้:

resource "null_resource" "enable_step_function_logging" {
  triggers = {
state_machine_arn = aws_sfn_state_machine.sfn_state_machine.arn
  }
provisioner "local-exec" {
  command = "aws stepfunctions update-state-machine --state-machine-arn ${self.triggers.state_machine_arn} --tracing-configuration enabled=true"
  }
}

ตอนนี้ฉันต้องการเปิดใช้งานส่วนการบันทึก cloudwatch ' --logging-configuration=xxx' แต่ฉันยังคงได้รับข้อผิดพลาด นี่คือสิ่งที่ฉันได้ลอง:

resource "null_resource" "enable_step_function_logging" {
  triggers = {
    state_machine_arn = aws_sfn_state_machine.sfn_state_machine.arn
    logs_params       = <<PARAMS
      {
        "level":"ALL",
        "includeExecutionData":true,
        "destinations":[
            {
                "cloudWatchLogsLogGroup":{
                    "logGroupArn":"${aws_cloudwatch_log_group.sfn_cloudwatch_log_group.arn}:*"
                    }
                }
            ]
            }
    PARAMS
  }
  provisioner "local-exec" {
    command     = "aws stepfunctions update-state-machine --state-machine-arn ${self.triggers.state_machine_arn}  --tracing-configuration enabled=true --logging-configuration='${self.triggers.logs_params}'"
  }
}

จากนั้นเมื่อฉันสมัครใน Terraform มันทำให้ฉันมีข้อผิดพลาด:

Error: Error running command 'aws stepfunctions update-state-machine --state-machine-arn arn:aws:states:us-east-1:xxxxxxxxx:stateMachine:xxxxxxxxstate-machine  --tracing-configuration enabled=true --logging-configuration='      {
        "level":"ALL",
        "includeExecutionData":true,
        "destinations":[
            {
                "cloudWatchLogsLogGroup":{
                    "logGroupArn":"arn:aws:logs:us-east-1:xxx:log-group:/aws/vendedlogs/states/xxxxxxx-Logs:*"
                    }
                }
            ]
            }
'': exit status 252. Output:
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: {

มันบ่นว่าคำสั่ง aws มีรูปแบบที่ไม่ถูกต้อง ฉันไม่พบตัวอย่างออนไลน์ ใครสามารถช่วยได้บ้าง


comment
การดูทั้งพื้นผิวและเอาต์พุตเป็นข้อความเพิ่มเติมเล็กน้อยจะเป็นประโยชน์   -  person thekbb    schedule 28.01.2021
comment
สวัสดี @thekbb ฉันอัปเดตคำถามของฉันแล้ว ฉันจัดการเพื่อให้ 'เปิดใช้งาน x-ray' ได้ แต่มีปัญหาในส่วน 'เปิดใช้งานการบันทึก' ดูเหมือนว่าจะบ่นเกี่ยวกับรูปแบบ json หรือไม่   -  person Cecilia    schedule 28.01.2021


คำตอบ (1)


ไม่เคยใช้ terraform กับ windows ฉันก็ไม่ค่อยชัดเจน แต่ฉันสงสัยว่า local-exec กำลังใช้ cmd มากกว่า bash เพื่อเรียกใช้ aws-cli อาจมีความแตกต่างในวิธีการหลบหนีและตีความสิ่งต่าง ๆ ? ลองบอก Terraform ให้ใช้ bash:

  provisioner "local-exec" {
    command     = "aws stepfunctions update-state-machine --state-machine-arn ${self.triggers.state_machine_arn}  --tracing-configuration enabled=true --logging-configuration='${self.triggers.logs_params}'"
    interpreter = ["bash", "-c"]
  }
person thekbb    schedule 28.01.2021
comment
คุณได้ทดสอบในตอนท้ายของคุณแล้วหรือยัง? มันทำให้ฉันมีข้อผิดพลาด 'ไม่คาดหวังอาร์กิวเมนต์ชื่อล่ามที่นี่' - person Cecilia; 28.01.2021
comment
คุณรู้หรือไม่ว่าฉันต้องส่งรูปแบบ json ใดไปยัง '--logging-configuration' ฉันเชื่อว่าเป็นปัญหาของ json - person Cecilia; 28.01.2021
comment
แปลก.. ฉันมีการเว้นวรรคแปลกๆ เป็นตัวอย่าง คุณใช้ Terraform เวอร์ชันใดอยู่? ล่ามถูกต้องในเอกสาร: terraform.io/docs/ ภาษา/ทรัพยากร/ผู้จัดเตรียม/ - person thekbb; 28.01.2021
comment
ฉันใช้ Terraform v0.13.4 - person Cecilia; 28.01.2021
comment
ฉันไม่สามารถใช้ bash ได้ มันจะทำให้ฉันมีข้อผิดพลาดบางอย่าง เช่น ไม่พบ bash กำลังใช้ CMD - person Cecilia; 01.02.2021