示例#1
0
    def test_create_resource_type_label(self):
        from troposphere_mate import s3, apigateway
        tpl = Template()
        s3_bucket = s3.Bucket(
            "Bucket",
            template=tpl,
            BucketName="my-bucket",
        )
        rest_api = apigateway.RestApi("RestApi",
                                      template=tpl,
                                      DependsOn=[
                                          s3_bucket,
                                      ])
        tpl.create_resource_type_label()
        tpl.create_resource_type_label()  # see if second call raise exception

        assert len(tpl.to_dict()["Resources"]["Bucket"]["Metadata"]
                   [DEFAULT_LABELS_FIELD]) == 1
        assert len(tpl.to_dict()["Resources"]["RestApi"]["Metadata"]
                   [DEFAULT_LABELS_FIELD]) == 1
示例#2
0
    NetworkConfiguration=ecs.NetworkConfiguration(
        AwsvpcConfiguration=ecs.AwsvpcConfiguration(
            AssignPublicIp="ENABLED",
            SecurityGroups=[
                Ref(sg_for_ecs),
            ],
            Subnets=[
                config.PUBLIC_SUBNET_ID_AZ1.get_value(),
                config.PUBLIC_SUBNET_ID_AZ2.get_value(),
            ])),
    SchedulingStrategy="REPLICA",
    HealthCheckGracePeriodSeconds=30,
    DependsOn=[
        sg_for_ecs,
        ecs_task_definition,
        elb_lb,
        elb_default_target_group,
    ],
)

template.create_resource_type_label()

# give all aws resource common tags
common_tags = {
    "ProjectName": Ref(param_project_name),
    "ProjectNameSlug": Ref(param_project_name_slug),
    "Stage": Ref(param_stage),
    "EnvironmentName": Ref(param_env_name),
}
template.update_tags(common_tags)