random.string

Query Syntax

<desired-length>

Generate a random string of the given length.

New in version 2.2.0.

Arguments

digits: bool = True

When generating the random string, the string may contain digits ([0-9]). If the string can contain digits, it will always contain at least one.

lowercase: bool = True

When generating the random string, the string may contain lowercase letters ([a-z]). If the string can contain lowercase letters, it will always contain at least one.

punctuation: bool = False

When generating the random string, the string may contain ASCII punctuation ([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]). If the string can contain ASCII punctuation, it will always contain at least one.

uppercase: bool = True

When generating the random string, the string may contain uppercase letters ([A-Z]). If the string can contain uppercase letters, it will always contain at least one.

This Lookup supports all Common Lookup Arguments but, the following have limited or no effect:

  • default

  • get

  • indent

  • load

  • region

Example

This example shows the use of this lookup to create an SSM parameter that will retain value generated during the first deployment. Even through subsequent deployments generate a new value that is passed to the hook, the hook does not overwrite the value of an existing parameter.

pre_deploy: &hooks
  - path: runway.cfngin.hooks.ssm.parameter.SecureString
    args:
      name: /${namespace}/password
      overwrite: false
      value: ${random.string 12::punctuation=true}

post_destroy: *hooks