The null_data_source
data source implements the standard data source lifecycle but does not
interact with any external APIs.
Historically, the null_data_source
was typically used to construct intermediate values to re-use elsewhere in configuration. The
same can now be achieved using locals or the terraform_data resource type in Terraform 1.4 and later.
# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from constructs import Construct
from cdktf import Token, TerraformCount, Fn, TerraformOutput, TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.aws.elb import Elb
from imports.aws.instance import Instance
from imports.null.data_null_data_source import DataNullDataSource
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.
blue_count = TerraformCount.of(Token.as_number("3"))
blue = Instance(self, "blue",
ami="ami-0dcc1e21636832c5d",
instance_type="m5.large",
count=blue_count
)
# 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.
green_count = TerraformCount.of(Token.as_number("3"))
green = Instance(self, "green",
ami="ami-0dcc1e21636832c5d",
instance_type="m5.large",
count=green_count
)
values = DataNullDataSource(self, "values",
inputs={
"all_server_ids": Token.as_string(
Fn.concat([
Fn.lookup_nested(green, ["*", "id"]),
Fn.lookup_nested(blue, ["*", "id"])
])),
"all_server_ips": Token.as_string(
Fn.concat([
Fn.lookup_nested(green, ["*", "private_ip"]),
Fn.lookup_nested(blue, ["*", "private_ip"])
]))
}
)
TerraformOutput(self, "all_server_ids",
value=Fn.lookup_nested(values.outputs, ["\"all_server_ids\""])
)
TerraformOutput(self, "all_server_ips",
value=Fn.lookup_nested(values.outputs, ["\"all_server_ips\""])
)
Elb(self, "main",
instances=Token.as_list(
Fn.lookup_nested(values.outputs, ["\"all_server_ids\""])),
listener=[ElbListener(
instance_port=8000,
instance_protocol="http",
lb_port=80,
lb_protocol="http"
)
]
)
has_computed_default
(String) If set, its literal value will be stored and returned. If not, its value defaults to "default"
. This argument exists primarily for testing and has little practical use.inputs
(Map of String) A map of arbitrary strings that is copied into the outputs
attribute, and accessible directly for interpolation.id
(String, Deprecated) This attribute is only present for some legacy compatibility issues and should not be used. It will be removed in a future version.outputs
(Map of String) After the data source is "read", a copy of the inputs
map.random
(String) A random value. This is primarily for testing and has little practical use; prefer the hashicorp/random provider for more practical random number use-cases.