gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.06k stars 979 forks source link

Store module outputs as SSM parameters #3448

Closed p5 closed 1 month ago

p5 commented 1 month ago

Describe the enhancement

A built-in way to store native OpenTofu/Terraform outputs as AWS SSM parameters so they can be shared with other systems, such as Serverless Framework or AWS CDK.

According to the OpenTofu docs, there are some common ways to share data between different pieces of infrastructure, including DNS records, S3 objects and SSM parameters. It would be great if Terragrunt could be configured to store select module outputs as SSM parameters so we can use off-the-shelf modules (like terraform-aws-vpc or the Gruntwork ones) along with other IaC tooling.

Right now, I am needing to wrap most OpenTofu modules inside my own custom module to simply add aws_ssm_parameter resources for data commonly used by other tools. Examples include MSK broker URLs, VPC IDs and many more.

Additional context

I have not considered the interface that this would be exposed as. Perhaps as a top-level option such as:

outputs {
    backend = "ssm"
    outputs = {
        "/SHARED/VPC/ID"            = outputs.vpc_id,       // module outputs
        "/PLATFORM/DEFAULT_REGION"  = locals.aws_region,    // terragrunt locals
    }
}

Behind the scenes, it could either use AWS SDK or generate the required aws_ssm_parameter resources.

PoC (Proof of Concept)

N/A

RFC Not Needed

yhakbar commented 1 month ago

Hey @p5 ,

I like this idea, and think it could be cool. I'm not sure how the interface would look either. If possible, please create an RFC to propose a full design for it, including how other units (terragrunt.hcl files) would read in those values.

For what it's worth, I wouldn't think of this as "outputs", as it doesn't deal with the output that users get when running terragrunt output via tofu/terraform output. There may be a different name for this like "data store" or something. I'm not sure what that name should be.

I'm going to mark this enhancement as needs-design and preserved to encourage others to chime in with design ideas and to ensure it doesn't go stale if it takes a while.

p5 commented 1 month ago

RFC: #3449

yhakbar commented 1 month ago

Closing this issue to focus attention on the RFC.