Skip to content

Commit

Permalink
Merge pull request #164 from devopshobbies/dev
Browse files Browse the repository at this point in the history
feat(terraform-templates): implementing aws-alb route
  • Loading branch information
mohammadll authored Jan 4, 2025
2 parents a1d692a + 7aa6583 commit d14b988
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
34 changes: 2 additions & 32 deletions app/media/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@

argocd_instance_info = {
server_addr = "http://argocd.local"
username = "username"
password = "password"
insecure = true
}


repository_create = true
argocd_repository_info = {
repo = "https://your_repo.git"
username = "username"
password = "token"
}


application_create = false
argocd_application = {
name = "myapp"
destination_server = "https://kubernetes.default.svc"
destination_namespace = "default"
source_repo_url = "https://your_repo.git"
source_path = "myapp/manifests"
source_target_revision = "master"
}


argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]

auto_prune = false
self_heal = false
alb_create = true
create_security_group = true
6 changes: 5 additions & 1 deletion app/models/terraform_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@ class IaCTemplateGenerationEFS(BaseModel):
efs_file_system:bool = True
efs_mount_target:bool = True
efs_backup_policy:bool = True


class IaCTemplateGenerationALB(BaseModel):

alb_resources:bool = True
security_group:bool = True
16 changes: 15 additions & 1 deletion app/routes/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
IaCTemplateGenerationIAM,
IaCTemplateGenerationArgoCD,
IaCTemplateGenerationELB,
IaCTemplateGenerationEFS
IaCTemplateGenerationEFS,
IaCTemplateGenerationALB
)

from fastapi import Response
Expand All @@ -30,6 +31,7 @@
from app.template_generators.terraform.argocd import (IaC_template_generator_argocd)
from app.template_generators.terraform.aws.ELB import (IaC_template_generator_elb)
from app.template_generators.terraform.aws.EFS import (IaC_template_generator_efs)
from app.template_generators.terraform.aws.ALB import (IaC_template_generator_alb)
from app.template_generators.terraform.Installation.main import (select_install)
import os

Expand Down Expand Up @@ -141,3 +143,15 @@ async def IaC_template_generation_aws_efs(request:IaCTemplateGenerationEFS) -> O

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


@app.post("/api/IaC-template/aws/alb")
async def IaC_template_generation_aws_alb(request:IaCTemplateGenerationALB) -> Output:

dir = 'app/media/terraform.tfvars'

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

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

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

aws_alb_create_resources = 'true' if input.alb_resources else 'false'
aws_alb_create_security_group = 'true' if input.security_group else 'false'

tfvars_file = f"""alb_create = {aws_alb_create_resources}
create_security_group = {aws_alb_create_security_group}
"""
return tfvars_file

0 comments on commit d14b988

Please sign in to comment.