我坚持创建 ssm.CfnAssociation 因为我也是 AWS CDK 和 CloudFormation 的新手。我正在尝试通过 ssm.CfnAssociation 创建 AWS Systems Manager 状态管理器任务 (AWS-RunAnsiblePlaybook),但我误解了如何定义参数?我想将参数 url 设置为 s3 的剧本。从 CDK 文档开始,它应该是:
parameters (Union[IResolvable, None, Mapping[str, Union[IResolvable, Forwardref]]]) – AWS::SSM::Association.Parameters.
通过 AWS 码头Type: Map of ParameterValues
->{
"ParameterValues" : [ String, ... ]
}
我试图为参数定义各种类型,但我总是有错误:Value did not match any type in union: Expected object reference, got {"plybook":"s3-url"},Value did not match any type in union: Expected object reference, got "s3-url",Expected object reference, got "s3-url"
如果我使用ssm.CfnAssociation.ParameterValuesProperty
for 匹配到 key playbookurl
,我在部署步骤中有错误:SSMAssociation/SSMAssociation (SSMAssociation6148DA19) Value of {Parameters} must be a map where each value is a list of {String}
你能帮我解决一下吗,因为不知道什么类型以及如何适合参数?谢谢你。
class SSMAssociation(core.Construct):
def __init__(self, scope: core.Construct, id: str,
ssm_association_name: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
ssm_param_values = ssm.CfnAssociation.ParameterValuesProperty(
parameter_values=["s3://test-ansible-test1-pl1/playbook1.yml"],
)
ssm_tartgets = ssm.CfnAssociation.TargetProperty(
key="CDK-Type",
values="EC2Instance",
),
ssm_association = ssm.CfnAssociation(
self, "SSMAssociation",
name=ssm_association_name,
output_location=None,
parameters={
"playbookurl": ssm_param_values,
},
targets=None,
)