Virtual ResourceΒΆ

The @virtual directive defines a virtual resource. A virtual resource groups resource definitions together into a single virtual resource much like a function in a full programming language.

A virtual resource can define arguments that must be passed in using the @param directive.


@virtual myproject::network
    @param name

    aws::vpc vpc
        cidr-block: ''

        tags: {
            Name: "$name project"

To use this virtual resource define a resource using the name you gave the virtual resource:

myproject::network dev-network
    name: "development"

To reference resources created by the virtual resource prepend the resource name you provided when using the virtual resource followed by the name of the resource inside the virtual resource definition:

aws::subnet mysubnet
    vpc: $(aws::vpc dev-network/vpc)