Skip to content

Commit

Permalink
fix(examples): fix Python example for lookup & lookupNested
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm committed Aug 7, 2023
1 parent 962b1bf commit 31953af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/python/documentation/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ def __init__(self, scope: Construct, id: str):

# DOCS_BLOCK_END:functions-usage-example

# INTERNAL NOTE: Due to an JSII bug, we have to pass a default value for lookup in Python
# INTERNAL NOTE: Due to an JSII bug, we have to pass the variable as a string_value in Python
# We can remove it, once https://github.com/aws/jsii/pull/4209 is released
# DOCS_BLOCK_START:functions-lookup
v = TerraformVariable(self, "complex-object",
type = 'object({users: list(object({name: string}))})',
)
TerraformOutput(self, 'users',
value=Fn.lookup(v.value, "users", "default")
value=Fn.lookup(v.string_value, "users")
)
TerraformOutput(self, 'first_user_name',
value=Fn.lookup_nested(v.value, ["users", 0, "name"])
value=Fn.lookup_nested(v.string_value, ["users", 0, "name"])
)
# DOCS_BLOCK_END:functions-lookup

Expand Down
4 changes: 2 additions & 2 deletions website/docs/cdktf/concepts/functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ v = TerraformVariable(self, "complex-object",
type = 'object({users: list(object({name: string}))})',
)
TerraformOutput(self, 'users',
value=Fn.lookup(v.value, "users", "default")
value=Fn.lookup(v.string_value, "users")
)
TerraformOutput(self, 'first_user_name',
value=Fn.lookup_nested(v.value, ["users", 0, "name"])
value=Fn.lookup_nested(v.string_value, ["users", 0, "name"])
)
```

Expand Down

0 comments on commit 31953af

Please sign in to comment.