Terraform代码不支持JSON格式。

huangapple go评论51阅读模式
英文:

Terraform code with the json format are not supported

问题

`在用 Terraform 创建事件桥接时,当 ENI 修改时通过 SNS 主题获取警报,此时 Json 格式未在 Terraform 运行时验证。

event_pattern = <<EOF { "source":"aws.config", "detail-type":"Config Configuration Item Change", "detail": { "messageType":"ConfigurationItemChangeNotification", "configurationItem": { "resourceType":"AWS::EC2::NetworkInterface", "resourceId":"eni-030512620140c240d","eni-0626261dd4743a0fc" } } } EOF

最终阶段出现错误,我需要代码来进行 Terraform 验证。

英文:

`In the Terraform for creating the Event bridge with getting alert through SNS topic when the ENI getting modification for this the Json format have not validated at the terraform running time

event_pattern = <<EOF
{
"source":"aws.config",
"detail-type":"Config Configuration Item Change",
"detail":
{
"messageType":"ConfigurationItemChangeNotification",
"configurationItem":
{
"resourceType":"AWS::EC2::NetworkInterface",
"resourceId":"eni-030512620140c240d","eni-0626261dd4743a0fc"
}
}
}
EOF

At the final stage it through the error as

I need the code to get Terraform validation `

答案1

得分: 1

Your JSON is not valid.

{
    "source": "aws.config",
    "detail-type": "Config Configuration Item Change",
    "detail": {
        "messageType": "ConfigurationItemChangeNotification",
        "configurationItem": {
            "resourceType": "AWS::EC2::NetworkInterface",
            "resourceId": "eni-030512620140c240d",
            "eni-0626261dd4743a0fc" <---- This is incorrect
        }
    }
}

I believe this is what you want:

{
    "source": "aws.config",
    "detail-type": "Config Configuration Item Change",
    "detail": {
        "messageType": "ConfigurationItemChangeNotification",
        "configurationItem": {
            "resourceType": "AWS::EC2::NetworkInterface",
            "resourceId": ["eni-030512620140c240d", "eni-0626261dd4743a0fc"]
        }
    }
}
英文:

Your JSON is not valid.

{
    &quot;source&quot;: &quot;aws.config&quot;,
    &quot;detail-type&quot;: &quot;Config Configuration Item Change&quot;,
    &quot;detail&quot;: {
        &quot;messageType&quot;: &quot;ConfigurationItemChangeNotification&quot;,
        &quot;configurationItem&quot;: {
            &quot;resourceType&quot;: &quot;AWS::EC2::NetworkInterface&quot;,
            &quot;resourceId&quot;: &quot;eni-030512620140c240d&quot;,
            &quot;eni-0626261dd4743a0fc&quot; &lt;---- This is incorrect
        }
    }
}

I believe this is what you want:

{
    &quot;source&quot;: &quot;aws.config&quot;,
    &quot;detail-type&quot;: &quot;Config Configuration Item Change&quot;,
    &quot;detail&quot;: {
        &quot;messageType&quot;: &quot;ConfigurationItemChangeNotification&quot;,
        &quot;configurationItem&quot;: {
            &quot;resourceType&quot;: &quot;AWS::EC2::NetworkInterface&quot;,
            &quot;resourceId&quot;: [ &quot;eni-030512620140c240d&quot;, &quot;eni-0626261dd4743a0fc&quot; ]
        }
    }
}

huangapple
  • 本文由 发表于 2023年4月1日 00:35:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75900843.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定