Skip to content

Add ability to query single Terraform State

Emily Ring requested to merge 291140-query-single-state into master

What does this MR do?

Our GraphQL currently has a way to query a list of terraformStates, but we are missing the option to query one terraformState.

This MR wil add the following query to GraphQL

project(fullPath: "project_path") {
  terraformState(name: "name") {
    ...
  }
}

SQL for Terraform::StatesFinder.new(project, current_user, params: { name: 'test'}).execute

SELECT "terraform_states".* FROM "terraform_states" WHERE "terraform_states"."project_id" = 278964 AND "terraform_states"."name" = 'test' ORDER BY "terraform_states"."name" ASC

QUERY PLAN
Index Scan using index_terraform_states_on_project_id_and_name on public.terraform_states  (cost=0.28..3.30 rows=1 width=177) (actual time=2.000..2.001 rows=0 loops=1)
   Index Cond: ((terraform_states.project_id = 278964) AND ((terraform_states.name)::text = 'test'::text))
   Buffers: shared hit=3 read=2
   I/O Timings: read=1.965

Screenshots (strongly suggested)

state

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #291140

Edited by Emily Ring

Merge request reports