You can also use the context to create super light...
# general
b
You can also use the context to create super lightweight components, with no OO code required. For example:
Copy code
function myCluster(ctx, name) {
    ctx = ctx.withComponent("myorg:cluster", name)
             .withProps({tags: { Cluster: name } });

    // all resources created using this context now share a component, and all have the "Cluster" tag set
    // note that if we passed in a context with the "Environment" tag it'll still have that, merged in nicely.
    let primary = ctx.r(aws.ec2.Instance, "primary", {
        instanceType: "t2.micro",
        ami: "ami-xxxxxxxx"
    });

    let replicas = [];
    for(var i=0; i <= 3; i++) {
        replicas[i] = ctx.r(aws.ec2.Instance, `replica-${i}`,{
            instanceType: "t2.micro",
            ami: "ami-xxxxxxxx"
        });
    }

    return {primary, replicas};
}

var cluster = myCluster(ctx, "testCluster");
💥 2