diff --git a/app/directory_generators/terraform_generator.py b/app/directory_generators/terraform_generator.py index 20d483ca..ef377fe6 100644 --- a/app/directory_generators/terraform_generator.py +++ b/app/directory_generators/terraform_generator.py @@ -1,128 +1,93 @@ import os project_name = "app/media/MyTerraform" modules_dir = os.path.join(project_name, "modules") -ec2_dir = os.path.join(modules_dir, "ec2") +argocd_dir = os.path.join(modules_dir, "argocd") # Create project directories -os.makedirs(ec2_dir, exist_ok=True) +os.makedirs(argocd_dir, exist_ok=True) # Create main.tf with open(os.path.join(project_name, "main.tf"), "w") as main_file: main_file.write(''' -provider "aws" { - region = "us-east-1" +provider "argocd" { + server_addr = var.argocd_instance_info["server_addr"] + username = var.argocd_instance_info["username"] + password = var.argocd_instance_info["password"] + insecure = var.argocd_instance_info["insecure"] } -module "ec2" { - source = "./modules/ec2" +module "argocd" { + source = "./modules/argocd" - key_pair_create = var.key_pair_create - key_pair_name = var.key_pair_name - - security_group_create = var.security_group_create - security_group_name = var.security_group_name - security_group_ingress_rules = var.security_group_ingress_rules - security_group_egress_rule = var.security_group_egress_rule - - instance_create = var.instance_create - instance_type = var.instance_type - - ami_from_instance_create = var.ami_from_instance_create - ami_name = var.ami_name + repository_create = var.repository_create + argocd_repository_info = var.argocd_repository_info + application_create = var.application_create + argocd_application = var.argocd_application + argocd_sync_options = var.argocd_sync_options } ''') # Create variables.tf with open(os.path.join(project_name, "variables.tf"), "w") as variables_file: variables_file.write(''' -variable "key_pair_create" { - type = bool -} - -variable "key_pair_name" { - type = string -} - -variable "security_group_create" { - type = bool -} - -variable "security_group_name" { - type = string -} - -variable "security_group_ingress_rules" { - type = map(object({ - description = string - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) - })) -} - -variable "security_group_egress_rule" { +variable "argocd_instance_info" { type = object({ - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) + server_addr = string + username = string + password = string + insecure = bool }) } -variable "instance_create" { +variable "repository_create" { type = bool } -variable "instance_type" { - type = string +variable "argocd_repository_info" { + type = map(string) } -variable "ami_from_instance_create" { +variable "application_create" { type = bool } -variable "ami_name" { - type = string +variable "argocd_application" { + type = map(string) +} + +variable "argocd_sync_options" { + type = list(string) } ''') # Create terraform.tfvars with open(os.path.join(project_name, "terraform.tfvars"), "w") as tfvars_file: tfvars_file.write(''' -key_pair_create = true -key_pair_name = "ec2" - -security_group_create = true -security_group_name = "my_rules" -security_group_ingress_rules = { - ssh_rule = { - description = "SSH Ingress" - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - }, - http_rule = { - description = "HTTP Ingress" - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } +argocd_instance_info = { + server_addr = "ARGOCD_DOMAIN" + username = "admin" + password = "ARGOCD_ADMIN_PASS" + insecure = true } -security_group_egress_rule = { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] + +repository_create = true +argocd_repository_info = { + repo = "https://YOUR_REPO.git" + username = "USERNAME" + password = "CHANGE_ME_WITH_TOKEN" } -instance_create = false -instance_type = "t2.micro" +application_create = true +argocd_application = { + name = "APPLICATION_NAME" + destination_server = "https://kubernetes.default.svc" + destination_namespace = "DESTINATION_NAMESPACE" + source_repo_url = "https://YOUR_REPO.git" + source_path = "SOURCE_PATH" + source_target_revision = "SOURCE_TARGET_REVISION" +} -ami_from_instance_create = true -ami_name = "my-own-ami" +argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"] ''') # Create versions.tf @@ -132,184 +97,114 @@ required_version = ">= 1.0" required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 5.20" + argocd = { + source = "oboukili/argocd" + version = ">= 6.0.2" } } } ''') -# Create ec2 module files -with open(os.path.join(ec2_dir, "terraform.pub"), "w") as pub_file: - pass - -with open(os.path.join(ec2_dir, "main.tf"), "w") as ec2_main_file: - ec2_main_file.write(''' -data "aws_ami" "linux" { - most_recent = true - owners = ["amazon"] - - filter { - name = "name" - values = ["al2023-ami-2023*kernel-6.1-x86_64"] - } - - filter { - name = "root-device-type" - values = ["ebs"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } -} - -resource "aws_key_pair" "key_pair" { - count = var.key_pair_create ? 1 : 0 - key_name = var.key_pair_name - public_key = file("${path.module}/terraform.pub") -} - -resource "aws_security_group" "security_group" { - count = var.security_group_create ? 1 : 0 - name = var.security_group_name - - dynamic "ingress" { - for_each = var.security_group_ingress_rules - content { - description = ingress.value["description"] - from_port = ingress.value["from_port"] - to_port = ingress.value["to_port"] - protocol = ingress.value["protocol"] - cidr_blocks = ingress.value["cidr_blocks"] +# Create module main.tf +with open(os.path.join(argocd_dir, "main.tf"), "w") as module_main_file: + module_main_file.write(''' +resource "argocd_repository" "repository" { + count = var.repository_create ? 1 : 0 + repo = var.argocd_repository_info["repo"] + username = var.argocd_repository_info["username"] + password = var.argocd_repository_info["password"] +} + +resource "argocd_application" "application" { + count = var.application_create ? 1 : 0 + depends_on = [argocd_repository.repository] + + metadata { + name = var.argocd_application["name"] + namespace = "argocd" + labels = { + using_sync_policy_options = "true" } } - egress { - from_port = var.security_group_egress_rule["from_port"] - to_port = var.security_group_egress_rule["to_port"] - protocol = var.security_group_egress_rule["protocol"] - cidr_blocks = var.security_group_egress_rule["cidr_blocks"] + spec { + destination { + server = var.argocd_application["destination_server"] + namespace = var.argocd_application["destination_namespace"] + } + source { + repo_url = var.argocd_application["source_repo_url"] + path = var.argocd_application["source_path"] + target_revision = var.argocd_application["source_target_revision"] + } + sync_policy { + automated { + prune = true + self_heal = true + } + sync_options = var.argocd_sync_options + } } } - -resource "aws_instance" "instance" { - count = var.instance_create ? 1 : 0 - ami = data.aws_ami.linux.id - instance_type = var.instance_type - key_name = var.key_pair_create ? aws_key_pair.key_pair[0].key_name : null - vpc_security_group_ids = var.security_group_create ? [aws_security_group.security_group[0].id] : null -} - -resource "aws_ami_from_instance" "ami" { - count = var.instance_create && var.ami_from_instance_create ? 1 : 0 - name = var.ami_name - source_instance_id = aws_instance.instance[0].id -} ''') -with open(os.path.join(ec2_dir, "variables.tf"), "w") as ec2_variables_file: - ec2_variables_file.write(''' -variable "key_pair_create" { +# Create module variables.tf +with open(os.path.join(argocd_dir, "variables.tf"), "w") as module_variables_file: + module_variables_file.write(''' +variable "repository_create" { type = bool } -variable "key_pair_name" { - type = string +variable "argocd_repository_info" { + type = map(string) } -variable "security_group_create" { +variable "application_create" { type = bool } -variable "security_group_name" { - type = string +variable "argocd_application" { + type = map(string) } -variable "security_group_ingress_rules" { - type = map(object({ - description = string - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) - })) -} - -variable "security_group_egress_rule" { - type = object({ - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) - }) -} - -variable "instance_create" { - type = bool -} - -variable "instance_type" { - type = string -} - -variable "ami_from_instance_create" { - type = bool -} - -variable "ami_name" { - type = string +variable "argocd_sync_options" { + type = list(string) } ''') -with open(os.path.join(ec2_dir, "terraform.tfvars"), "w") as ec2_tfvars_file: - ec2_tfvars_file.write(''' -key_pair_create = true -key_pair_name = "ec2" - -security_group_create = true -security_group_name = "my_rules" -security_group_ingress_rules = { - ssh_rule = { - description = "SSH Ingress" - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - }, - http_rule = { - description = "HTTP Ingress" - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } -} -security_group_egress_rule = { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] +# Create module terraform.tfvars +with open(os.path.join(argocd_dir, "terraform.tfvars"), "w") as module_tfvars_file: + module_tfvars_file.write(''' +repository_create = true +argocd_repository_info = { + repo = "https://YOUR_REPO.git" + username = "USERNAME" + password = "CHANGE_ME_WITH_TOKEN" } -instance_create = false -instance_type = "t2.micro" +application_create = true +argocd_application = { + name = "APPLICATION_NAME" + destination_server = "https://kubernetes.default.svc" + destination_namespace = "DESTINATION_NAMESPACE" + source_repo_url = "https://YOUR_REPO.git" + source_path = "SOURCE_PATH" + source_target_revision = "SOURCE_TARGET_REVISION" +} -ami_from_instance_create = true -ami_name = "my-own-ami" +argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"] ''') -with open(os.path.join(ec2_dir, "versions.tf"), "w") as ec2_versions_file: - ec2_versions_file.write(''' +# Create module versions.tf +with open(os.path.join(argocd_dir, "versions.tf"), "w") as module_versions_file: + module_versions_file.write(''' terraform { required_version = ">= 1.0" required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 5.20" + argocd = { + source = "oboukili/argocd" + version = ">= 6.0.2" } } } diff --git a/app/media/MyTerraform/.terraform/modules/modules.json b/app/media/MyTerraform/.terraform/modules/modules.json deleted file mode 100644 index 59daf448..00000000 --- a/app/media/MyTerraform/.terraform/modules/modules.json +++ /dev/null @@ -1 +0,0 @@ -{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"ec2","Source":"./modules/ec2","Dir":"modules/ec2"}]} \ No newline at end of file diff --git a/app/media/MyTerraform/main.tf b/app/media/MyTerraform/main.tf index 6168e8f5..36f59aaf 100644 --- a/app/media/MyTerraform/main.tf +++ b/app/media/MyTerraform/main.tf @@ -1,22 +1,17 @@ -provider "aws" { - region = "us-east-1" +provider "argocd" { + server_addr = var.argocd_instance_info["server_addr"] + username = var.argocd_instance_info["username"] + password = var.argocd_instance_info["password"] + insecure = var.argocd_instance_info["insecure"] } -module "ec2" { - source = "./modules/ec2" +module "argocd" { + source = "./modules/argocd" - key_pair_create = var.key_pair_create - key_pair_name = var.key_pair_name - - security_group_create = var.security_group_create - security_group_name = var.security_group_name - security_group_ingress_rules = var.security_group_ingress_rules - security_group_egress_rule = var.security_group_egress_rule - - instance_create = var.instance_create - instance_type = var.instance_type - - ami_from_instance_create = var.ami_from_instance_create - ami_name = var.ami_name + repository_create = var.repository_create + argocd_repository_info = var.argocd_repository_info + application_create = var.application_create + argocd_application = var.argocd_application + argocd_sync_options = var.argocd_sync_options } diff --git a/app/media/MyTerraform/modules/argocd/main.tf b/app/media/MyTerraform/modules/argocd/main.tf new file mode 100644 index 00000000..350bb665 --- /dev/null +++ b/app/media/MyTerraform/modules/argocd/main.tf @@ -0,0 +1,39 @@ + +resource "argocd_repository" "repository" { + count = var.repository_create ? 1 : 0 + repo = var.argocd_repository_info["repo"] + username = var.argocd_repository_info["username"] + password = var.argocd_repository_info["password"] +} + +resource "argocd_application" "application" { + count = var.application_create ? 1 : 0 + depends_on = [argocd_repository.repository] + + metadata { + name = var.argocd_application["name"] + namespace = "argocd" + labels = { + using_sync_policy_options = "true" + } + } + + spec { + destination { + server = var.argocd_application["destination_server"] + namespace = var.argocd_application["destination_namespace"] + } + source { + repo_url = var.argocd_application["source_repo_url"] + path = var.argocd_application["source_path"] + target_revision = var.argocd_application["source_target_revision"] + } + sync_policy { + automated { + prune = true + self_heal = true + } + sync_options = var.argocd_sync_options + } + } +} diff --git a/app/media/MyTerraform/modules/argocd/terraform.tfvars b/app/media/MyTerraform/modules/argocd/terraform.tfvars new file mode 100644 index 00000000..2552956f --- /dev/null +++ b/app/media/MyTerraform/modules/argocd/terraform.tfvars @@ -0,0 +1,19 @@ + +repository_create = true +argocd_repository_info = { + repo = "https://YOUR_REPO.git" + username = "USERNAME" + password = "CHANGE_ME_WITH_TOKEN" +} + +application_create = true +argocd_application = { + name = "APPLICATION_NAME" + destination_server = "https://kubernetes.default.svc" + destination_namespace = "DESTINATION_NAMESPACE" + source_repo_url = "https://YOUR_REPO.git" + source_path = "SOURCE_PATH" + source_target_revision = "SOURCE_TARGET_REVISION" +} + +argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"] diff --git a/app/media/MyTerraform/modules/argocd/variables.tf b/app/media/MyTerraform/modules/argocd/variables.tf new file mode 100644 index 00000000..5d76fdc1 --- /dev/null +++ b/app/media/MyTerraform/modules/argocd/variables.tf @@ -0,0 +1,20 @@ + +variable "repository_create" { + type = bool +} + +variable "argocd_repository_info" { + type = map(string) +} + +variable "application_create" { + type = bool +} + +variable "argocd_application" { + type = map(string) +} + +variable "argocd_sync_options" { + type = list(string) +} diff --git a/app/media/MyTerraform/modules/ec2/versions.tf b/app/media/MyTerraform/modules/argocd/versions.tf similarity index 50% rename from app/media/MyTerraform/modules/ec2/versions.tf rename to app/media/MyTerraform/modules/argocd/versions.tf index b19ec086..c2fa9111 100644 --- a/app/media/MyTerraform/modules/ec2/versions.tf +++ b/app/media/MyTerraform/modules/argocd/versions.tf @@ -3,9 +3,9 @@ terraform { required_version = ">= 1.0" required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 5.20" + argocd = { + source = "oboukili/argocd" + version = ">= 6.0.2" } } } diff --git a/app/media/MyTerraform/modules/ec2/main.tf b/app/media/MyTerraform/modules/ec2/main.tf deleted file mode 100644 index b1ee0cd3..00000000 --- a/app/media/MyTerraform/modules/ec2/main.tf +++ /dev/null @@ -1,63 +0,0 @@ - -data "aws_ami" "linux" { - most_recent = true - owners = ["amazon"] - - filter { - name = "name" - values = ["al2023-ami-2023*kernel-6.1-x86_64"] - } - - filter { - name = "root-device-type" - values = ["ebs"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } -} - -resource "aws_key_pair" "key_pair" { - count = var.key_pair_create ? 1 : 0 - key_name = var.key_pair_name - public_key = file("${path.module}/terraform.pub") -} - -resource "aws_security_group" "security_group" { - count = var.security_group_create ? 1 : 0 - name = var.security_group_name - - dynamic "ingress" { - for_each = var.security_group_ingress_rules - content { - description = ingress.value["description"] - from_port = ingress.value["from_port"] - to_port = ingress.value["to_port"] - protocol = ingress.value["protocol"] - cidr_blocks = ingress.value["cidr_blocks"] - } - } - - egress { - from_port = var.security_group_egress_rule["from_port"] - to_port = var.security_group_egress_rule["to_port"] - protocol = var.security_group_egress_rule["protocol"] - cidr_blocks = var.security_group_egress_rule["cidr_blocks"] - } -} - -resource "aws_instance" "instance" { - count = var.instance_create ? 1 : 0 - ami = data.aws_ami.linux.id - instance_type = var.instance_type - key_name = var.key_pair_create ? aws_key_pair.key_pair[0].key_name : null - vpc_security_group_ids = var.security_group_create ? [aws_security_group.security_group[0].id] : null -} - -resource "aws_ami_from_instance" "ami" { - count = var.instance_create && var.ami_from_instance_create ? 1 : 0 - name = var.ami_name - source_instance_id = aws_instance.instance[0].id -} diff --git a/app/media/MyTerraform/modules/ec2/terraform.pub b/app/media/MyTerraform/modules/ec2/terraform.pub deleted file mode 100644 index e69de29b..00000000 diff --git a/app/media/MyTerraform/modules/ec2/terraform.tfvars b/app/media/MyTerraform/modules/ec2/terraform.tfvars deleted file mode 100644 index 4902d205..00000000 --- a/app/media/MyTerraform/modules/ec2/terraform.tfvars +++ /dev/null @@ -1,34 +0,0 @@ - -key_pair_create = true -key_pair_name = "ec2" - -security_group_create = true -security_group_name = "my_rules" -security_group_ingress_rules = { - ssh_rule = { - description = "SSH Ingress" - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - }, - http_rule = { - description = "HTTP Ingress" - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } -} -security_group_egress_rule = { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] -} - -instance_create = false -instance_type = "t2.micro" - -ami_from_instance_create = true -ami_name = "my-own-ami" diff --git a/app/media/MyTerraform/modules/ec2/variables.tf b/app/media/MyTerraform/modules/ec2/variables.tf deleted file mode 100644 index 6e05d798..00000000 --- a/app/media/MyTerraform/modules/ec2/variables.tf +++ /dev/null @@ -1,51 +0,0 @@ - -variable "key_pair_create" { - type = bool -} - -variable "key_pair_name" { - type = string -} - -variable "security_group_create" { - type = bool -} - -variable "security_group_name" { - type = string -} - -variable "security_group_ingress_rules" { - type = map(object({ - description = string - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) - })) -} - -variable "security_group_egress_rule" { - type = object({ - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) - }) -} - -variable "instance_create" { - type = bool -} - -variable "instance_type" { - type = string -} - -variable "ami_from_instance_create" { - type = bool -} - -variable "ami_name" { - type = string -} diff --git a/app/media/MyTerraform/terraform.tfvars b/app/media/MyTerraform/terraform.tfvars index 4902d205..f2793be0 100644 --- a/app/media/MyTerraform/terraform.tfvars +++ b/app/media/MyTerraform/terraform.tfvars @@ -1,34 +1,26 @@ -key_pair_create = true -key_pair_name = "ec2" - -security_group_create = true -security_group_name = "my_rules" -security_group_ingress_rules = { - ssh_rule = { - description = "SSH Ingress" - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - }, - http_rule = { - description = "HTTP Ingress" - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } +argocd_instance_info = { + server_addr = "ARGOCD_DOMAIN" + username = "admin" + password = "ARGOCD_ADMIN_PASS" + insecure = true } -security_group_egress_rule = { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] + +repository_create = true +argocd_repository_info = { + repo = "https://YOUR_REPO.git" + username = "USERNAME" + password = "CHANGE_ME_WITH_TOKEN" } -instance_create = false -instance_type = "t2.micro" +application_create = true +argocd_application = { + name = "APPLICATION_NAME" + destination_server = "https://kubernetes.default.svc" + destination_namespace = "DESTINATION_NAMESPACE" + source_repo_url = "https://YOUR_REPO.git" + source_path = "SOURCE_PATH" + source_target_revision = "SOURCE_TARGET_REVISION" +} -ami_from_instance_create = true -ami_name = "my-own-ami" +argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"] diff --git a/app/media/MyTerraform/variables.tf b/app/media/MyTerraform/variables.tf index 6e05d798..6cd53c28 100644 --- a/app/media/MyTerraform/variables.tf +++ b/app/media/MyTerraform/variables.tf @@ -1,51 +1,29 @@ -variable "key_pair_create" { - type = bool -} - -variable "key_pair_name" { - type = string -} - -variable "security_group_create" { - type = bool -} - -variable "security_group_name" { - type = string -} - -variable "security_group_ingress_rules" { - type = map(object({ - description = string - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) - })) -} - -variable "security_group_egress_rule" { +variable "argocd_instance_info" { type = object({ - from_port = number - to_port = number - protocol = string - cidr_blocks = list(string) + server_addr = string + username = string + password = string + insecure = bool }) } -variable "instance_create" { +variable "repository_create" { type = bool } -variable "instance_type" { - type = string +variable "argocd_repository_info" { + type = map(string) } -variable "ami_from_instance_create" { +variable "application_create" { type = bool } -variable "ami_name" { - type = string +variable "argocd_application" { + type = map(string) +} + +variable "argocd_sync_options" { + type = list(string) } diff --git a/app/media/MyTerraform/versions.tf b/app/media/MyTerraform/versions.tf index b19ec086..c2fa9111 100644 --- a/app/media/MyTerraform/versions.tf +++ b/app/media/MyTerraform/versions.tf @@ -3,9 +3,9 @@ terraform { required_version = ">= 1.0" required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 5.20" + argocd = { + source = "oboukili/argocd" + version = ">= 6.0.2" } } } diff --git a/app/models/terraform_models.py b/app/models/terraform_models.py index 40094911..d4301eea 100644 --- a/app/models/terraform_models.py +++ b/app/models/terraform_models.py @@ -93,6 +93,7 @@ class ArgoApplication(BaseModel): class IaCTemplateGenerationArgoCD(BaseModel): argocd_application:ArgoApplication | None = None argocd_repository:bool = True + application_depends_repository:bool = True class IaCTemplateGenerationELB(BaseModel): diff --git a/app/template_generators/terraform/argocd.py b/app/template_generators/terraform/argocd.py index 85d24322..ef8f34ec 100644 --- a/app/template_generators/terraform/argocd.py +++ b/app/template_generators/terraform/argocd.py @@ -11,6 +11,10 @@ def IaC_template_generator_argocd(input) -> str: argocd_create_application = 'false' argocd_application_auto_prune = "" argocd_application_selfheal = "" + + depends_on = 'depends_on = []' + if input.application_depends_repository == True: + depends_on = 'depends_on = [argocd_repository.repository]' prompt = f""" Generate a Python code to generate a Terraform project (project name is app/media/MyTerraform) @@ -112,7 +116,13 @@ def IaC_template_generator_argocd(input) -> str: ``` count = var.application_create ? 1 : 0 ``` - - 2. metadata (A block): Define a metadata block as follows: + - 2. add depends_on block following : + ``` + {depends_on} + + ``` + + - 3. metadata (A block): Define a metadata block as follows: ``` metadata {{ name = var.argocd_application["name"] @@ -122,7 +132,7 @@ def IaC_template_generator_argocd(input) -> str: }} }} ``` - - 3. spec (A block): Define a spec block as follows: + - 4. spec (A block): Define a spec block as follows: ``` spec {{ destination {{ diff --git a/app/tests/test_iac_template.py b/app/tests/test_iac_template.py index 7c79eaf8..ac72b641 100644 --- a/app/tests/test_iac_template.py +++ b/app/tests/test_iac_template.py @@ -21,6 +21,7 @@ def teardown_method(self): def test_iac_template_docker(self, client, iac_template_docker_sample_input): response = client.post(self.iac_template_docker_url, json=iac_template_docker_sample_input) + print(response.json()) assert response.status_code == 200 def test_iac_template_ec2(self, client, iac_template_ec2_sample_input):