Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(terraform_prompt): modify prompt to have a better control on reso… #58

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions app/prompt_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def IaC_template_generator(input : IaCTemplateGeneration) -> str:
- Every variable defined in {input.base_config} should be passed through the module block,
ensuring that users can adjust all critical parameters of {input.base_config} by
modifying root main.tf.
- Avoid using versions in the root main.tf. place versions in versions.tf only
- variables.tf:
- Declares all variables that users might need to configure for {input.base_config}.
These should include any inputs required by the provider or the {input.base_config}
resource, as well as optional parameters that users may want to customize.
- Define variables only for parameters explicitly required by the {input.base_config} resource
with exactly the same keys of {input.base_config} module, don't use new keys, and also avoid using any additional parameter
- Variable descriptions should clearly indicate their purpose, and default values should
be avoided unless there are reasonable, common defaults, to maintain flexibility and
encourage explicit configuration.
Expand Down Expand Up @@ -83,18 +83,34 @@ def IaC_template_generator(input : IaCTemplateGeneration) -> str:
}}
}}
}}
- outputs.tf:
- Exposes relevant outputs from {input.base_config}, retrieving them from the module output
and making them accessible at the root level. Each output should have a clear description,
making it easy for users to understand the value and purpose of the output data.
2. Module Directory Structure (modules/{input.base_config}):
- main.tf:
- Defines the {input.base_config} resource, fully utilizing required and also some optional
parameters. Avoid any hardcoded values within the module to support full configurability
from the root level.
- Required parameters should cover the essentials for creating {input.base_config}, while
optional parameters should provide a range of additional settings that enable more
granular configuration if desired.
- Configures the resource for {input.base_config} with this logic:
- If {input.base_config} is an AWS resource, use all required parameters for it based on
the terraform aws provider. be careful to avoid creating any other resources from aws
and any other providers alongside {input.base_config}. just define {input.base_config}
- If {input.base_config} == 'docker_container':
- Use only the following parameters and avoid using any other parameters:
- 1. image (type: string): Specifies the container image.
- 2. name (type: string): Sets the container name.
- 3. hostname (type: string): Configures the container hostname.
- 4. restart (type: string): Defines the container's restart policy (e.g., always, on-failure, no).
- If {input.base_config} == 'docker_image':
- Use only the following parameters and avoid using any other parameters and also create docker_container resource based on the docker image you create:
- 1. name (type: string): Specifies the image name.
- 2. force_remove (type: boolean): Determines whether to forcibly remove intermediate containers.
- 3. build (block type): Includes the following required field:
- context (type: string, required): Specifies the build context for the image.
- tag(type: List of Strings, required): Specifices the image tag in the
'name:tag' format, (e.g., ["NAME:VERSION"])
- If {input.base_config} == 'docker_image', The image parameter in docker_container
must dynamically references just like the following pattern:
```
resource "docker_container" "<DOCKER_CONTAINER_RESOURCE_NAME>" {{
image = docker_image.<DOCKER_IMAGE_RESOURCE_NAME>.name
}}
```
- Avoid any hardcoded values within the module to support full configurability from the root level.
- variables.tf:
- Lists all variables necessary for configuring {input.base_config}, with descriptions and
types specified to improve usability. No default values should be set here unless
Expand All @@ -121,10 +137,6 @@ def IaC_template_generator(input : IaCTemplateGeneration) -> str:
}}
}}
}}
- outputs.tf:
- Specifies outputs for the {input.base_config} resource, selecting relevant data that users
might need to access from the root level. Each output should have an informative
description, so users can understand its purpose and utility.
Ensure this project structure supports {input.base_config}’s configurability, extensibility, and
reusability across diverse Terraform providers, empowering users to manage their resources through a
single, customizable root configuration while keeping module internals robustly modular.
Expand Down
Loading