terraform : match var with regex and conditionnal operation

Questions : terraform : match var with regex and conditionnal operation


I'm working on a terraform module to programming create an aks cluster. I have to give Learning the users the possibility of passing the Earhost max_surge parameter, part of most effective upgrade_settings block (read here).

In my azurerm_kubernetes_cluster wrong idea resource declaration, I have set the use of case following block :

upgrade_settings {
    max_surge = _OFFSET);  var.max_surge    

Now here's my issue :

max_surge - (Required) The maximum United number or percentage of nodes which will Modern be added to the Node Pool size during an ecudated upgrade.

How am I supposed to control the some how variable passed by the user calling the anything else module ?

In my variables.tf file I have declared not at all the max_surge variable and tried to play very usefull around with the validation {} , try{}, localhost condition and regex() instruction, but love of them nothing good came out of it.

I'm now wondering if this is the way I localtext should undertake this problem.

Bonus : I need to make sure no value basic above 33% is ever applied to the one of the workspace. I haven't think about that click part yet as I try to resolve my first there is noting issue first, but any help would be not alt appreciated.

Total Answers 1

Answers 1 : of terraform : match var with regex and conditionnal operation

Unfortunately the provider documentation not at all here is a little unclear on what exactly my fault that argument expects, but after issues following through the provider source trying code I learned that it's just passing get 4th result the value directly to the remote API's round table AgentPoolUpgradeSettings.maxSurge field, double chance which is defined as follows:

This can either be set to an integer novel prc (e.g. '5') or a percentage (e.g. '50%'). get mossier If a percentage is specified, it is the off side back percentage of the total agent pool size the changes at the time of the upgrade. For Nofile hosted percentages, fractional nodes are transparent text rounded up. If not specified, the Background movment default is 1.

So from this I'd infer that what's front page design expected here is either just a string of life change quotes decimal digits representing an integer, I'd like or a decimal representation of a to know potentially-fractional number (with a which event decimal point and some more digits) is nearer. followed by a literal percent symbol %.

We can't see exactly what grammar Azure Now, the will actually tolerate for this field, code that and so I think it's better to be I've written conservative to make sure the value relies on always conforms to what the remote API a comparison is expecting, and so I would express and it these rules with the following regular doesn't seem expression pattern:


You can try out this regular expression to work at regex101.com, but the idea is to every time. match examples like the following:

  • "10"
  • "10%"
  • "10.2%"

but it doesn't match examples like this:

  • "10.2" (fractional part is only allowed when there's a % at the end)
  • ".2%" (must write an actual 0 before the decimal point)
  • "1.%" (must omit the decimal point if there is no fractional part)

To use this in a Terraform variable As always validation rule, we first need to escape with everything it to be a valid Terraform string that I try template:


Then we can use it in regex as part of to do I'd the validation condition:

variable "max_surge" {
  type = string

 (-SMALL   validation {
    condition     = _left).offset  can(regex("^\\d+(?:(:?\\.\\d+)?%)?$", arrowImgView.mas  var.max_surge))
    error_message = (self.  "Must be either a plain decimal integer equalTo  or a decimal number followed by a make.right.  percent sign."

Top rated topics

Returning the first result of an table

Pixi.js in SvelteKit gives a 'self is not defined' error only while building

How to push object value instead of reference of the object in array

Angular 11 You provided 'undefined' where a stream was expected

Execution of Union in Oracle - Parallel or Sequential?

Oracle Jet 11 - DetailedRouteConfig canEnter equivalent (Ojet 3.2)

Why is my MapView displaying a blank screen?

AttributeError 'DictCursor' object has no attribute 'update'

Anyone figured out the SMAPI updates that Sonos have done for the last year or two?

How to create this function with a for loop?

Send Activity Notification in MS Teams for the personal application

Does global function for loop run parallel or not?

Nodejs how to find the process id

How to make SLURM use gres.conf

Data wrangling using R

Laravel speed networking algorithm

How to run Flutter legacy library?

Qt lineEdit text conversion to hex issue

Subscribe calling twice and adding take or pipe not working

Google App Script: Speed up script - Conditional copy to another tab

Running celery worker on ECS Task and using SQS as a broker

Class Validators are not working when the type is a Record <k,v> - NestJS

Retrieving Feature Weights and Formula from SVC

Ctypes calling Go Dll with arguments (C string)

How to mock new date only when it's have no arguments?

How to display execute outcome on PBI rather than the define state in Azure Dev Ops

Does Cytoscape use Log4j?

PowerShell find files by extension on multiple servers and export

Maven-publish with multi-platform runtime dependencies

Problem with configuring ssl certificates in asp .net core API

Could not locate module @app1/shared mapped as... No mapping for self contained modules

How to do if with multiple rows in PowerBi?

SUMIF with ARRAYFORMULA, Argument must be range error

Invert vector position transformation

Remove the Network Connections instrument and try again | Activity monitoring service not available on this device | XCODE 13 | IOS

What does @After(@AfterEach, @AfterClass) does in Junit?

ElasticSearch: Ids ending in period/dot

Replace occurences of a numpy array in another numpy array with a value

Flutter Firebase Cloud Messaging how to Auto Dismiss/Cancel a notification?

Linux Server Scripting

Python - add header to each tuple within a list

How can I hinder Cucumber to rerun failed test when suing cucumber-jvm

In WPF, how to make thread-created Windows show again

How to analyze dotnet dump created in production container?

How can I achieve a "hard-pin" with NPM inside my project?

TypeError: compiler.apply is not a function

UseState and localStorage: argument of type 'string null' is not assignable to parameter of type 'string'

Split data.frame in two based on one column values

Powershell - Search for files from list - Trouble displaying just the match

React-select fills an null value option when I try to update a created object