0

Edit Terraform

by
Published Oct 17, 2025
Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit Terraform
4
 *
5
 */
6
export async function main(auth: RT.Qovery, terraformId: string, body: TerraformRequest) {
7
	const url = new URL(`https://api.qovery.com/terraform/${terraformId}`)
8

9
	const response = await fetch(url, {
10
		method: 'PUT',
11
		headers: {
12
			'Content-Type': 'application/json',
13
			Authorization: 'Token ' + auth.apiKey
14
		},
15
		body: JSON.stringify(body)
16
	})
17
	if (!response.ok) {
18
		const text = await response.text()
19
		throw new Error(`${response.status} ${text}`)
20
	}
21
	return await response.json()
22
}
23

24
/* eslint-disable */
25
/**
26
 * This file was automatically generated by json-schema-to-typescript.
27
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
28
 * and run json-schema-to-typescript to regenerate this file.
29
 */
30

31
export interface TerraformRequest {
32
	name: string
33
	description: string
34
	auto_deploy: boolean
35
	terraform_files_source: {
36
		git_repository?: TerraformGitRepositoryRequest
37
		[k: string]: unknown
38
	}
39
	terraform_variables_source: TerraformVariablesSourceRequest
40
	/**
41
	 * Configuration for Terraform backend - exactly one backend type must be specified
42
	 */
43
	backend:
44
		| {
45
				/**
46
				 * Kubernetes-specific backend configuration
47
				 */
48
				kubernetes: {
49
					[k: string]: unknown
50
				}
51
				[k: string]: unknown
52
		  }
53
		| {
54
				/**
55
				 * User-provided backend configuration
56
				 */
57
				user_provided: {
58
					[k: string]: unknown
59
				}
60
				[k: string]: unknown
61
		  }
62
	provider: 'TERRAFORM'
63
	provider_version: TerraformProviderVersion
64
	timeout_sec?: number
65
	icon_uri?: string
66
	job_resources: TerraformRequestJobResources
67
	use_cluster_credentials?: boolean
68
	/**
69
	 * The key represent the action command name i.e: "plan"
70
	 * The value represent the extra arguments to pass to this command
71
	 *
72
	 * i.e: {"apply", ["-lock=false"]} is going to prepend `-lock=false` to terraform apply commands
73
	 */
74
	action_extra_arguments?: {
75
		[k: string]: string[]
76
	}
77
	[k: string]: unknown
78
}
79
export interface TerraformGitRepositoryRequest {
80
	url: string
81
	branch?: string
82
	root_path?: string
83
	git_token_id?: string
84
	[k: string]: unknown
85
}
86
export interface TerraformVariablesSourceRequest {
87
	tf_var_file_paths: string[]
88
	tf_vars: TerraformVarKeyValue[]
89
	[k: string]: unknown
90
}
91
/**
92
 * A Terraform input variable
93
 */
94
export interface TerraformVarKeyValue {
95
	key?: string
96
	value?: string
97
	secret?: boolean
98
	[k: string]: unknown
99
}
100
export interface TerraformProviderVersion {
101
	read_from_terraform_block?: boolean
102
	explicit_version: string
103
	[k: string]: unknown
104
}
105
export interface TerraformRequestJobResources {
106
	cpu_milli: number
107
	ram_mib: number
108
	gpu: number
109
	storage_gib: number
110
	[k: string]: unknown
111
}
112