The null_resource
resource implements the standard resource lifecycle but takes no further action. On Terraform 1.4 and later, use the terraform_data resource type instead.
The triggers
argument allows specifying an arbitrary set of values that, when changed, will cause the resource to be replaced.
# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from cdktf import SSHProvisionerConnection, FileProvisioner
from constructs import Construct
from cdktf import Token, TerraformCount, Fn, TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.null.resource import Resource
from imports.aws.instance import Instance
class MyConvertedCode(TerraformStack):
def __init__(self, scope, name):
super().__init__(scope, name)
# In most cases loops should be handled in the programming language context and
# not inside of the Terraform context. If you are looping over something external, e.g. a variable or a file input
# you should consider using a for loop. If you are looping over something only known to Terraform, e.g. a result of a data source
# you need to keep this like it is.
cluster_count = TerraformCount.of(Token.as_number("3"))
cluster = Instance(self, "cluster",
ami="ami-0dcc1e21636832c5d",
instance_type="m5.large",
count=cluster_count
)
null_provider_resource_cluster = Resource(self, "cluster_1",
connection=SSHProvisionerConnection(
host=Fn.element(Fn.lookup_nested(cluster, ["*", "public_ip"]), 0)
),
triggers=[{
"cluster_instance_ids": Fn.join(",",
Token.as_list(Fn.lookup_nested(cluster, ["*", "id"])))
}
],
provisioners=[FileProvisioner(
type="remote-exec",
inline=["bootstrap-cluster.sh " +
Token.as_string(
Fn.join(" ",
Token.as_list(Fn.lookup_nested(cluster, ["*", "private_ip"]))))
]
)
]
)
# This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.
null_provider_resource_cluster.override_logical_id("cluster")
triggers
(Map of String) A map of arbitrary strings that, when changed, will force the null resource to be replaced, re-running any associated provisioners.id
(String) This is set to a random value at create time.