Terraform: aws_instance security_groups when provide id throwing error

Created on 7 Nov 2015  ·  3Comments  ·  Source: hashicorp/terraform

Hey all

According to this documentation in security_group should be only name of security groups. But I came up with that after big confusion because when I tried to provide ID I got that kind of error :

Error during applying

Which in my opinion is misleading, and if it's possible it should throw a syntax error.

Another misleading is that originally I looked up eventstore-terraform and here it seems working when you pass id

This issue is more about understanding and to clarify it might be helpful for other that struggling with that error/problem.

Thanks,
Pawel

bug provideaws

Most helpful comment

Hey @pawelsawicz – are you creating this security group inside a default VPC? I checked out your example repos (thanks, by the way!) and I don't see a VPC declared. This leads me to believe you're inside a default VPC, which allows the name usage but not id. Is my understanding correct?

Regarding the misleading error, that's the error we're getting back from the AWS API, and is certainly not helping anyone figure out the root case here :smile:

Regarding throwing a syntax error, I don't believe Terraform has the context to make that kind of validation here. The resource is simply receiving a value. It's valid it certain situations. That said, do you think if we attempted to capture that error around here and provide additional warning logs, that would be sufficient? Let me know if I'm missing something here, and thanks again

All 3 comments

Hey @pawelsawicz – are you creating this security group inside a default VPC? I checked out your example repos (thanks, by the way!) and I don't see a VPC declared. This leads me to believe you're inside a default VPC, which allows the name usage but not id. Is my understanding correct?

Regarding the misleading error, that's the error we're getting back from the AWS API, and is certainly not helping anyone figure out the root case here :smile:

Regarding throwing a syntax error, I don't believe Terraform has the context to make that kind of validation here. The resource is simply receiving a value. It's valid it certain situations. That said, do you think if we attempted to capture that error around here and provide additional warning logs, that would be sufficient? Let me know if I'm missing something here, and thanks again

Hey @catsby
Ah yes I should mention that, I don't create VPC, I am using default one. Yes your understanding is correct. Does it mean that if you define VPC then you can use id ?

Yes we could try to capture error, which is "Value () for parameter groupId is invalid. The value cannot be empty" and maybe modify that error a little bit to

  1. "Value () for parameter groupId is invalid. The value cannot be empty, check https://goo.gl/BwlZnp"
  2. "Value () for parameter groupId is invalid. The value cannot be empty, if you use default VPC security groups have to contain names instead of id"

on the other hand I don't think so that terraform should overwrite/modify errors that AWS returns, maybe it's something that we could open a ticket at AWS to make this error message better ?

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.

Was this page helpful?
0 / 5 - 0 ratings