Пример #1
0
def mkbucket(bucket):
    name = bucket['Name']
    region_name = s3.get_bucket_location(Bucket=name)[
        "LocationConstraint"]
    return newTarget("s3_bucket",
                     region_name,
                     [name])
Пример #2
0
def mkstack(region, stack_summary):
    return newTarget("cloudformation_stack",
                     region,
                     [stack_summary['StackName']],
                     {
                         "StackStatus": stack_summary['StackStatus'],
                         "ExtraStr": stack_summary['StackStatus'],
                     })
Пример #3
0
def chase(bucket):
    bucketNames = bucket.get("resource_names", [])
    if len(bucketNames) > 0:
        bucketName = bucketNames[0]
        region = bucket["region"]
        objects = list_objects(bucketName, region)
        empty_bucket = newTarget("s3_empty_bucket", bucket["region_name"],
                                 [bucketName])
        targets = objects + [empty_bucket]
        return targets
    else:
        return []
Пример #4
0
def chase(bucket):
    bucketNames = bucket.get("resource_names", [])
    if len(bucketNames) > 0:
        bucketName = bucketNames[0]
        region = bucket["region"]
        objects = list_objects(bucketName, region)
        empty_bucket = newTarget("s3_empty_bucket",
                                 bucket["region_name"],
                                 [bucketName])
        targets = objects + [empty_bucket]
        return targets
    else:
        return []
Пример #5
0
def list_objects(bucketName, region):
    kwargs = {'Bucket': bucketName}
    # TODO: Support large (>1000) buckets
    list_object_versions = s3.list_object_versions(**kwargs)
    versions = list_object_versions.get("Versions", [])
    objects = list(map(mkversion, versions))
    result = []
    if objects:
        result = [
            newTarget("s3_objects", region, objects,
                      {"bucket-name": bucketName})
        ]
    return result
Пример #6
0
def list_objects(bucketName, region):
    kwargs = {'Bucket': bucketName}
    # TODO: Support large (>1000) buckets
    list_object_versions = s3.list_object_versions(**kwargs)
    versions = list_object_versions.get("Versions", [])
    objects = list(map(mkversion, versions))
    result = []
    if objects:
        result = [newTarget("s3_objects",
                            region,
                            objects,
                            {
                                "bucket-name": bucketName
                            })]
    return result
Пример #7
0
def mkbucket(bucket):
    name = bucket['Name']
    region_name = s3.get_bucket_location(Bucket=name)["LocationConstraint"]
    return newTarget("s3_bucket", region_name, [name])
Пример #8
0
def chase(target):
    return [newTarget("ec2_instances", region=target["region"])]
Пример #9
0
def mkstack(region, stack_summary):
    return newTarget(
        "cloudformation_stack", region, [stack_summary['StackName']], {
            "StackStatus": stack_summary['StackStatus'],
            "ExtraStr": stack_summary['StackStatus'],
        })