Skip to content

Add GraphQL for Terraform States

Alex Ives requested to merge alexives/220956/tf_state_replication_graphql into master

What does this MR do?

- Add terraform state registry finder
- Add terraform state resolver
- Add terraform state registry type
- Use package_file specific feature flag for it's graphql endpoint

Relates to #220956 (closed)

Database

Since terraform_state_registry doesn't exist on the primary (it's in the geo secondary tracking database), so you won't be able to run an explain on this in #database-lab

At any rate, here's the added query:

SELECT "terraform_state_registry".* FROM "terraform_state_registry" ORDER BY "terraform_state_registry"."id" ASC

And here's an explain plan I ran locally:

Index Scan using terraform_state_registry_pkey on terraform_state_registry  (cost=0.15..55.85 rows=780 width=76)

And if :ids are provided in params (example was 10, 100, and 1000 because I'm lazy):

SELECT "terraform_state_registry".* FROM "terraform_state_registry" WHERE "terraform_state_registry"."id" IN (10, 100, 1000) ORDER BY "terraform_state_registry"."id" ASC

And I guess this is the explain for that (also local):

 Sort  (cost=11.61..11.62 rows=3 width=76)
   Sort Key: id
   ->  Bitmap Heap Scan on terraform_state_registry  (cost=4.47..11.58 rows=3 width=76)
         Recheck Cond: (id = ANY ('{10,100,1000}'::bigint[]))
         ->  Bitmap Index Scan on terraform_state_registry_pkey  (cost=0.00..4.47 rows=3 width=0)
               Index Cond: (id = ANY ('{10,100,1000}'::bigint[]))

If you feel that it would be useful to see this run in staging, that might be able to be arranged. At the moment, even if I could figure out how to do that, there would be 0 rows since we don't have any replicated terraform states there yet. 😁

Screenshots

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
Edited by Alex Ives

Merge request reports