Skip to content

Commit

Permalink
Update syntax to respect TF minimum version (1.0.0)
Browse files Browse the repository at this point in the history
Most of the changes are related to the strictness of TF v0.12

https://www.terraform.io/language/upgrade-guides/0-12
> Due to the design of the configuration language decoder in
> Terraform v0.11 and earlier, it was in many cases possible to
> interchange the argument syntax (with =) and the block syntax
> (with just braces) when dealing with map arguments vs. nested
> blocks. However, this led to some subtle bugs and limitations,
> so Terraform v0.12 now requires consistent usage of argument
> syntax for arguments and nested block syntax for nested blocks.

This commit validates both examples against Terraform 1

The min terraform version is going to be updated to 1.0.0
#11650

Fixes #11652
  • Loading branch information
marcoandredinis committed Apr 4, 2022
1 parent c03f94e commit 6418174
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 42 deletions.
46 changes: 25 additions & 21 deletions examples/resources/terraform/terraform-user-role-cloud.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,70 @@ provider "teleport" {
}

resource "teleport_role" "terraform-test" {
metadata {
metadata = {
name = "terraform-test"
description = "Terraform test role"
labels = {
example = "yes"
}
}

spec {
options {
spec = {
options = {
forward_agent = false
max_session_ttl = "30m"
port_forwarding = false
client_idle_timeout = "1h"
disconnect_expired_cert = true
permit_x11_forwarding = false
permit_x11_forwarding = false
request_access = "denied"
}

allow {
allow = {
logins = ["this-user-does-not-exist"]

rules {
resources = ["user", "role"]
verbs = ["list"]
}
rules = [
{
resources = ["user", "role"]
verbs = ["list"]
}
]

request {
request = {
roles = ["example"]
claims_to_roles {
claim = "example"
value = "example"
roles = ["example"]
}
claims_to_roles = [
{
claim = "example"
value = "example"
roles = ["example"]
}
]
}

node_labels {
key = "example"
node_labels = {
key = ["example"]
value = ["yes"]
}
}

deny {
deny = {
logins = ["anonymous"]
}
}
}

resource "teleport_user" "terraform-test" {
metadata {
metadata = {
name = "terraform-test"
description = "Test terraform user"
expires = "2022-10-12T07:20:50.52Z"
expires = "2022-10-12T07:20:50Z"

labels = {
test = "true"
}
}

spec {
spec = {
roles = ["terraform-test"]
}
}
46 changes: 25 additions & 21 deletions examples/resources/terraform/terraform-user-role-self-hosted.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,70 @@ provider "teleport" {
}

resource "teleport_role" "terraform-test" {
metadata {
metadata = {
name = "terraform-test"
description = "Terraform test role"
labels = {
example = "yes"
}
}

spec {
options {
spec = {
options = {
forward_agent = false
max_session_ttl = "30m"
port_forwarding = false
client_idle_timeout = "1h"
disconnect_expired_cert = true
permit_x11_forwarding = false
permit_x11_forwarding = false
request_access = "denied"
}

allow {
allow = {
logins = ["this-user-does-not-exist"]

rules {
resources = ["user", "role"]
verbs = ["list"]
}
rules = [
{
resources = ["user", "role"]
verbs = ["list"]
}
]

request {
request = {
roles = ["example"]
claims_to_roles {
claim = "example"
value = "example"
roles = ["example"]
}
claims_to_roles = [
{
claim = "example"
value = "example"
roles = ["example"]
}
]
}

node_labels {
key = "example"
node_labels = {
key = ["example"]
value = ["yes"]
}
}

deny {
deny = {
logins = ["anonymous"]
}
}
}

resource "teleport_user" "terraform-test" {
metadata {
metadata = {
name = "terraform-test"
description = "Test terraform user"
expires = "2022-10-12T07:20:50.52Z"
expires = "2022-10-12T07:20:50Z"

labels = {
test = "true"
}
}

spec {
spec = {
roles = ["terraform-test"]
}
}

0 comments on commit 6418174

Please sign in to comment.