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

provider/aws: Convert protocols to standard format for Security Groups #5881

Merged
merged 2 commits into from
Mar 28, 2016

Conversation

catsby
Copy link
Contributor

@catsby catsby commented Mar 28, 2016

Convert network protocols to their names for keys/state in Security Group and Security Group Rules, fixing issue(s) when using them interchangeably.

Fixes issues like #5050 where there is a mix and match of using "6" and "tcp" for the protocol value. The name/number reference can be found here:

We support a limited set of those, as defined/leveraged from https://github.com/hashicorp/terraform/blob/master/builtin/providers/aws/network_acl_entry.go#L81

Right now, if a user specifies "17" for the protocol (the code for upd), they'll get a diff error when they plan/apply. This is because the AWS API will accept the code or number, but will automatically convert numbers to their matching code, e.g. send 17 and get udp back, except for -1 which represents all. If you send -1, you get -1 back.

In this PR we convert all of the numbers referenced in the network_acl_entry.go method to their proper name for hashing. Users can use them interchangeably. I've added a statefunc for both Security Groups and Security Group Rules, and double checked our existing tests to make sure there aren't any stray 6 or other non-string protocols used.

Both TestAccAWSSecurityGroupRule_Ingress_Protocol in security_group_rule_test.go, and the simple "tcp" -> "6" in security_group_test.go are regression tests; they would fail on master.

Convert network protocols to their names for keys/state, fixing issue(s) when
using them interchangeably.
@stack72
Copy link
Contributor

stack72 commented Mar 28, 2016

This is a great find @catsby :) Will be good to close off this issue

LGTM!


resource "aws_security_group" "web" {
name = "terraform_acceptance_test_example"
description = "Used in the terraform acceptance tests"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to omit these to protect us against future collision - let the tags stick around for taxonomy purposes.

@phinze
Copy link
Contributor

phinze commented Mar 28, 2016

Looking solid so far!

  • one inline nit in the acctest fixture
  • I believe "icmp" is also handled as a string and normalized, base on the aws api docs?

@catsby
Copy link
Contributor Author

catsby commented Mar 28, 2016

Discussed icmp out of band; it's currently supported but wasn't explicitly mentioned. This branch allows you to use icmp or 1 interchangeably .

@ghost
Copy link

ghost commented Apr 27, 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 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants