github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/urlencode.html.md (about)

     1  ---
     2  layout: "functions"
     3  page_title: "urlencode - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-encoding-urlencode"
     5  description: |-
     6    The urlencode function applies URL encoding to a given string.
     7  ---
     8  
     9  # `urlencode` Function
    10  
    11  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    12  earlier, see
    13  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    14  
    15  `urlencode` applies URL encoding to a given string.
    16  
    17  This function identifies characters in the given string that would have a
    18  special meaning when included as a query string argument in a URL and
    19  escapes them using
    20  [RFC 3986 "percent encoding"](https://tools.ietf.org/html/rfc3986#section-2.1).
    21  
    22  The exact set of characters escaped may change over time, but the result
    23  is guaranteed to be interpolatable into a query string argument without
    24  inadvertently introducing additional delimiters.
    25  
    26  If the given string contains non-ASCII characters, these are first encoded as
    27  UTF-8 and then percent encoding is applied separately to each UTF-8 byte.
    28  
    29  ## Examples
    30  
    31  ```
    32  > urlencode("Hello World")
    33  Hello%20World
    34  > urlencode("☃")
    35  %E2%98%83
    36  > "http://example.com/search?q=${urlencode("terraform urlencode")}"
    37  http://example.com/search?q=terraform%20urlencode
    38  ```