在AWS配置模板的云形成中将补救措施作为参数传递

时间:2019-06-04 23:37:43

标签: amazon-cloudformation amazon-systems-manager

我目前正在使用cloudformation模板来自动化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"
  }
]
},

1 个答案:

答案 0 :(得分:0)

对于可直接在Cloudfront上使用的配置,没有像“ RemediationConfigurations”之类的可用属性。因此,您最好调用lambda函数,并使用putremediationconfigurations函数通过脚本将其传递。