awslabs / aws-cyclone-solution

Apache License 2.0
22 stars 2 forks source link

pulumi dynamic providers for cyclone #13

Closed jamie1911 closed 2 years ago

jamie1911 commented 2 years ago

Description of changes:

This dynamic provider hits the config API and places the creation/updating/and deletion under Pulumi control.

example usage: __main__.py

"""A Python Pulumi program"""

import rtx_pulumi_helpers.providers.cyclone as cyclone

us_east_1 = cyclone.region.CycloneRegion(
    "NAME-us-east-1",
    cyclone.region.CycloneRegionArgs(
        name="us-east-1",
        main_region=True,
        peer_with_main_region=False,
        import_vpc=True,
        vpc_id="vpc-xxxxxxx",
        deploy_vpc_endpoints="OFF",
    ),
)

us_east_2 = cyclone.region.CycloneRegion(
    "NAME-us-east-2",
    cyclone.region.CycloneRegionArgs(
        name="us-east-2",
        main_region=False,
        peer_with_main_region=False,
        import_vpc=True,
        vpc_id="vpc-xxxxxxx",
        deploy_vpc_endpoints="OFF",
    ),
)

c_cluster = cyclone.cluster.CycloneCluster(
    "NAME-cluster",
    cyclone.cluster.CycloneClusterArgs(
        name="NAME-cluster",
        main_region_image_name="amazon-linux-2-20220328194725",
        instance_list=["r6i.large", "r6i.xlarge", "r6i.2xlarge"],
    ),
)

c_definition = cyclone.definition.CycloneDefinition(
    "NAME-definition",
    cyclone.definition.CycloneDefinitionArgs(
        name="NAME-definition",
        image_uri="00000000000.dkr.ecr.us-east-1.amazonaws.com/images/NAME",
        vcpus=1,
        memory_limit_mib=8000,
        iam_policies=["NAME-cyclone-s3-fullaccess"],
    ),
)

c_queue = cyclone.queue.CycloneQueue(
    "NAME-queue",
    cyclone.queue.CycloneQueueArgs(
        name="NAME",
        computeEnvironment=c_cluster.name,
        optimise_lowest_spot_cost_region=True,
        region_distribution_weights={"us-east-1": "auto", "us-east-2": "auto"},
    ),
)