random_integer (Resource)

The resource random_integer generates random values from a given range, described by the min and max attributes of a given resource.

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 { AlbListenerRule } from "./.gen/providers/aws/alb-listener-rule";
import { Integer } from "./.gen/providers/random/integer";
interface MyConfig {
  condition: any;
}
class MyConvertedCode extends TerraformStack {
  constructor(scope: Construct, name: string, config: MyConfig) {
    super(scope, name);
    const priority = new Integer(this, "priority", {
      keepers: {
        listener_arn: listenerArn.stringValue,
      },
      max: 50000,
      min: 1,
    });
    new AlbListenerRule(this, "main", {
      action: [
        {
          targetGroupArn: targetGroupArn.stringValue,
          type: "forward",
        },
      ],
      listenerArn: Token.asString(
        Fn.lookupNested(priority, ["keepers", "listener_arn"])
      ),
      priority: priority.result,
      condition: config.condition,
    });
  }
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

# Random integers can be imported using the result, min, and max, with an
# optional seed. This can be used to replace a config value with a value
# interpolated from the random provider without experiencing diffs.

# Example (values are separated by a ,):
terraform import random_integer.priority 15390,1,50000