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
import { Construct } from "constructs";
import { Fn, Token, TerraformStack } from "cdktf";
/*
 * Provider bindings are generated by running `cdktf get`.
 * See https://cdk.tf/provider-generation for more details.
 */
import { Instance } from "./.gen/providers/aws/instance";
import { Pet } from "./.gen/providers/random/pet";
class MyConvertedCode extends TerraformStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);
    const server = new Pet(this, "server", {
      keepers: {
        ami_id: amiId.stringValue,
      },
    });
    const awsInstanceServer = new Instance(this, "server_1", {
      ami: Token.asString(Fn.lookupNested(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.*/
    awsInstanceServer.overrideLogicalId("server");
  }
}

Schema

Optional

Read-Only