Skip to content

Commit f9233b3

Browse files
committed
feat(terraform-templates): implementing aws-route53 route
1 parent 907ca70 commit f9233b3

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

app/media/terraform.tfvars

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
create = true
2-
create_queue_policy = false
3-
create_dlq = false
4-
create_dlq_redrive_allow_policy = true
5-
create_dlq_queue_policy = false
1+
create_zone = true
2+
create_record = true
3+
create_delegation_set = false
4+
create_resolver_rule_association = false

app/models/terraform_models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,10 @@ class IaCTemplateGenerationSQS(BaseModel):
134134
dlq:bool = False
135135
dlq_redrive_allow_policy:bool = True
136136
dlq_queue_policy:bool = False
137+
138+
class IaCTemplateGenerationRoute53(BaseModel):
139+
140+
zone:bool = True
141+
record:bool = True
142+
delegation_set:bool = False
143+
resolver_rule_association:bool = False

app/routes/terraform.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
IaCTemplateGenerationCloudFront,
2020
IaCTemplateGenerationSNS,
2121
IaCTemplateGenerationAutoScaling,
22-
IaCTemplateGenerationSQS
22+
IaCTemplateGenerationSQS,
23+
IaCTemplateGenerationRoute53
2324
)
2425

2526
from fastapi import Response
@@ -40,6 +41,7 @@
4041
from app.template_generators.terraform.aws.SNS import (IaC_template_generator_sns)
4142
from app.template_generators.terraform.aws.AutoScaling import (IaC_template_generator_autoscaling)
4243
from app.template_generators.terraform.aws.SQS import (IaC_template_generator_sqs)
44+
from app.template_generators.terraform.aws.Route53 import (IaC_template_generator_route53)
4345
from app.template_generators.terraform.Installation.main import (select_install)
4446
import os
4547

@@ -211,3 +213,15 @@ async def IaC_template_generation_aws_sqs(request:IaCTemplateGenerationSQS) -> O
211213

212214
return FileResponse(dir, media_type='application/zip', filename=f"terraform.tfvars")
213215

216+
217+
@app.post("/api/IaC-template/aws/route53")
218+
async def IaC_template_generation_aws_route53(request:IaCTemplateGenerationRoute53) -> Output:
219+
220+
dir = 'app/media/terraform.tfvars'
221+
222+
file_response = IaC_template_generator_route53(request)
223+
with open(dir,'w')as f:
224+
f.write(file_response)
225+
226+
return FileResponse(dir, media_type='application/zip', filename=f"terraform.tfvars")
227+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def IaC_template_generator_route53(input) -> str:
2+
3+
aws_route53_create_zone = 'true' if input.zone else 'false'
4+
aws_route53_create_record = 'true' if input.record else 'false'
5+
aws_route53_create_delegation_set = 'true' if input.delegation_set else 'false'
6+
aws_route53_create_resolver_rule_association = 'true' if input.resolver_rule_association else 'false'
7+
8+
tfvars_file = f"""create_zone = {aws_route53_create_zone}
9+
create_record = {aws_route53_create_record}
10+
create_delegation_set = {aws_route53_create_delegation_set}
11+
create_resolver_rule_association = {aws_route53_create_resolver_rule_association}
12+
"""
13+
return tfvars_file

0 commit comments

Comments
 (0)