From 6d6ee026da0f6148ccc32aba176eedbc0a0f3ce7 Mon Sep 17 00:00:00 2001 From: mohammadll Date: Wed, 20 Nov 2024 23:54:14 +0330 Subject: [PATCH] fix(ec2_prompt): resolve bugs related to varibales with object type --- app/template_generators/terraform/aws/ec2.py | 43 +++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/app/template_generators/terraform/aws/ec2.py b/app/template_generators/terraform/aws/ec2.py index 21877246..d8e25f82 100644 --- a/app/template_generators/terraform/aws/ec2.py +++ b/app/template_generators/terraform/aws/ec2.py @@ -22,7 +22,10 @@ def IaC_template_generator_ec2(input) -> str: }} ``` - Defines a module block that references "ec2" from a subdirectory within modules. - Don't forget to use source parameter to call ec2 module. this is so important. + Don't forget to use source parameter to call ec2 module as follows: + ``` + source = "./modules/ec2" + ``` This module block should expose all variables that {ec2} resources require, allowing configuration at the root level rather than directly within the module. - Every variable defined in {ec2} resources should be passed through the module block, @@ -33,6 +36,25 @@ def IaC_template_generator_ec2(input) -> str: key_pair_create(bool), key_pair_name(string) - Sets these variables names for aws_security_group resource: security_group_create(bool), security_group_name(string), security_group_ingress_rules(map(object)), security_group_egress_rule(object()) + Sets security_group_ingress_rules as follows: + ``` + type = map(object({{ + description = string + from_port = number + to_port = number + protocol = string + cidr_blocks = list(string) + }})) + ``` + Sets security_group_egress_rule as follows: + ``` + type = object({{ + from_port = number + to_port = number + protocol = string + cidr_blocks = list(string) + }}) + ``` - Sets these variables names for aws_instance resource: instance_create(bool), instance_type(string) - Sets these variables names for aws_ami_from_instance resource: @@ -192,6 +214,25 @@ def IaC_template_generator_ec2(input) -> str: key_pair_create(bool), key_pair_name(string) - Sets these variables names for aws_security_group resource: security_group_create(bool), security_group_name(string), security_group_ingress_rules(map(object)), security_group_egress_rule(object()) + Sets security_group_ingress_rules as follows: + ``` + type = map(object({{ + description = string + from_port = number + to_port = number + protocol = string + cidr_blocks = list(string) + }})) + ``` + Sets security_group_egress_rule as follows: + ``` + type = object({{ + from_port = number + to_port = number + protocol = string + cidr_blocks = list(string) + }}) + ``` - Sets these variables names for aws_instance resource: instance_create(bool), instance_type(string) - Sets these variables names for aws_ami_from_instance resource: