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

use count for set multiple scaleway_security_group_rule #25

Closed
eraac opened this issue Nov 28, 2017 · 1 comment · Fixed by #28
Closed

use count for set multiple scaleway_security_group_rule #25

eraac opened this issue Nov 28, 2017 · 1 comment · Fixed by #28
Labels

Comments

@eraac
Copy link

eraac commented Nov 28, 2017

Hi there (again 😄 ),

Terraform Version

Terraform v0.11.0
+ provider.scaleway v1.0.0

Affected Resource(s)

  • scaleway_security_group_rule

Terraform Configuration Files

variable "trusted_ips" {
    type        = "list"
    description = "List of allowed IP for ssh"
    default = ["1.1.1.1/32", "2.2.2.2/32"]
}

resource "scaleway_security_group" "firewall" {
    name        = "firewall"
    description = "Firewall rules"
}

# Allow SSH in
resource "scaleway_security_group_rule" "ssh_in" {
    count = "${length(var.trusted_ips)}"

    security_group = "${scaleway_security_group.firewall.id}"

    action    = "accept"
    direction = "inbound"
    ip_range  = "${element(var.trusted_ips, count.index)}"
    protocol  = "TCP"
    port      = "${var.ssh_port}"
}

Debug Output

scaleway_security_group.firewall: Creating...
  description: "" => "Firewall rules"
  name:        "" => "firewall"
scaleway_security_group.firewall: Creation complete after 1s (ID: ---xxx---)
scaleway_security_group_rule.ssh_in[0]: Creating...
  action:         "" => "accept"
  direction:      "" => "inbound"
  ip_range:       "" => "XXXXX"
  port:           "" => "XXXX"
  protocol:       "" => "TCP"
  security_group: "" => "---xxx---"
scaleway_security_group_rule.ssh_in[1]: Creating...
  action:         "" => "accept"
  direction:      "" => "inbound"
  ip_range:       "" => "XXXXX"
  port:           "" => "XXXX"
  protocol:       "" => "TCP"
  security_group: "" => "---xxx---"
scaleway_security_group_rule.ssh_in[1]: Creation complete after 0s (ID: ---xxx---)

Error: Error applying plan:

1 error(s) occurred:

* scaleway_security_group_rule.ssh_in[0]: 1 error(s) occurred:

* scaleway_security_group_rule.ssh_in.0: Failed to find created security group rule

Expected Behavior

Create 2 rules, one per trusted_ips and terraform should continue

Actual Behavior

Rules for ssh_in are created, but terraform stop due to the error

Steps to Reproduce

  1. terraform apply
@nicolai86
Copy link
Contributor

nicolai86 commented Dec 2, 2017

@eraac after diving into the problem I can tell you that you uncovered a bug which is fixed with #28, but there's also a peculiarity about Scaleways CIDR handling.

Technically, 1.1.1.1/32 and 1.1.1.1 are identical, as both describe only one IP, but Scaleway normalizes this to 1.1.1.1, leading to a diff in the terraform provider.

Once #28 is merged you should use an IP instead of a CIDR to avoid this. The changed implementation will not error but instead give you a diff if you re-apply.

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

Successfully merging a pull request may close this issue.

2 participants