Skip to content

Commit

Permalink
terraform-resources module support PoC
Browse files Browse the repository at this point in the history
  • Loading branch information
maorfr committed Jul 10, 2024
1 parent 18acaf6 commit 29dd345
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions reconcile/utils/terrascript_aws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
"records",
"extra_tags",
"lifecycle",
"module",
]

EMAIL_REGEX = re.compile(r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$")
Expand Down Expand Up @@ -1575,6 +1576,8 @@ def populate_tf_resources(self, spec, ocm_map=None):
self.populate_tf_resource_rosa_authenticator_vpce(spec)
elif provider == "msk":
self.populate_tf_resource_msk(spec)
elif provider == "module-poc":
self.populate_tf_resource_module(spec)
else:
raise UnknownProviderError(provider)

Expand Down Expand Up @@ -6713,3 +6716,44 @@ def populate_saml_idp(self, account_name: str, name: str, metadata: str) -> None
f"{account_name}-{name}", name=name, saml_metadata_document=metadata
)
self.add_resource(account_name, saml_idp)

def populate_tf_resource_module(self, spec: ExternalResourceSpec):
account = spec.provisioner_name
identifier = spec.identifier
values = self.init_values(spec, init_tags=False)
values.pop("identifier")

tf_resources: list[Resource] = []
self.init_common_outputs(tf_resources, spec)

module_spec = values.pop("module")
url: str = module_spec["url"]
path: str = module_spec["path"]
ref: str = module_spec["ref"]

self.init_gitlab()
self.init_github()
if self.gitlab and url.startswith(self.gitlab.server):
ssl_verify = self.gitlab.ssl_verify
token = self.gitlab.token
else:
ssl_verify = True
token = self.token

wd = os.path.join(self.working_dirs[account], identifier)
git.clone(
url,
wd,
ref=ref,
depth=1,
verify=ssl_verify,
token=token,
)

values["source"] = os.path.join(wd, path)
module = Module(identifier, **values)
tf_resources.append(module)

# TODO for each module output create terrascript output

self.add_resources(account, tf_resources)

0 comments on commit 29dd345

Please sign in to comment.