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.
// 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");
}
}
keepers
(Map of String) Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.length
(Number) The length (in words) of the pet name. Defaults to 2prefix
(String) A string to prefix the name with.separator
(String) The character to separate words in the pet name. Defaults to "-"id
(String) The random pet name.