Skip to content

[FEAT]: Support for terraform query #2955

@SamW94

Description

@SamW94

Describe the need

Hello!

In Terraform version 1.14 the terraform query command was introduced. This command executes list operations against existing infrastructure and displays the results. The command can optionally generate configuration for importing results into Terraform.

Currently this does not work for GitHub resources defined in the provider presumably because list resources are not supported.

Example import.tfquery.hcl file

list "github_membership" "org_owner" {
    provider = github
    config {
        username = "one-cool-user"
        role     = "admin"
    }
}

terraform query command output

terraform query
╷
│ Error: Invalid list resource
│ 
│   on import.tfquery.hcl line 1, in list "github_membership" "org_owner":
│    1: list "github_membership" "org_owner" {
│ 
│ The provider integrations/github does not support list resource "github_membership".

Is there a plan to implement this functionality? Currently, users will need to use the terraform import command repeatedly. Potentially for thousands of resources if they're trying to import a large GitHub ecosystem to Terraform.

Reference HashiCorp documentation: https://developer.hashicorp.com/terraform/language/v1.14.x/import/bulk

Thanks for the great work!
Sam

SDK Version

No response

API Version

No response

Relevant log output

### Example import.tfquery.hcl file


list "github_membership" "org_owner" {
    provider = github
    config {
        username = "one-cool-user"
        role     = "admin"
    }
}


### `terraform query` command output


terraform query
╷
│ Error: Invalid list resource
│ 
│   on import.tfquery.hcl line 1, in list "github_membership" "org_owner":
│    1: list "github_membership" "org_owner" {
│ 
│ The provider integrations/github does not support list resource "github_membership".

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: BlockedSome technical or requirement is blocking the issueStatus: TriageThis is being looked at and prioritizedType: FeatureNew feature or request

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions