【发布时间】:2021-05-02 10:10:27
【问题描述】:
我正在关注this question 中的答案,我尝试启用 X 射线并且它有效,我使用的代码:
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命令的格式无效,我在网上找不到任何示例,有人可以帮忙吗?
【问题讨论】:
-
将 terraform 和更多的输出视为文本会很有帮助。
-
嗨@thekbb 我更新了我的问题,我设法让“启用 X 射线”工作,但在“启用日志记录”部分有问题,好像它在抱怨 json 格式?
标签: terraform git-bash terraform-provider-aws aws-step-functions aws-xray