Skip to content

Commit d89591e

Browse files
authored
Merge pull request #82 from mohammadll/terraform
fix(ec2_prompt): resolve bugs related to variables with object type
2 parents 56deae8 + 6d6ee02 commit d89591e

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

  • app/template_generators/terraform/aws

app/template_generators/terraform/aws/ec2.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ def IaC_template_generator_ec2(input) -> str:
2222
}}
2323
```
2424
- Defines a module block that references "ec2" from a subdirectory within modules.
25-
Don't forget to use source parameter to call ec2 module. this is so important.
25+
Don't forget to use source parameter to call ec2 module as follows:
26+
```
27+
source = "./modules/ec2"
28+
```
2629
This module block should expose all variables that {ec2} resources require, allowing
2730
configuration at the root level rather than directly within the module.
2831
- Every variable defined in {ec2} resources should be passed through the module block,
@@ -33,6 +36,25 @@ def IaC_template_generator_ec2(input) -> str:
3336
key_pair_create(bool), key_pair_name(string)
3437
- Sets these variables names for aws_security_group resource:
3538
security_group_create(bool), security_group_name(string), security_group_ingress_rules(map(object)), security_group_egress_rule(object())
39+
Sets security_group_ingress_rules as follows:
40+
```
41+
type = map(object({{
42+
description = string
43+
from_port = number
44+
to_port = number
45+
protocol = string
46+
cidr_blocks = list(string)
47+
}}))
48+
```
49+
Sets security_group_egress_rule as follows:
50+
```
51+
type = object({{
52+
from_port = number
53+
to_port = number
54+
protocol = string
55+
cidr_blocks = list(string)
56+
}})
57+
```
3658
- Sets these variables names for aws_instance resource:
3759
instance_create(bool), instance_type(string)
3860
- Sets these variables names for aws_ami_from_instance resource:
@@ -192,6 +214,25 @@ def IaC_template_generator_ec2(input) -> str:
192214
key_pair_create(bool), key_pair_name(string)
193215
- Sets these variables names for aws_security_group resource:
194216
security_group_create(bool), security_group_name(string), security_group_ingress_rules(map(object)), security_group_egress_rule(object())
217+
Sets security_group_ingress_rules as follows:
218+
```
219+
type = map(object({{
220+
description = string
221+
from_port = number
222+
to_port = number
223+
protocol = string
224+
cidr_blocks = list(string)
225+
}}))
226+
```
227+
Sets security_group_egress_rule as follows:
228+
```
229+
type = object({{
230+
from_port = number
231+
to_port = number
232+
protocol = string
233+
cidr_blocks = list(string)
234+
}})
235+
```
195236
- Sets these variables names for aws_instance resource:
196237
instance_create(bool), instance_type(string)
197238
- Sets these variables names for aws_ami_from_instance resource:

0 commit comments

Comments
 (0)