provider/aws: Convert protocols to standard format for Security Groups #5881
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theprotocol
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 forupd
), 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. send17
and getudp
back, except for-1
which representsall
. 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 stray6
or other non-string protocols used.Both
TestAccAWSSecurityGroupRule_Ingress_Protocol
insecurity_group_rule_test.go
, and the simple"tcp"
->"6"
insecurity_group_test.go
are regression tests; they would fail on master.