Skip to content
Draft
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions engines/terraform/outputs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package terraform

import (
"github.com/aws/jsii-runtime-go"
"github.com/hashicorp/terraform-cdk-go/cdktf"
)

func (td *TerraformDeployment) createOutputs() {
for name, module := range td.terraformResources {
td.createOutputsForModule(name, module)
}

for name, module := range td.terraformInfraResources {
td.createOutputsForModule(name, module)
}
}

func (td *TerraformDeployment) createOutputsForModule(name string, module cdktf.TerraformHclModule) {
cdktf.NewTerraformOutput(td.stack, jsii.Sprintf("%s_outputs", name), &cdktf.TerraformOutputConfig{
Copy link
Member Author

Choose a reason for hiding this comment

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

Currently outputs are scoped to <resource_name>_outputs, but this can possibly just be resource_name?

Copy link
Member

Choose a reason for hiding this comment

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

I think the _outputs is redundant and most modules and examples don't use it.

Value: module,
})
}
3 changes: 3 additions & 0 deletions engines/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ func (e *TerraformEngine) Apply(appSpec *app_spec_schema.Application) (result st
}
}

// Create outputs for all resources
tfDeployment.createOutputs()

tfDeployment.Synth()

return filepath.Join(e.outputDir, "stacks", appSpec.Name), nil
Expand Down