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

Clone a resource from a data source #35431

Open
alexgagnon opened this issue Jul 5, 2024 · 2 comments
Open

Clone a resource from a data source #35431

alexgagnon opened this issue Jul 5, 2024 · 2 comments
Labels
enhancement new new issue not yet triaged

Comments

@alexgagnon
Copy link

alexgagnon commented Jul 5, 2024

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:

  • extend the current configuration to have variables that allow for creating just the minimal set of resources for smoke testing, however this significantly increases the complexity of the configuration
  • create a separate config, however this has high risk of drift without significant effort to maintain parity between the configurations
  • use terraform remote state, however as mentioned above it's split across many different state files so can be difficult to maintain the integrations between them
  • use data resources to pull in a resources attributes and then create a new resource using the data attributes as values, seems to solve most of the issues, but some syntactic sugar might make this easier

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
Copy link
Member

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

@tombuildsstuff tombuildsstuff transferred this issue from hashicorp/terraform-provider-azurerm Jul 8, 2024
@crw
Copy link
Collaborator

crw commented Jul 8, 2024

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!

@crw crw added enhancement new new issue not yet triaged labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants