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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Palo Alto Rulestack Rule does not allow specifying "any" as a value #25907

Open
1 task done
automagicallyio opened this issue May 8, 2024 · 0 comments
Open
1 task done

Comments

@automagicallyio
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

When using azurerm_palo_alto_local_rulestack_rule Terraform module, you cannot specify "any" as a value for protocol field. It's supported value when you make changes via REST API, but not when you try to do that via Terraform. It appears that the issue is related to validation function: https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/paloalto/validate/protocol.go .

I'm not a Go developer, but I've tried to fix function below:

func ProtocolWithPort(input interface{}, k string) (warnings []string, errors []error) {
	v, ok := input.(string)
	if !ok {
		errors = append(errors, fmt.Errorf("expected %s to be a string", k))
		return
	}

	parts := strings.Split(v, ":")
	if len(parts) != 2 {
		if v != "any" && v != "application-default" {
			errors = append(errors, fmt.Errorf("expected %s to be 'any' or 'application-default' or a two part string separated by a `:`, e.g. TCP:80", k))
			return
		}
	} else {
		if parts[0] != "TCP" && parts[0] != "UDP" {
			errors = append(errors, fmt.Errorf("protocol portion of %s must be one of `TCP` or `UDP`, got %q", k, parts[0]))
		}
	
		port, err := strconv.Atoi(parts[1])
		if err != nil || port == 0 || port > 65535 {
			errors = append(errors, fmt.Errorf("port in %s must me an integer value between 1 and 65535, got %q", k, parts[1]))
		}
	}

	return
}

Terraform Version

1.8.2

AzureRM Provider Version

3.102

Affected Resource(s)/Data Source(s)

azurerm_palo_alto_local_rulestack_rule

Terraform Configuration Files

Not sure what you need here

Debug Output/Panic Output

Not sure what you need here

Expected Behaviour

No response

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants