Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

fix(engines): injects suga variable into infrastructure modules#103

Closed
raksiv wants to merge 1 commit intomainfrom
NIT-379
Closed

fix(engines): injects suga variable into infrastructure modules#103
raksiv wants to merge 1 commit intomainfrom
NIT-379

Conversation

@raksiv
Copy link
Copy Markdown
Member

@raksiv raksiv commented Oct 2, 2025

Adds the suga variable containing infrastructure name and stack ID to the Terraform module configuration.

Required to create unique names for these resources in their respective terraform module implementations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 2, 2025

📝 Walkthrough

Walkthrough

resolveInfraResource in engines/terraform/deployment.go now creates a local sugaVar map containing only "stack_id" set to td.stackId.Result(). This sugaVar is assigned into the TerraformHclModuleConfig Variables field under the key "suga", causing the infra module initialization to receive per-infra stack metadata during resolution.

Suggested reviewers

  • jyecusch

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the injection of the new `suga` variable into infrastructure modules, matching the core change in the PR.
Description Check ✅ Passed The description clearly explains adding the `suga` variable with stack metadata to Terraform module configurations and its purpose for unique resource names, aligning with the implemented changes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddc5afe and 6f316ba.

📒 Files selected for processing (1)
  • engines/terraform/deployment.go (1 hunks)
🔇 Additional comments (1)
engines/terraform/deployment.go (1)

76-84: Add missing name field to suga for consistency.

Other usages of suga include both name and stack_id. Although no references to var.suga.name were found in Terraform modules, update the map to match the pattern:

 sugaVar := map[string]any{
+  "name":     infraName,
   "stack_id": td.stackId.Result(),
 }

Manually verify downstream modules accept this new input.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

raksiv added a commit to raksiv/plugins-aws that referenced this pull request Oct 2, 2025
resources updated - fargate, lambda, loadbalancer, vpc
relies on - nitrictech/monk#103 which injects the stack_id
raksiv added a commit to raksiv/plugins-aws that referenced this pull request Oct 2, 2025
resources updated - fargate, lambda, loadbalancer, vpc, cloudfront
relies on - nitrictech/monk#103 which injects the stack_id
Adds the `suga` variable containing infrastructure name and stack ID to the Terraform module configuration.

Required to create unique names for these resources in the Terraform.
raksiv added a commit to raksiv/plugins-aws that referenced this pull request Oct 2, 2025
resources updated - fargate, lambda, loadbalancer, vpc, cloudfront
relies on - nitrictech/monk#103 which injects the stack_id
raksiv added a commit to raksiv/plugins-aws that referenced this pull request Oct 2, 2025
resources updated - fargate, lambda, loadbalancer, vpc, cloudfront
relies on - nitrictech/monk#103 which injects the stack_id
raksiv added a commit to raksiv/plugins-aws that referenced this pull request Oct 6, 2025
resources updated - fargate, lambda, loadbalancer, vpc, cloudfront, security group
relies on - nitrictech/monk#103 which injects the stack_id
@raksiv raksiv self-assigned this Oct 6, 2025
@raksiv raksiv added the bug Something isn't working label Oct 6, 2025
@tjholm tjholm added enhancement New feature or request and removed bug Something isn't working labels Oct 6, 2025
Comment on lines +76 to 86
sugaVar := map[string]any{
"stack_id": td.stackId.Result(),
}

td.terraformInfraResources[infraName] = cdktf.NewTerraformHclModule(td.stack, jsii.String(infraName), &cdktf.TerraformHclModuleConfig{
Source: jsii.String(pluginRef.Deployment.Terraform),
Variables: &map[string]interface{}{
"suga": sugaVar,
},
})
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally the idea behind not including this was to allow any existing terraform module to be made into infra modules without any additional HCL wrapping. As far as unique naming goes at the moment this can be delegated to SREs (or whoever is performing the apply) by forwarding the name using variables.

Not saying we don't include this by the way, just sharing the original thinking behind not including suga vars for infra.

Copy link
Copy Markdown
Member Author

@raksiv raksiv Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeh lets discuss, I knew that the original intent was to keep suga specific things out of the infra modules - but its not possible to deploy multiple projects that use the same platform config.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could create variables in the default platforms that accept a prefix?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, that would be the way to do it currently, could potentially use a few variables as well. e.g.
${var.project_name}-${var.environment_name}-vpc as an example. Built-in variables are also possible.

e.g. ${var.project_name}-${terraform.workspace}, although it might be better to default for those rather than make an assumption i.e. var.environment_name == terraform.workspace as a potential default.

@raksiv
Copy link
Copy Markdown
Member Author

raksiv commented Oct 6, 2025

Okay, I'll pull these and update my platform to use variables.

@raksiv raksiv closed this Oct 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants