Skip to content

Commit

Permalink
doc: add sg example with for_each (scaleway#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
kindermoumoute authored and Quentin Brosse committed Oct 11, 2019
1 parent ad9a363 commit 078886a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions website/docs/r/instance_security_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ resource "scaleway_instance_security_group" "web" {
}
```

### Trusted IP for SSH access (using for_each)

If you use terraform >= 0.12.6, you can leverage the [`for_each`](https://www.terraform.io/docs/configuration/resources.html#for_each-multiple-resource-instances-defined-by-a-map-or-set-of-strings) feature with this resource.

```hcl
locals {
trusted = ["192.168.0.1", "192.168.0.2", "192.168.0.3"]
}
resource "scaleway_instance_security_group" "dummy" {
inbound_default_policy = "drop"
outbound_default_policy = "accept"
dynamic "inbound_rule" {
for_each = local.trusted
content {
action = "accept"
port = 22
ip = inbound_rule.value
}
}
}
```

## Arguments Reference

The following arguments are supported:
Expand Down

0 comments on commit 078886a

Please sign in to comment.