Skip to content

Commit

Permalink
fix: fix some more Python code and document changes in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm committed Feb 23, 2023
1 parent a625b36 commit 9bbcae4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ The following functions changed:
- `Fn.mergeLists()` does not exist anymore, use `Fn.concat()` instead
- `Fn.mergeMaps()` does not exist anymore, use `Fn.merge()` instead

As part of this change, we use the same parameter names as Terraform which might require changing keyword arguments in Python.

```python
# old
Fn.join(",", [src.stringResource.result, src.stringResource.result])
Fn.join(separator=",", value=[src.stringResource.result, src.stringResource.result])
# new
Fn.join(",", [src.stringResource.result, src.stringResource.result]) # stays the same
Fn.join(separator=",", list=[src.stringResource.result, src.stringResource.result]) # value -> list
```

## 0.15.5

### fix
Expand Down
2 changes: 1 addition & 1 deletion examples/python/documentation/stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(self, scope: Construct, id: str, config: BackendStackConfig):

'''
#DOCS_BLOCK_START:stack-dependencies
self.allResources = TerraformLocal(self, "merge_items", Fn.merge_lists(resourceFromStackA.items, resourceFromStackB.items))
self.allResources = TerraformLocal(self, "merge_items", Fn.concat(resourceFromStackA.items, resourceFromStackB.items))
#DOCS_BLOCK_END:stack-dependencies
'''

Expand Down
2 changes: 1 addition & 1 deletion test/python/terraform-functions/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, scope: Construct, ns: str):
}
})
TerraformOutput(self, "computed", value=Fn.element(
Fn.merge_lists([{"id": resource.id}, {"value": "123"}]), 1))
Fn.merge([{"id": resource.id}, {"value": "123"}]), 1))


app = Testing.stub_version(App(stack_traces=False))
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cdktf/concepts/stacks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ this.allResources = new TerraformLocal(this, "merge_items", Fn.mergeLists(Arrays
```
```python
self.allResources = TerraformLocal(self, "merge_items", Fn.merge_lists(resourceFromStackA.items, resourceFromStackB.items))
self.allResources = TerraformLocal(self, "merge_items", Fn.concat(resourceFromStackA.items, resourceFromStackB.items))
```
```csharp
Expand Down

0 comments on commit 9bbcae4

Please sign in to comment.