使用 CDK 创建 AWS SSM AnsibelePlaybook Provide

Create AWS SSM AnsibelePlaybook Provide using CDK

我正在尝试使用 CDK 和 AWS SSM 创建 AnsibelePlaybook Provide。协会需要设置:

有没有人有(或指导我)“模板”,所以我可以很容易地用我的价值观转换它达到上述要求。

我是 AWS 的新手。 :) 谢谢

我明白了。这就是我要找的:

ssm_association = ssm.CfnAssociation(
            self, "SSMAssociation",
            name="AWS-ApplyAnsiblePlaybooks",
            output_location=None,
            parameters={
                "SourceType": [
                    "S3"
                ],
                "SourceInfo": [
                    "{\"path\":\"https://PATH_TO_S3_BUCKET"}"
                ],
                "InstallDependencies": [
                    "True"
                ],
                "PlaybookFile": [
                    "main.yml"
                ],
            # where PARAM1 and PARAM2 are declerd before like:
            #  PARAM1 = cdk.CfnParameter( self,
            #  PARAM2 = cdk.CfnParameter( self,
                "ExtraVariables": [
                    f"PARAM_1={ PARAM1.value_as_string } PARAM_2={PARAM2.value_as_string}"
                ],
                "Check": [
                    "False"
                ],
                "Verbose": [
                    "-v"
                ]
            },
             # where instance and targer_two id  aredeclerd before like:
             # instance = aws_ec2.Instance(se,...
             # target_two = ssm.CfnAssociation.TargetProperty(key="InstanceIds", values=[instance.instance_id])
            targets=[target_two]
        )

    ssm_association.node.add_dependency(instance)