I'm stuck with creating ssm.CfnAssociation due to I'm novice in AWS CDK and CloudFormation also. I'm trying to create AWS Systems Manager State Manager task (AWS-RunAnsiblePlaybook) by ssm.CfnAssociation, but I have misunderstanding how can I define parameters? I want to set in parameters url to s3 for playbook. As from CDK docs it should be:
parameters (Union[IResolvable, None, Mapping[str, Union[IResolvable, Forwardref]]]) – AWS::SSM::Association.Parameters.
By AWS docks Type: Map of ParameterValues
-> {
"ParameterValues" : [ String, ... ]
}
I've tried to define various types for parameters, but I always have error: 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"
If I'm using ssm.CfnAssociation.ParameterValuesProperty
for matching to key playbookurl
, I have and error on the deploying step: SSMAssociation/SSMAssociation (SSMAssociation6148DA19) Value of {Parameters} must be a map where each value is a list of {String}
Could you please help me with it, because have no idea what type and how should be proper for parameters? Thank you.
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,
)