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

aws_security_group documentation and plan validation issues with a non-vpc SG using a protocol value of "-1" #1670

Closed
hashibot opened this issue Sep 15, 2017 · 1 comment · Fixed by #1843
Labels
documentation Introduces or discusses updates to documentation.

Comments

@hashibot
Copy link

This issue was originally opened by @ryno75 as hashicorp/terraform#16082. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.10.4

Terraform Configuration Files

resource "aws_security_group" "test" {
  name        = "test_sg"
  description = "Test SG"

  ingress {
    from_port   = 0
    to_port     = 0
    protocol    = -1
    cidr_blocks = ["192.168.0.0/16"]
  }
}

Debug Output

plan: https://gist.github.com/ryno75/9bc7f915b2de350976e03e1fe6c410a5
apply: https://gist.github.com/ryno75/0356173e5ab99fd30b5814b027dbc2e2

Expected Behavior

According to the Terraform documentation (and plan seems to confirm this) this should be perfectly acceptable configuration but it in fact is not. Only Security Groups created under VPCs are allowed to have a protocol value of anything but "tcp", "udp", and "icmp" (i.e. "-1")

Actual Behavior

An EC2 API exception is returned to Terraform and raised.

Error applying plan:

1 error(s) occurred:

* aws_security_group.test_sg: 1 error(s) occurred:

* aws_security_group.test_sg: Error authorizing security group ingress rules: InvalidPermission.Malformed: Unsupported IP protocol "-1"  - supported: [tcp, udp, icmp]
	status code: 400, request id: 14e00208-087d-4cf1-b5c0-23c48f70f0d9

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Steps to Reproduce

Please list the full steps required to reproduce the issue, for example:

  1. Create an aws_security_group resource that has no vpc_id and contains an ingress rule with a protocol value of "-1"
  2. terraform init
  3. terraform apply

Important Factoids

I am not expecting this to result in a change to the behavior of terraform apply but rather that the documentation will be updated to reflect this limitation and that terraform plan will return an exception indicating an invalid configuration.

The Terraform documentation for aws_security_group
https://www.terraform.io/docs/providers/aws/r/security_group.html actually has an example that would result in the above error if it were ran as presented (it does not have a vpc_id defined but has a protocol value of "-1"). See "Basic Usage" under "Example Usage".

@ghost
Copy link

ghost commented Apr 10, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant