redis参数组的cloudformation

bprjcwpo  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(390)

我想创建一个cloudformation模板来部署redis参数组。问题在于,我的每个参数都是这样的:

{
    "Parameters": [
        {
            "ParameterName": "activedefrag",
            "ParameterValue": "no",
            "Description": "Enabled active memory defragmentation",
            "Source": "user",
            "DataType": "string",
            "AllowedValues": "yes,no",
            "IsModifiable": true,
            "MinimumEngineVersion": "4.0.9",
            "ChangeType": "immediate"
        },
        {
            "ParameterName": "active-defrag-cycle-max",
            "ParameterValue": "75",
            "Description": "Maximal effort for defrag in CPU percentage",
            "Source": "user",
            "DataType": "integer",
            "AllowedValues": "1-75",
            "IsModifiable": true,
            "MinimumEngineVersion": "4.0.9",
            "ChangeType": "immediate"
        }
}

现在我理解了模板的基本格式,但无法像上面所看到的那样理解如何传入参数。
失败的模板:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Template to create a consul cluster",
  "Parameters": {
    "CacheParameterGroupFamily": {
      "Description": "The name of the cache parameter group family that this cache parameter group is compatible with.",
      "Type": "String",
      "Default": "redis4.0",
      "AllowedValues": ["memcached1.4", "memcached1.5", "redis2.6", "redis2.8", "redis3.2", "redis4.0", "redis5.0"]
    },
    "ParameterGroupDescription": {
      "Description": "What this parameter group will be used for",
      "Type": "String"
    }
  },
  "Resources": {
    "RedisParameterGroup": {
      "Type": "AWS::ElastiCache::ParameterGroup",
      "Properties": {
        "CacheParameterGroupFamily" : { "Ref": "CacheParameterGroupFamily" },
        "Description" : { "Ref": "ParameterGroupDescription" },
        "Properties" : {
            "Parameters": [{
                "ParameterName": "activedefrag",
                "ParameterValue": "no",
                "Description": "Enabled active memory defragmentation",
                "Source": "user",
                "DataType": "string",
                "AllowedValues": "yes,no",
                "IsModifiable": true,
                "MinimumEngineVersion": "4.0.9",
                "ChangeType": "immediate"
            }]
        }
      }
    }
  }
}
xn1cxnb4

xn1cxnb41#

欢迎来到stackoverflow!
您需要将这些参数合并到 Parameters ,并更改语法,使其符合参数格式。

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Template to create a consul cluster",
  "Parameters": {
    "CacheParameterGroupFamily": {
      "Description": "The name of the cache parameter group family that this cache parameter group is compatible with.",
      "Type": "String",
      "Default": "redis4.0",
      "AllowedValues": ["memcached1.4", "memcached1.5", "redis2.6", "redis2.8", "redis3.2", "redis4.0", "redis5.0"]
    },
    "ParameterGroupDescription": {
      "Description": "What this parameter group will be used for",
      "Type": "String"
    },
    "activedefrag": {
        "Description": "Enabled active memory defragmentation",
        "Type": "String",
        "AllowedValues": ["yes", "no"],
        "Default": "no"
    },
    "activedefragcyclemax": {
        "Description": "Maximal effort for defrag in CPU percentage",
        "Type": "Number",
        "Default": 75,
        "MinValue": 1,
        "MaxValue": 75
    }
  },
  "Resources": {
    "RedisParameterGroup": {
      "Type": "AWS::ElastiCache::ParameterGroup",
      "Properties": {
        "CacheParameterGroupFamily" : { "Ref": "CacheParameterGroupFamily" },
        "Description" : { "Ref": "ParameterGroupDescription" },
        "Properties" : {
            "activedefrag": {"Ref": "activedefrag"},
            "active-defrag-cycle-max": {"Ref": "activedefragcyclemax"}
        }
      }
    }
  }
}

相关问题