random_pet (Resource)

The resource random_pet generates random pet names that are intended to be used as unique identifiers for other resources.

This resource can be used in conjunction with resources that have the create_before_destroy lifecycle flag set, to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently.

Example Usage

# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
from constructs import Construct
from cdktf import Fn, Token, TerraformStack
#
# Provider bindings are generated by running `cdktf get`.
# See https://cdk.tf/provider-generation for more details.
#
from imports.aws.instance import Instance
from imports.random.pet import Pet
class MyConvertedCode(TerraformStack):
    def __init__(self, scope, name):
        super().__init__(scope, name)
        server = Pet(self, "server",
            keepers={
                "ami_id": ami_id.string_value
            }
        )
        aws_instance_server = Instance(self, "server_1",
            ami=Token.as_string(Fn.lookup_nested(server, ["keepers", "ami_id"])),
            tags={
                "Name": "web-server-${" + server.id + "}"
            }
        )
        # This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.
        aws_instance_server.override_logical_id("server")

Schema

Optional

Read-Only