hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.35k stars 9.49k forks source link

Clone a resource from a data source #35431

Open alexgagnon opened 2 months ago

alexgagnon commented 2 months ago

Description

Use case:

We have a complex terraform setup with many state files and modules spread across multiple repositories. We're trying to create a minimal subset of the infrastructure to use for application smoke testing

Options:

Proposal:

Make it easy to 'clone' a resource, overriding specific arguments (i.e. to avoid naming collisions)

I'm not sure if this is even possible as it would require knowing the resource type, but the intention is to essentially first perform a data lookup of the source, expand it into the equivalent resource type, map the fetched attributes to the arguments, but override the ones specified in the override block.

New or Affected Resource(s)/Data Source(s)

azurerm_clone

Potential Terraform Configuration

resource "azurerm_clone" "name" {
  resource_id = <...>
  override {
    ...
  }
}

References

No response

tombuildsstuff commented 2 months ago

Transferring this to hashicorp/terraform since this is more a feature request for Terraform Core than something specific to the AzureRM Provider

crw commented 2 months ago

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!