Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vmanilo committed Sep 22, 2024
1 parent 4623023 commit 875a442
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/resources/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ resource "twingate_resource" "resource" {
}
// Service acoount access is specified similarly
// A `for_each` block may be used like above to assign access to multiple
// A `for_each` block may be used like above to assign access to multiple
// service accounts in a single configuration block.
access_service {
content {
Expand Down
84 changes: 77 additions & 7 deletions examples/resources/twingate_resource/resource.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
provider "twingate" {
# api_token = "1234567890abcdef"
# network = "mynetwork"
api_token = "1234567890abcdef"
network = "mynetwork"
}

resource "twingate_remote_network" "aws_network" {
name = "aws_remote_network-2"
name = "aws_remote_network"
}

resource "twingate_group" "aws" {
name = "aws_group"
}

data "twingate_group" "security" {
id = "securityGroupID"
}

data "twingate_groups" "devops" {
name_contains = "DevOps"
}

data "twingate_groups" "sre" {
name_contains = "SRE"
}

resource "twingate_service_account" "github_actions_prod" {
name = "Github Actions PROD"
}

data "twingate_security_policy" "test_policy" {
name = "Test Policy"
}

data twingate_dlp_policy test {
name = "Test"
data twingate_dlp_policy access_example {
name = "DLP Policy Access Example"
}

resource "twingate_resource" "resource" {
Expand All @@ -25,7 +41,61 @@ resource "twingate_resource" "resource" {
remote_network_id = twingate_remote_network.aws_network.id

security_policy_id = data.twingate_security_policy.test_policy.id
dlp_policy_id = data.twingate_dlp_policy.test.id
dlp_policy_id = data.twingate_dlp_policy.access_example.id

protocols = {
allow_icmp = true
tcp = {
policy = "RESTRICTED"
ports = ["80", "82-83"]
}
udp = {
policy = "ALLOW_ALL"
}
}

// Adding a single group via `access_group`
access_group {
group_id = twingate_group.aws.id
security_policy_id = data.twingate_security_policy.test_policy.id
usage_based_autolock_duration_days = 30
dlp_policy_id = data.twingate_dlp_policy.access_example.id
}

// Adding multiple groups by individual ID
dynamic "access_group" {
for_each = toset([twingate_group.aws.id, data.twingate_group.security.id])
content {
group_id = access_group.value
security_policy_id = data.twingate_security_policy.test_policy.id
usage_based_autolock_duration_days = 30
}
}

// Adding multiple groups from twingate_groups data sources
dynamic "access_group" {
for_each = setunion(
data.twingate_groups.devops.groups[*].id,
data.twingate_groups.sre.groups[*].id,
// Single IDs can be added by wrapping them in a set
toset([data.twingate_group.security.id])
)
content {
group_id = access_group.value
security_policy_id = data.twingate_security_policy.test_policy.id
usage_based_autolock_duration_days = 30

}
}

// Service acoount access is specified similarly
// A `for_each` block may be used like above to assign access to multiple
// service accounts in a single configuration block.
access_service {
content {
service_account_id = twingate_service_account.github_actions_prod.id
}
}

is_active = true
}
}

0 comments on commit 875a442

Please sign in to comment.