Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding providers data to output #917

Merged
merged 3 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions opta/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ def outputs(self, module_idx: Optional[int] = None) -> Iterable[str]:
module_idx = len(self.modules) - 1 if module_idx is None else module_idx
for module in self.modules[0 : module_idx + 1]:
ret += module.outputs()
if self.parent is None:
ret.append("providers")
return ret

def gen_tf(
Expand Down Expand Up @@ -482,6 +484,8 @@ def gen_tf(
ret,
)
ret["output"] = ret.get("output", {})
if self.parent is None:
ret["output"]["providers"] = {"value": self.providers}
ret["output"]["state_storage"] = {"value": self.state_storage()}

return hydrate(ret, self.metadata_hydration())
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/basic_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"s3_log_bucket_name": {"value": "${module.core.s3_log_bucket_name }"},
"public_nat_ips": {"value": "${module.core.public_nat_ips }"},
"state_storage": {"value": "opta-tf-state-test-dev1-98f2"},
"providers": {
"value": {"aws": {"account_id": "111111111111", "region": "us-east-1"}}
},
},
},
)
2 changes: 2 additions & 0 deletions tests/test_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_hydration_aws(self, mocker: MockFixture):
k8s_node_group_security_id="${data.terraform_remote_state.parent.outputs.k8s_node_group_security_id}",
load_balancer_raw_dns="${data.terraform_remote_state.parent.outputs.load_balancer_raw_dns}",
load_balancer_arn="${data.terraform_remote_state.parent.outputs.load_balancer_arn}",
providers="${data.terraform_remote_state.parent.outputs.providers}",
),
"parent_name": "dummy-parent",
"state_storage": "opta-tf-state-opta-tests-dummy-parent-195d",
Expand Down Expand Up @@ -113,6 +114,7 @@ def test_hydration_gcp(self, mocker: MockFixture):
k8s_ca_data="${data.terraform_remote_state.parent.outputs.k8s_ca_data}",
k8s_cluster_name="${data.terraform_remote_state.parent.outputs.k8s_cluster_name}",
load_balancer_raw_ip="${data.terraform_remote_state.parent.outputs.load_balancer_raw_ip}",
providers="${data.terraform_remote_state.parent.outputs.providers}",
),
"parent_name": "gcp-dummy-parent",
"state_storage": "opta-tf-state-opta-tests-gcp-dummy-parent",
Expand Down