yandex_smartcaptcha_captcha (Resource)
Статья создана
Обновлена 7 августа 2025 г.
- Example Usage
- Schema
- Optional
- Read-Only
- Nested Schema for override_variant
- Nested Schema for security_rule
- Nested Schema for security_rule.condition
- Nested Schema for security_rule.condition.headers
- Nested Schema for security_rule.condition.headers.value
- Nested Schema for security_rule.condition.host
- Nested Schema for security_rule.condition.host.hosts
- Nested Schema for security_rule.condition.source_ip
- Nested Schema for security_rule.condition.source_ip.geo_ip_match
- Nested Schema for security_rule.condition.source_ip.geo_ip_not_match
- Nested Schema for security_rule.condition.source_ip.ip_ranges_match
- Nested Schema for security_rule.condition.source_ip.ip_ranges_not_match
- Nested Schema for security_rule.condition.uri
- Nested Schema for security_rule.condition.uri.path
- Nested Schema for security_rule.condition.uri.queries
- Nested Schema for security_rule.condition.uri.queries.value
- Nested Schema for timeouts
- Import
Creates a Captcha in the specified folder. For more information, see the official documentation.
Example Usage
//
// Simple SmartCaptcha example.
//
resource "yandex_smartcaptcha_captcha" "demo-captcha-simple" {
deletion_protection = true
name = "demo-captcha-simple"
complexity = "HARD"
pre_check_type = "SLIDER"
challenge_type = "IMAGE_TEXT"
allowed_sites = [
"example.com",
"example.ru"
]
}
//
// Advanced SmartCaptcha example.
//
resource "yandex_smartcaptcha_captcha" "demo-captcha-advanced" {
deletion_protection = true
name = "demo-captcha-advanced"
complexity = "HARD"
pre_check_type = "SLIDER"
challenge_type = "IMAGE_TEXT"
allowed_sites = [
"example.com",
"example.ru"
]
override_variant {
uuid = "xxx"
description = "override variant 1"
complexity = "EASY"
pre_check_type = "CHECKBOX"
challenge_type = "SILHOUETTES"
}
override_variant {
uuid = "yyy"
description = "override variant 2"
complexity = "HARD"
pre_check_type = "CHECKBOX"
challenge_type = "KALEIDOSCOPE"
}
security_rule {
name = "rule1"
priority = 11
description = "My first security rule. This rule it's just example to show possibilities of configuration."
override_variant_uuid = "xxx"
condition {
host {
hosts {
exact_match = "example.com"
}
hosts {
exact_match = "example.net"
}
}
uri {
path {
prefix_match = "/form"
}
queries {
key = "firstname"
value {
pire_regex_match = ".*ivan.*"
}
}
queries {
key = "lastname"
value {
pire_regex_match = ".*petr.*"
}
}
}
headers {
name = "User-Agent"
value {
pire_regex_match = ".*curl.*"
}
}
headers {
name = "Referer"
value {
pire_regex_not_match = ".*bot.*"
}
}
source_ip {
ip_ranges_match {
ip_ranges = ["1.2.33.44", "2.3.4.56"]
}
ip_ranges_not_match {
ip_ranges = ["8.8.0.0/16", "10::1234:1abc:1/64"]
}
geo_ip_match {
locations = ["ru", "es"]
}
geo_ip_not_match {
locations = ["us", "fm", "gb"]
}
}
}
}
security_rule {
name = "rule2"
priority = 555
description = "Second rule"
override_variant_uuid = "yyy"
condition {
uri {
path {
prefix_match = "/form"
}
}
}
}
security_rule {
name = "rule3"
priority = 99999
description = "Empty condition rule"
override_variant_uuid = "yyy"
}
}
Schema
Optional
allowed_sites(List of String) List of allowed host names, see Domain validation.challenge_type(String) Additional task type of the captcha. Possible values:
IMAGE_TEXT- Text recognition: The user has to type a distorted text from the picture into a special field.SILHOUETTES- Silhouettes: The user has to mark several icons from the picture in a particular order.KALEIDOSCOPE- Kaleidoscope: The user has to build a picture from individual parts by shuffling them using a slider.
cloud_id(String) TheCloud IDwhich resource belongs to. If it is not provided, the default providercloud-idis used.complexity(String) Complexity of the captcha. Possible values:
EASY- High chance to pass pre-check and easy advanced challenge.MEDIUM- Medium chance to pass pre-check and normal advanced challenge.HARD- Little chance to pass pre-check and hard advanced challenge.FORCE_HARD- Impossible to pass pre-check and hard advanced challenge.
deletion_protection(Boolean) Thetruevalue means that resource is protected from accidental deletion.folder_id(String) The folder identifier that resource belongs to. If it is not provided, the default providerfolder-idis used.name(String) The resource name.override_variant(Block List) List of variants to use in security_rules. (see below for nested schema)pre_check_type(String) Basic check type of the captcha.Possible values:
CHECKBOX- User must click the 'I am not a robot' button.SLIDER- User must move the slider from left to right.
security_rule(Block List) List of security rules. (see below for nested schema)style_json(String) JSON with variables to define the captcha appearance. For more details see generated JSON in cloud console.timeouts(Block, Optional) (see below for nested schema)turn_off_hostname_check(Boolean) Turn off host name check, see Domain validation.
Read-Only
client_key(String) Client key of the captcha, see CAPTCHA keys.created_at(String) The creation timestamp of the resource.id(String) The ID of this resource.suspend(Boolean)
Nested Schema for override_variant
Optional:
challenge_type(String) Additional task type of the captcha.complexity(String) Complexity of the captcha.description(String) Optional description of the rule. 0-512 characters long.pre_check_type(String) Basic check type of the captcha.uuid(String) Unique identifier of the variant.
Nested Schema for security_rule
Optional:
condition(Block List, Max: 1) The condition for matching the rule. You can find all possibilities of condition in gRPC specs . (see below for nested schema)description(String) Description of the rule. 0-512 characters long.name(String) Name of the rule. The name is unique within the captcha. 1-50 characters long.override_variant_uuid(String) Variant UUID to show in case of match the rule. Keep empty to use defaults.priority(Number) Priority of the rule. Lower value means higher priority.
Nested Schema for security_rule.condition
Optional:
headers(Block List) (see below for nested schema)host(Block List, Max: 1) (see below for nested schema)source_ip(Block List, Max: 1) (see below for nested schema)uri(Block List, Max: 1) (see below for nested schema)
Nested Schema for security_rule.condition.headers
Required:
value(Block List, Min: 1, Max: 1) (see below for nested schema)
Optional:
name(String)
Nested Schema for security_rule.condition.headers.value
Optional:
exact_match(String)exact_not_match(String)pire_regex_match(String)pire_regex_not_match(String)prefix_match(String)prefix_not_match(String)
Nested Schema for security_rule.condition.host
Optional:
hosts(Block List) (see below for nested schema)
Nested Schema for security_rule.condition.host.hosts
Optional:
exact_match(String)exact_not_match(String)pire_regex_match(String)pire_regex_not_match(String)prefix_match(String)prefix_not_match(String)
Nested Schema for security_rule.condition.source_ip
Optional:
geo_ip_match(Block List, Max: 1) (see below for nested schema)geo_ip_not_match(Block List, Max: 1) (see below for nested schema)ip_ranges_match(Block List, Max: 1) (see below for nested schema)ip_ranges_not_match(Block List, Max: 1) (see below for nested schema)
Nested Schema for security_rule.condition.source_ip.geo_ip_match
Optional:
locations(List of String)
Nested Schema for security_rule.condition.source_ip.geo_ip_not_match
Optional:
locations(List of String)
Nested Schema for security_rule.condition.source_ip.ip_ranges_match
Optional:
ip_ranges(List of String)
Nested Schema for security_rule.condition.source_ip.ip_ranges_not_match
Optional:
ip_ranges(List of String)
Nested Schema for security_rule.condition.uri
Optional:
path(Block List, Max: 1) (see below for nested schema)queries(Block List) (see below for nested schema)
Nested Schema for security_rule.condition.uri.path
Optional:
exact_match(String)exact_not_match(String)pire_regex_match(String)pire_regex_not_match(String)prefix_match(String)prefix_not_match(String)
Nested Schema for security_rule.condition.uri.queries
Required:
key(String)value(Block List, Min: 1, Max: 1) (see below for nested schema)
Nested Schema for security_rule.condition.uri.queries.value
Optional:
exact_match(String)exact_not_match(String)pire_regex_match(String)pire_regex_not_match(String)prefix_match(String)prefix_not_match(String)
Nested Schema for timeouts
Optional:
create(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).delete(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.read(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.update(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
Import
The resource can be imported by using their resource ID. For getting the resource ID you can use Yandex Cloud Web Console
# terraform import yandex_smartcaptcha_captcha.<resource Name> <resource Id>
terraform import yandex_smartcaptcha_captcha.demo-captcha-simple ...