Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

substr(var.small_string, -4, -1) crashes if the string is not long enough #17041

Closed
marcosdiez opened this issue Jan 5, 2018 · 1 comment · Fixed by #17043
Closed

substr(var.small_string, -4, -1) crashes if the string is not long enough #17041

marcosdiez opened this issue Jan 5, 2018 · 1 comment · Fixed by #17043

Comments

@marcosdiez
Copy link

marcosdiez commented Jan 5, 2018

Terraform Version

Terraform v0.11.1
+ provider.aws v1.6.0

Terraform Configuration Files

variable "small_string" {
  default = "mmm"
}

# Here we have a basic string handling error
# substr will crash because it can't get the last 4 charcters of a 3 caracter string

resource "aws_security_group" "whatever" {
  name        = "this_will_crash"
  description = "This will crash because var.small_string has less than 4 characters ${ substr(var.small_string, -4, -1) }"
}

Debug Output

https://gist.github.com/marcosdiez/e3fed4bf49274706be3c656b03cc0498

Crash Output

https://gist.github.com/marcosdiez/c648c31911b1e5a3155fba4ddb4598ba

Expected Behavior

terraform validate (and terraform plan and terraform apply should complain that string ( var.small_string ) is too small and therefore it can't proceed

Actual Behavior

it crashes

Steps to Reproduce

Additional Context

The issue is quite simple: substr should check if the string has the appropriate size.

-->

@marcosdiez marcosdiez changed the title substr(var.small_string, -4, -1) crasehs if the string is not long enough substr(var.small_string, -4, -1) crashes if the string is not long enough Jan 5, 2018
minamijoyo added a commit to minamijoyo/terraform that referenced this issue Jan 5, 2018
@ghost
Copy link

ghost commented Apr 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants