代码之家  ›  专栏  ›  技术社区  ›  Friedrich 'Fred' Clausen

AWS CDK:设置elasticache参数组的名称(Python风格)

  •  1
  • Friedrich 'Fred' Clausen  · 技术社区  · 1 年前

    我正在尝试为设置一个名称 elasticache.CfnParameterGroup 以符合某些IAM权限边界(名称必须以前缀开头,例如。 my-project 。现在我正在尝试使用“description”参数进行以下操作:

    import aws_cdk.aws_elasticache as elasticache
    # ...
    parameter_group = elasticache.CfnParameterGroup(
        main,
        "RedisParameterGroup",
        description="my-project-param-group",
        cache_parameter_group_family="redis6.x",
    )
    

    这不起作用,因为它没有将参数组名称设置为正确的前缀。

    所以,我找不到构造函数的任何“命名”参数。我试着添加一个标签,比如 tags=[{"key": "Name", "value": "my-project-param-group"}], 但这仍然没有给参数组一个名称。的帮助文本 CfnParameterGroup 说:

    def __init__(self,
                 scope: Construct,
                 id: str,
                 *,
                 cache_parameter_group_family: str,
                 description: str,
                 properties: IResolvable | Mapping[str, str] | None = None,
                 tags: Sequence[CfnTag | dict[str, Any]] | None = None) -> None
    

    它不显示任何命名参数。大多数其他构造似乎都有某种命名参数,例如实际的 CfnCacheCluster cluster_name -参数组的等价项是什么?

    1 回复  |  直到 1 年前
        1
  •  0
  •   erik258    1 年前

    我不认为你能做到这一点,因为它目前似乎在云形成中被省略了。

    从开始 the SDK's documentation ,上面写着,

    使用自动生成的L1构造,方法与使用相同 the CloudFormation AWS::ElastiCache resources 直接地

    所以我们看看 AWS::ElastiCache::ParameterGroup 在那里它没有提到 CacheParameterGroupName .

    最后,我们可以在文档中验证底层API调用 CreateCacheParameterGroup 哪里 CacheParameterGroupName 是必需的参数。因此,cloudformation的ParameterGroup实现似乎不支持用户定义的名称。

    对不起,我想你是SOL。值得庆幸的是,参数组是非常直接的,所以您可能需要考虑让管理员从外部创建它们。