Skip to content

Commit

Permalink
feat(terraform-templates): implementing aws-route53 route
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadll committed Jan 9, 2025
1 parent 907ca70 commit f9233b3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
9 changes: 4 additions & 5 deletions app/media/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
create = true
create_queue_policy = false
create_dlq = false
create_dlq_redrive_allow_policy = true
create_dlq_queue_policy = false
create_zone = true
create_record = true
create_delegation_set = false
create_resolver_rule_association = false
7 changes: 7 additions & 0 deletions app/models/terraform_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,10 @@ class IaCTemplateGenerationSQS(BaseModel):
dlq:bool = False
dlq_redrive_allow_policy:bool = True
dlq_queue_policy:bool = False

class IaCTemplateGenerationRoute53(BaseModel):

zone:bool = True
record:bool = True
delegation_set:bool = False
resolver_rule_association:bool = False
16 changes: 15 additions & 1 deletion app/routes/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
IaCTemplateGenerationCloudFront,
IaCTemplateGenerationSNS,
IaCTemplateGenerationAutoScaling,
IaCTemplateGenerationSQS
IaCTemplateGenerationSQS,
IaCTemplateGenerationRoute53
)

from fastapi import Response
Expand All @@ -40,6 +41,7 @@
from app.template_generators.terraform.aws.SNS import (IaC_template_generator_sns)
from app.template_generators.terraform.aws.AutoScaling import (IaC_template_generator_autoscaling)
from app.template_generators.terraform.aws.SQS import (IaC_template_generator_sqs)
from app.template_generators.terraform.aws.Route53 import (IaC_template_generator_route53)
from app.template_generators.terraform.Installation.main import (select_install)
import os

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

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


@app.post("/api/IaC-template/aws/route53")
async def IaC_template_generation_aws_route53(request:IaCTemplateGenerationRoute53) -> Output:

dir = 'app/media/terraform.tfvars'

file_response = IaC_template_generator_route53(request)
with open(dir,'w')as f:
f.write(file_response)

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

13 changes: 13 additions & 0 deletions app/template_generators/terraform/aws/Route53.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def IaC_template_generator_route53(input) -> str:

aws_route53_create_zone = 'true' if input.zone else 'false'
aws_route53_create_record = 'true' if input.record else 'false'
aws_route53_create_delegation_set = 'true' if input.delegation_set else 'false'
aws_route53_create_resolver_rule_association = 'true' if input.resolver_rule_association else 'false'

tfvars_file = f"""create_zone = {aws_route53_create_zone}
create_record = {aws_route53_create_record}
create_delegation_set = {aws_route53_create_delegation_set}
create_resolver_rule_association = {aws_route53_create_resolver_rule_association}
"""
return tfvars_file

0 comments on commit f9233b3

Please sign in to comment.