在 AWS 配置模板的云形成中将修复操作作为参数传递



我目前正在研究使用云形成模板自动创建 aws 配置规则。我需要在脚本中添加修复操作,以自动执行不合规的资源。我不知道将修复操作添加为云形成模板的参数。有人可以帮助我解决这个问题吗?下面是我的代码。但是我无法创建堆栈

{
"Resources": {
"AWSConfigRule": {
  "Type": "AWS::Config::ConfigRule",
  "Properties": {
    "ConfigRuleName": {
      "Ref": "ConfigRuleName"
    },
    "Description": "Checks whether Amazon Virtual Private Cloud flow logs 
are found and enabled for Amazon VPC.",
    "InputParameters": {
      "trafficType": {
        "Fn::If": [
          "trafficType",
          {
            "Ref": "trafficType"
          },
          {
            "Ref": "AWS::NoValue"
          }
        ]
      }
    },
    "Scope": {},
    "Source": {
      "Owner": "AWS",
      "SourceIdentifier": "VPC_FLOW_LOGS_ENABLED"
    },
    "MaximumExecutionFrequency": {
      "Ref": "MaximumExecutionFrequency"
    },
    "RemediationConfigurations": {
        "Ref": "RemediationConfigurations"
    },        
  }
}
  },
 "Parameters": {
"ConfigRuleName": {
  "Type": "String",
  "Default": "vpc-flow-logs-enabled",
  "Description": "The name that you assign to the AWS Config rule.",
  "MinLength": "1",
  "ConstraintDescription": "This parameter is required."
},
"MaximumExecutionFrequency": {
  "Type": "String",
  "Default": "TwentyFour_Hours",
  "Description": "The frequency that you want AWS Config to run evaluations for the rule.",
  "MinLength": "1",
  "ConstraintDescription": "This parameter is required.",
  "AllowedValues": [
    "One_Hour",
    "Three_Hours",
    "Six_Hours",
    "Twelve_Hours",
    "TwentyFour_Hours"
  ]
},
"trafficType": {
  "Type": "String",
  "Default": "",
  "Description": "TrafficType of flow logs"
},
"RemediationConfigurations": [ 
  { 
     "TargetId": "AWS-PublishSNSNotification",
     "TargetType": "SSM_DOCUMENT"
  }
]
},
没有

像"修复配置"这样的属性可用于配置规则,您可以直接在 cloudfront 使用它。因此,您最好调用 lambda 函数并使用函数 putremediationconfigurations 通过脚本传递它。

最新更新