Skip to content

Commit bea3ac5

Browse files
authored
feat: Set folder names correctly (fixes #22) (#25)
1 parent 2545788 commit bea3ac5

File tree

2 files changed

+327
-147
lines changed

2 files changed

+327
-147
lines changed

‎modulestf/convert.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
117117
tmp_edges = []
118118

119119
if node.get("type") == "rds" and node.get("engine") in ["aurora-mysql", "aurora-postgresql"]:
120-
r = Resource(key, "rds-aurora", node.get("text"))
120+
r = Resource(key, "rds-aurora", node_text)
121121

122122
r.update_params({
123123
"isMultiAZ": node.get("multiAZ"),
@@ -171,7 +171,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
171171
resources.append(r.content())
172172

173173
if node.get("type") == "rds" and node.get("engine") not in ["aurora-mysql", "aurora-postgresql"]:
174-
r = Resource(key, "rds", node.get("text"))
174+
r = Resource(key, "rds", node_text)
175175

176176
r.update_params({
177177
"isMultiAZ": node.get("multiAZ"),
@@ -253,7 +253,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
253253

254254
asg_name = G.nodes.get(asg_id, {}).get("text")
255255

256-
r = Resource(asg_id, "autoscaling", node.get("text"))
256+
r = Resource(asg_id, "autoscaling", asg_name)
257257

258258
r.update_params({
259259
"name": asg_name if asg_name else random_pet(),
@@ -293,7 +293,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
293293

294294
parsed_asg_id.add(asg_id)
295295
else:
296-
r = Resource(key, "ec2-instance", node.get("text"))
296+
r = Resource(key, "ec2-instance", node_text)
297297

298298
r.update_params({
299299
"name": node_text if node_text else random_pet(),
@@ -316,7 +316,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
316316
# break
317317

318318
if node.get("elbType") == "application":
319-
r = Resource(key, "alb", node.get("text"))
319+
r = Resource(key, "alb", node_text)
320320

321321
r.update_params({
322322
"name": random_pet(),
@@ -332,7 +332,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
332332
r.update_dynamic_params("security_groups", "[dependency." + sg_id + ".outputs.this_security_group_id]")
333333

334334
elif node.get("elbType") == "network":
335-
r = Resource(key, "nlb", node.get("text"))
335+
r = Resource(key, "nlb", node_text)
336336

337337
r.update_params({
338338
"name": random_pet(),
@@ -344,7 +344,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
344344
r.update_dynamic_params("vpc_id", "dependency." + vpc_id + ".outputs.vpc_id")
345345

346346
else:
347-
r = Resource(key, "elb", node.get("text"))
347+
r = Resource(key, "elb", node_text)
348348

349349
r.update_params({
350350
"name": random_pet(),
@@ -374,7 +374,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
374374
resources.append(r.content())
375375

376376
if node.get("type") == "redshift":
377-
r = Resource(key, "redshift", node.get("text"))
377+
r = Resource(key, "redshift", node_text)
378378

379379
r.update_params({
380380
"cluster_identifier": random_pet(),
@@ -401,7 +401,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
401401
resources.append(r.content())
402402

403403
if node.get("type") == "dynamodb":
404-
r = Resource(key, "dynamodb-table", node.get("text"))
404+
r = Resource(key, "dynamodb-table", node_text)
405405

406406
r.update_params({
407407
"name": random_pet(),
@@ -413,7 +413,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
413413
resources.append(r.content())
414414

415415
if node.get("type") == "s3":
416-
r = Resource(key, "s3-bucket", node.get("text"))
416+
r = Resource(key, "s3-bucket", node_text)
417417

418418
r.update_params({
419419
"bucket": node_text if node_text else random_pet(),
@@ -423,17 +423,17 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
423423
resources.append(r.content())
424424

425425
if node.get("type") == "cloudfront":
426-
r = Resource(key, "cloudfront", node.get("text"))
426+
r = Resource(key, "cloudfront", node_text)
427427

428428
resources.append(r.content())
429429

430430
if node.get("type") == "sns":
431-
r = Resource(key, "sns", node.get("text"))
431+
r = Resource(key, "sns", node_text)
432432

433433
resources.append(r.content())
434434

435435
if node.get("type") == "sqs":
436-
r = Resource(key, "sqs", node.get("text"))
436+
r = Resource(key, "sqs", node_text)
437437

438438
r.update_params({
439439
"fifoQueue": node.get("queueType") == "fifo",
@@ -442,7 +442,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
442442
resources.append(r.content())
443443

444444
if node.get("type") == "sg":
445-
r = Resource(key, "security-group", node.get("text"))
445+
r = Resource(key, "security-group", node.get("group_name"))
446446

447447
r.update_params({
448448
"name": node.get("group_name", random_pet()),
@@ -457,7 +457,7 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901
457457
resources.append(r.content())
458458

459459
if node.get("type") == "vpc":
460-
r = Resource(key, "vpc", node.get("text"))
460+
r = Resource(key, "vpc", node.get("group_name"))
461461

462462
selected_vpc_cidr = "10.0.0.0/16"
463463

0 commit comments

Comments
 (0)