@unstablestudios/terraform 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +312 -0
  2. package/dist/config/backend.d.ts +118 -0
  3. package/dist/config/backend.d.ts.map +1 -0
  4. package/dist/config/backend.js +153 -0
  5. package/dist/config/backend.js.map +1 -0
  6. package/dist/config/index.d.ts +6 -0
  7. package/dist/config/index.d.ts.map +1 -0
  8. package/dist/config/index.js +4 -0
  9. package/dist/config/index.js.map +1 -0
  10. package/dist/config/terraform.d.ts +157 -0
  11. package/dist/config/terraform.d.ts.map +1 -0
  12. package/dist/config/terraform.js +211 -0
  13. package/dist/config/terraform.js.map +1 -0
  14. package/dist/config/terraform.test.d.ts +2 -0
  15. package/dist/config/terraform.test.d.ts.map +1 -0
  16. package/dist/config/terraform.test.js +240 -0
  17. package/dist/config/terraform.test.js.map +1 -0
  18. package/dist/config/tfvars.d.ts +90 -0
  19. package/dist/config/tfvars.d.ts.map +1 -0
  20. package/dist/config/tfvars.js +133 -0
  21. package/dist/config/tfvars.js.map +1 -0
  22. package/dist/config/tfvars.test.d.ts +2 -0
  23. package/dist/config/tfvars.test.d.ts.map +1 -0
  24. package/dist/config/tfvars.test.js +187 -0
  25. package/dist/config/tfvars.test.js.map +1 -0
  26. package/dist/hcl/generator.d.ts +59 -0
  27. package/dist/hcl/generator.d.ts.map +1 -0
  28. package/dist/hcl/generator.js +401 -0
  29. package/dist/hcl/generator.js.map +1 -0
  30. package/dist/hcl/generator.test.d.ts +2 -0
  31. package/dist/hcl/generator.test.d.ts.map +1 -0
  32. package/dist/hcl/generator.test.js +280 -0
  33. package/dist/hcl/generator.test.js.map +1 -0
  34. package/dist/hcl/index.d.ts +5 -0
  35. package/dist/hcl/index.d.ts.map +1 -0
  36. package/dist/hcl/index.js +3 -0
  37. package/dist/hcl/index.js.map +1 -0
  38. package/dist/hcl/writer.d.ts +35 -0
  39. package/dist/hcl/writer.d.ts.map +1 -0
  40. package/dist/hcl/writer.js +154 -0
  41. package/dist/hcl/writer.js.map +1 -0
  42. package/dist/index.d.mts +970 -0
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +9 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/index.mjs +1283 -0
  48. package/dist/modules/cloudflare/d1.d.ts +39 -0
  49. package/dist/modules/cloudflare/d1.d.ts.map +1 -0
  50. package/dist/modules/cloudflare/d1.js +55 -0
  51. package/dist/modules/cloudflare/d1.js.map +1 -0
  52. package/dist/modules/cloudflare/index.d.ts +43 -0
  53. package/dist/modules/cloudflare/index.d.ts.map +1 -0
  54. package/dist/modules/cloudflare/index.js +44 -0
  55. package/dist/modules/cloudflare/index.js.map +1 -0
  56. package/dist/modules/cloudflare/kv.d.ts +57 -0
  57. package/dist/modules/cloudflare/kv.d.ts.map +1 -0
  58. package/dist/modules/cloudflare/kv.js +75 -0
  59. package/dist/modules/cloudflare/kv.js.map +1 -0
  60. package/dist/modules/cloudflare/r2.d.ts +49 -0
  61. package/dist/modules/cloudflare/r2.d.ts.map +1 -0
  62. package/dist/modules/cloudflare/r2.js +70 -0
  63. package/dist/modules/cloudflare/r2.js.map +1 -0
  64. package/dist/modules/cloudflare/worker.d.ts +104 -0
  65. package/dist/modules/cloudflare/worker.d.ts.map +1 -0
  66. package/dist/modules/cloudflare/worker.js +128 -0
  67. package/dist/modules/cloudflare/worker.js.map +1 -0
  68. package/dist/modules/index.d.ts +4 -0
  69. package/dist/modules/index.d.ts.map +1 -0
  70. package/dist/modules/index.js +4 -0
  71. package/dist/modules/index.js.map +1 -0
  72. package/dist/modules/types.d.ts +97 -0
  73. package/dist/modules/types.d.ts.map +1 -0
  74. package/dist/modules/types.js +106 -0
  75. package/dist/modules/types.js.map +1 -0
  76. package/dist/modules/types.test.d.ts +2 -0
  77. package/dist/modules/types.test.d.ts.map +1 -0
  78. package/dist/modules/types.test.js +167 -0
  79. package/dist/modules/types.test.js.map +1 -0
  80. package/dist/types/config.d.ts +140 -0
  81. package/dist/types/config.d.ts.map +1 -0
  82. package/dist/types/config.js +16 -0
  83. package/dist/types/config.js.map +1 -0
  84. package/dist/types/config.test.d.ts +2 -0
  85. package/dist/types/config.test.d.ts.map +1 -0
  86. package/dist/types/config.test.js +36 -0
  87. package/dist/types/config.test.js.map +1 -0
  88. package/dist/types/index.d.ts +2 -0
  89. package/dist/types/index.d.ts.map +1 -0
  90. package/dist/types/index.js +2 -0
  91. package/dist/types/index.js.map +1 -0
  92. package/package.json +27 -0
@@ -0,0 +1,970 @@
1
+ /**
2
+ * Terraform value types that can be serialized to HCL
3
+ */
4
+ type HclValue = string | number | boolean | null | HclValue[] | {
5
+ [key: string]: HclValue;
6
+ } | HclExpression;
7
+ /**
8
+ * Raw HCL expression (not quoted in output)
9
+ */
10
+ interface HclExpression {
11
+ __hclExpression: true;
12
+ value: string;
13
+ }
14
+ /**
15
+ * Create a raw HCL expression
16
+ */
17
+ declare function expr(value: string): HclExpression;
18
+ /**
19
+ * Check if a value is an HCL expression
20
+ */
21
+ declare function isHclExpression(value: unknown): value is HclExpression;
22
+ /**
23
+ * Terraform block type
24
+ */
25
+ type BlockType = 'terraform' | 'provider' | 'resource' | 'data' | 'variable' | 'output' | 'locals' | 'module';
26
+ /**
27
+ * Terraform block definition
28
+ */
29
+ interface TerraformBlock {
30
+ type: BlockType;
31
+ labels: string[];
32
+ body: Record<string, HclValue>;
33
+ nestedBlocks?: TerraformBlock[];
34
+ }
35
+ /**
36
+ * Terraform variable definition
37
+ */
38
+ interface VariableConfig {
39
+ type?: string;
40
+ description?: string;
41
+ default?: HclValue;
42
+ sensitive?: boolean;
43
+ nullable?: boolean;
44
+ validation?: {
45
+ condition: HclExpression;
46
+ error_message: string;
47
+ };
48
+ }
49
+ /**
50
+ * Terraform output definition
51
+ */
52
+ interface OutputConfig {
53
+ value: HclValue;
54
+ description?: string;
55
+ sensitive?: boolean;
56
+ depends_on?: HclExpression[];
57
+ }
58
+ /**
59
+ * Terraform provider configuration
60
+ */
61
+ interface ProviderConfig {
62
+ provider: string;
63
+ alias?: string;
64
+ config: Record<string, HclValue>;
65
+ }
66
+ /**
67
+ * Terraform backend configuration
68
+ */
69
+ interface BackendConfig {
70
+ type: string;
71
+ config: Record<string, HclValue>;
72
+ }
73
+ /**
74
+ * Terraform required providers configuration
75
+ */
76
+ interface RequiredProvider {
77
+ source: string;
78
+ version?: string;
79
+ }
80
+ /**
81
+ * Terraform resource configuration
82
+ */
83
+ interface ResourceConfig {
84
+ type: string;
85
+ name: string;
86
+ config: Record<string, HclValue>;
87
+ depends_on?: HclExpression[];
88
+ count?: HclValue;
89
+ for_each?: HclValue;
90
+ provider?: HclExpression;
91
+ lifecycle?: {
92
+ create_before_destroy?: boolean;
93
+ prevent_destroy?: boolean;
94
+ ignore_changes?: HclExpression;
95
+ replace_triggered_by?: HclExpression[];
96
+ };
97
+ }
98
+ /**
99
+ * Terraform data source configuration
100
+ */
101
+ interface DataSourceConfig {
102
+ type: string;
103
+ name: string;
104
+ config: Record<string, HclValue>;
105
+ depends_on?: HclExpression[];
106
+ count?: HclValue;
107
+ for_each?: HclValue;
108
+ provider?: HclExpression;
109
+ }
110
+ /**
111
+ * Module configuration
112
+ */
113
+ interface ModuleConfig {
114
+ name: string;
115
+ source: string;
116
+ version?: string;
117
+ config: Record<string, HclValue>;
118
+ depends_on?: HclExpression[];
119
+ count?: HclValue;
120
+ for_each?: HclValue;
121
+ providers?: Record<string, HclExpression>;
122
+ }
123
+ /**
124
+ * Complete Terraform configuration
125
+ */
126
+ interface TerraformConfig {
127
+ terraform?: {
128
+ required_version?: string;
129
+ required_providers?: Record<string, RequiredProvider>;
130
+ backend?: BackendConfig;
131
+ };
132
+ providers?: ProviderConfig[];
133
+ variables?: Record<string, VariableConfig>;
134
+ locals?: Record<string, HclValue>;
135
+ resources?: ResourceConfig[];
136
+ dataSources?: DataSourceConfig[];
137
+ modules?: ModuleConfig[];
138
+ outputs?: Record<string, OutputConfig>;
139
+ }
140
+
141
+ /**
142
+ * Options for HCL generation
143
+ */
144
+ interface HclOptions {
145
+ /** Indentation string (default: 2 spaces) */
146
+ indent?: string;
147
+ /** Whether to include empty values (default: false) */
148
+ includeEmpty?: boolean;
149
+ }
150
+ /**
151
+ * Convert a value to HCL string representation
152
+ */
153
+ declare function toHcl(value: HclValue, options?: HclOptions): string;
154
+ /**
155
+ * Format a block with labels
156
+ */
157
+ declare function formatBlock(block: TerraformBlock, options?: HclOptions): string;
158
+ /**
159
+ * Generate variable block
160
+ */
161
+ declare function generateVariable(name: string, config: VariableConfig, opts?: HclOptions): string;
162
+ /**
163
+ * Generate output block
164
+ */
165
+ declare function generateOutput(name: string, config: OutputConfig, opts?: HclOptions): string;
166
+ /**
167
+ * Generate provider block
168
+ */
169
+ declare function generateProvider(config: ProviderConfig, opts?: HclOptions): string;
170
+ /**
171
+ * Generate resource block
172
+ */
173
+ declare function generateResource(config: ResourceConfig, opts?: HclOptions): string;
174
+ /**
175
+ * Generate data source block
176
+ */
177
+ declare function generateDataSource(config: DataSourceConfig, opts?: HclOptions): string;
178
+ /**
179
+ * Generate module block
180
+ */
181
+ declare function generateModule(config: ModuleConfig, opts?: HclOptions): string;
182
+ /**
183
+ * Generate locals block
184
+ */
185
+ declare function generateLocals(locals: Record<string, HclValue>, opts?: HclOptions): string;
186
+ /**
187
+ * Generate terraform block (required_version, required_providers, backend)
188
+ */
189
+ declare function generateTerraformBlock(config: {
190
+ required_version?: string;
191
+ required_providers?: Record<string, RequiredProvider>;
192
+ backend?: BackendConfig;
193
+ }, opts?: HclOptions): string;
194
+ /**
195
+ * Generate complete Terraform configuration
196
+ */
197
+ declare function generateTerraformConfig(config: TerraformConfig, opts?: HclOptions): string;
198
+
199
+ /**
200
+ * Result of writing terraform files
201
+ */
202
+ interface WriteResult {
203
+ path: string;
204
+ content: string;
205
+ }
206
+ /**
207
+ * Options for writing terraform files
208
+ */
209
+ interface WriteOptions extends HclOptions {
210
+ /** Add header comment to generated files */
211
+ header?: string;
212
+ /** File extension (default: .tf) */
213
+ extension?: string;
214
+ }
215
+ /**
216
+ * Generate terraform file content from config
217
+ */
218
+ declare function generateTerraformFile(config: TerraformConfig, options?: WriteOptions): string;
219
+ /**
220
+ * Generate multiple terraform files (e.g., main.tf, variables.tf, outputs.tf)
221
+ */
222
+ declare function generateTerraformFiles(config: TerraformConfig, options?: WriteOptions): WriteResult[];
223
+ /**
224
+ * Create a terraform file writer that can be used with a file system
225
+ */
226
+ declare function createFileWriter(writeFile: (path: string, content: string) => Promise<void>): (results: WriteResult[], basePath?: string) => Promise<void>;
227
+ /**
228
+ * Format content for a specific purpose (e.g., tfvars)
229
+ */
230
+ declare function formatForTfvars(values: Record<string, unknown>): string;
231
+
232
+ /**
233
+ * Builder for creating Terraform configurations
234
+ */
235
+ declare class TerraformConfigBuilder {
236
+ private config;
237
+ /**
238
+ * Set required Terraform version
239
+ */
240
+ requiredVersion(version: string): this;
241
+ /**
242
+ * Add a required provider
243
+ */
244
+ requiredProvider(name: string, provider: RequiredProvider): this;
245
+ /**
246
+ * Set backend configuration
247
+ */
248
+ backend(backend: BackendConfig): this;
249
+ /**
250
+ * Add a provider configuration
251
+ */
252
+ provider(provider: string, config?: Record<string, HclValue>, alias?: string): this;
253
+ /**
254
+ * Add a variable
255
+ */
256
+ variable(name: string, type: string, options?: {
257
+ description?: string;
258
+ default?: HclValue;
259
+ sensitive?: boolean;
260
+ }): this;
261
+ /**
262
+ * Add locals
263
+ */
264
+ locals(values: Record<string, HclValue>): this;
265
+ /**
266
+ * Add a resource
267
+ */
268
+ resource(type: string, name: string, config: Record<string, HclValue>): this;
269
+ /**
270
+ * Add a data source
271
+ */
272
+ data(type: string, name: string, config: Record<string, HclValue>): this;
273
+ /**
274
+ * Add a module
275
+ */
276
+ module(name: string, source: string, config?: Record<string, HclValue>, version?: string): this;
277
+ /**
278
+ * Add an output
279
+ */
280
+ output(name: string, value: HclValue, options?: {
281
+ description?: string;
282
+ sensitive?: boolean;
283
+ }): this;
284
+ /**
285
+ * Get the built configuration
286
+ */
287
+ build(): TerraformConfig;
288
+ /**
289
+ * Generate HCL string
290
+ */
291
+ toHcl(options?: HclOptions): string;
292
+ }
293
+ /**
294
+ * Create a new Terraform configuration builder
295
+ */
296
+ declare function terraform(): TerraformConfigBuilder;
297
+ /**
298
+ * Common backend configurations
299
+ */
300
+ declare const backends: {
301
+ /**
302
+ * S3 backend configuration
303
+ */
304
+ s3: (config: {
305
+ bucket: string;
306
+ key: string;
307
+ region: string;
308
+ encrypt?: boolean;
309
+ dynamodb_table?: string;
310
+ }) => BackendConfig;
311
+ /**
312
+ * GCS backend configuration
313
+ */
314
+ gcs: (config: {
315
+ bucket: string;
316
+ prefix: string;
317
+ }) => BackendConfig;
318
+ /**
319
+ * Azure backend configuration
320
+ */
321
+ azurerm: (config: {
322
+ resource_group_name: string;
323
+ storage_account_name: string;
324
+ container_name: string;
325
+ key: string;
326
+ }) => BackendConfig;
327
+ /**
328
+ * Local backend configuration
329
+ */
330
+ local: (path?: string) => BackendConfig;
331
+ /**
332
+ * Terraform Cloud backend configuration
333
+ */
334
+ cloud: (config: {
335
+ organization: string;
336
+ workspaces: {
337
+ name: string;
338
+ };
339
+ }) => BackendConfig;
340
+ };
341
+ /**
342
+ * Common provider configurations
343
+ */
344
+ declare const providers: {
345
+ /**
346
+ * AWS provider
347
+ */
348
+ aws: (region: string, profile?: string) => {
349
+ provider: string;
350
+ config: {
351
+ profile?: string | undefined;
352
+ region: string;
353
+ };
354
+ };
355
+ /**
356
+ * Cloudflare provider
357
+ */
358
+ cloudflare: (apiToken?: string) => {
359
+ provider: string;
360
+ config: {
361
+ api_token: string;
362
+ } | {
363
+ api_token?: undefined;
364
+ };
365
+ };
366
+ /**
367
+ * Google provider
368
+ */
369
+ google: (project: string, region: string) => {
370
+ provider: string;
371
+ config: {
372
+ project: string;
373
+ region: string;
374
+ };
375
+ };
376
+ /**
377
+ * Azure provider
378
+ */
379
+ azurerm: (features?: Record<string, HclValue>) => {
380
+ provider: string;
381
+ config: {
382
+ features: Record<string, HclValue>;
383
+ };
384
+ };
385
+ };
386
+
387
+ /**
388
+ * Tfvars file generator
389
+ */
390
+ interface TfvarsConfig {
391
+ /** Variable values */
392
+ values: Record<string, unknown>;
393
+ /** Optional header comment */
394
+ header?: string;
395
+ }
396
+ /**
397
+ * Generate a tfvars file content
398
+ */
399
+ declare function generateTfvars(config: TfvarsConfig): string;
400
+ /**
401
+ * Generate environment-specific tfvars
402
+ */
403
+ declare function generateEnvTfvars(environment: string, values: Record<string, unknown>, options?: {
404
+ header?: boolean;
405
+ }): {
406
+ filename: string;
407
+ content: string;
408
+ };
409
+ /**
410
+ * Builder for tfvars files
411
+ */
412
+ declare class TfvarsBuilder {
413
+ private values;
414
+ private header?;
415
+ /**
416
+ * Set header comment
417
+ */
418
+ withHeader(header: string): this;
419
+ /**
420
+ * Set a string variable
421
+ */
422
+ string(name: string, value: string): this;
423
+ /**
424
+ * Set a number variable
425
+ */
426
+ number(name: string, value: number): this;
427
+ /**
428
+ * Set a boolean variable
429
+ */
430
+ bool(name: string, value: boolean): this;
431
+ /**
432
+ * Set a list variable
433
+ */
434
+ list(name: string, value: unknown[]): this;
435
+ /**
436
+ * Set a map variable
437
+ */
438
+ map(name: string, value: Record<string, unknown>): this;
439
+ /**
440
+ * Set a variable of any type
441
+ */
442
+ set(name: string, value: unknown): this;
443
+ /**
444
+ * Set multiple variables at once
445
+ */
446
+ setAll(values: Record<string, unknown>): this;
447
+ /**
448
+ * Build the tfvars content
449
+ */
450
+ build(): string;
451
+ /**
452
+ * Get the values as an object
453
+ */
454
+ toObject(): Record<string, unknown>;
455
+ }
456
+ /**
457
+ * Create a new tfvars builder
458
+ */
459
+ declare function tfvars(): TfvarsBuilder;
460
+ /**
461
+ * Merge multiple tfvars into one
462
+ */
463
+ declare function mergeTfvars(...sources: Record<string, unknown>[]): Record<string, unknown>;
464
+ /**
465
+ * Create tfvars from environment variables
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * const vars = tfvarsFromEnv(
470
+ * { cloudflare_account_id: 'CF_ACCOUNT_ID' },
471
+ * process.env
472
+ * );
473
+ * ```
474
+ */
475
+ declare function tfvarsFromEnv(mapping: Record<string, string>, env: Record<string, string | undefined>): Record<string, unknown>;
476
+
477
+ /**
478
+ * Backend configuration builder
479
+ */
480
+ declare class BackendBuilder {
481
+ private type;
482
+ private config;
483
+ constructor(type: string);
484
+ /**
485
+ * Set a configuration option
486
+ */
487
+ set(key: string, value: HclValue): this;
488
+ /**
489
+ * Set multiple configuration options
490
+ */
491
+ setAll(config: Record<string, HclValue>): this;
492
+ /**
493
+ * Build the backend configuration
494
+ */
495
+ build(): BackendConfig;
496
+ }
497
+ /**
498
+ * Create a backend builder
499
+ */
500
+ declare function backend(type: string): BackendBuilder;
501
+ /**
502
+ * S3 backend builder with type-safe options
503
+ */
504
+ interface S3BackendOptions {
505
+ bucket: string;
506
+ key: string;
507
+ region: string;
508
+ encrypt?: boolean;
509
+ dynamodb_table?: string;
510
+ workspace_key_prefix?: string;
511
+ acl?: string;
512
+ skip_credentials_validation?: boolean;
513
+ skip_metadata_api_check?: boolean;
514
+ skip_region_validation?: boolean;
515
+ profile?: string;
516
+ role_arn?: string;
517
+ }
518
+ /**
519
+ * Create an S3 backend configuration
520
+ */
521
+ declare function s3Backend(options: S3BackendOptions): BackendConfig;
522
+ /**
523
+ * GCS backend options
524
+ */
525
+ interface GcsBackendOptions {
526
+ bucket: string;
527
+ prefix?: string;
528
+ credentials?: string;
529
+ encryption_key?: string;
530
+ }
531
+ /**
532
+ * Create a GCS backend configuration
533
+ */
534
+ declare function gcsBackend(options: GcsBackendOptions): BackendConfig;
535
+ /**
536
+ * Azure backend options
537
+ */
538
+ interface AzureBackendOptions {
539
+ resource_group_name: string;
540
+ storage_account_name: string;
541
+ container_name: string;
542
+ key: string;
543
+ access_key?: string;
544
+ sas_token?: string;
545
+ use_oidc?: boolean;
546
+ subscription_id?: string;
547
+ tenant_id?: string;
548
+ client_id?: string;
549
+ }
550
+ /**
551
+ * Create an Azure backend configuration
552
+ */
553
+ declare function azureBackend(options: AzureBackendOptions): BackendConfig;
554
+ /**
555
+ * Terraform Cloud backend options
556
+ */
557
+ interface TerraformCloudOptions {
558
+ organization: string;
559
+ workspaces: {
560
+ name: string;
561
+ } | {
562
+ tags: string[];
563
+ } | {
564
+ project: string;
565
+ };
566
+ hostname?: string;
567
+ token?: string;
568
+ }
569
+ /**
570
+ * Create a Terraform Cloud backend configuration
571
+ */
572
+ declare function terraformCloudBackend(options: TerraformCloudOptions): BackendConfig;
573
+ /**
574
+ * Create a local backend configuration
575
+ */
576
+ declare function localBackend(path?: string): BackendConfig;
577
+ /**
578
+ * Consul backend options
579
+ */
580
+ interface ConsulBackendOptions {
581
+ address: string;
582
+ path: string;
583
+ scheme?: 'http' | 'https';
584
+ datacenter?: string;
585
+ access_token?: string;
586
+ gzip?: boolean;
587
+ lock?: boolean;
588
+ }
589
+ /**
590
+ * Create a Consul backend configuration
591
+ */
592
+ declare function consulBackend(options: ConsulBackendOptions): BackendConfig;
593
+
594
+ /**
595
+ * Module definition with typed inputs and outputs
596
+ */
597
+ interface ModuleDefinition<TInputs extends Record<string, unknown> = Record<string, unknown>, TOutputs extends Record<string, string> = Record<string, string>> {
598
+ /** Module source (registry, git, local path) */
599
+ source: string;
600
+ /** Module version (for registry modules) */
601
+ version?: string;
602
+ /** Available input variables */
603
+ inputs: TInputs;
604
+ /** Available output attributes */
605
+ outputs: TOutputs;
606
+ }
607
+ /**
608
+ * Create a typed module instance
609
+ */
610
+ interface ModuleInstance<TOutputs extends Record<string, string>> {
611
+ /** Module name */
612
+ name: string;
613
+ /** Get an output reference */
614
+ output<K extends keyof TOutputs>(key: K): HclExpression;
615
+ /** Get the module configuration */
616
+ config: ModuleConfig;
617
+ }
618
+ /**
619
+ * Create a module definition
620
+ */
621
+ declare function defineModule<TInputs extends Record<string, unknown>, TOutputs extends Record<string, string>>(source: string, version?: string): ModuleDefinition<TInputs, TOutputs>;
622
+ /**
623
+ * Create a module instance from a definition
624
+ */
625
+ declare function useModule<TInputs extends Record<string, unknown>, TOutputs extends Record<string, string>>(definition: ModuleDefinition<TInputs, TOutputs>, name: string, inputs: Partial<TInputs>): ModuleInstance<TOutputs>;
626
+ /**
627
+ * Create a reference to a module output
628
+ */
629
+ declare function moduleOutput(moduleName: string, outputName: string): HclExpression;
630
+ /**
631
+ * Create a reference to a resource attribute
632
+ */
633
+ declare function resourceRef(type: string, name: string, attribute: string): HclExpression;
634
+ /**
635
+ * Create a reference to a data source attribute
636
+ */
637
+ declare function dataRef(type: string, name: string, attribute: string): HclExpression;
638
+ /**
639
+ * Create a reference to a variable
640
+ */
641
+ declare function varRef(name: string): HclExpression;
642
+ /**
643
+ * Create a reference to a local value
644
+ */
645
+ declare function localRef(name: string): HclExpression;
646
+ /**
647
+ * Common Terraform functions as expressions
648
+ */
649
+ declare const tf: {
650
+ /** file() function */
651
+ file: (path: string) => HclExpression;
652
+ /** templatefile() function */
653
+ templatefile: (path: string, vars: string) => HclExpression;
654
+ /** jsonencode() function */
655
+ jsonencode: (value: string) => HclExpression;
656
+ /** jsondecode() function */
657
+ jsondecode: (value: string) => HclExpression;
658
+ /** lookup() function */
659
+ lookup: (map: string, key: string, defaultValue?: string) => HclExpression;
660
+ /** element() function */
661
+ element: (list: string, index: number | string) => HclExpression;
662
+ /** length() function */
663
+ length: (value: string) => HclExpression;
664
+ /** coalesce() function */
665
+ coalesce: (...values: string[]) => HclExpression;
666
+ /** join() function */
667
+ join: (separator: string, list: string) => HclExpression;
668
+ /** split() function */
669
+ split: (separator: string, value: string) => HclExpression;
670
+ /** format() function */
671
+ format: (formatStr: string, ...args: string[]) => HclExpression;
672
+ /** each.key */
673
+ eachKey: HclExpression;
674
+ /** each.value */
675
+ eachValue: HclExpression;
676
+ /** count.index */
677
+ countIndex: HclExpression;
678
+ /** self reference */
679
+ self: (attribute: string) => HclExpression;
680
+ /** path.module */
681
+ pathModule: HclExpression;
682
+ /** path.root */
683
+ pathRoot: HclExpression;
684
+ /** path.cwd */
685
+ pathCwd: HclExpression;
686
+ /** terraform.workspace */
687
+ workspace: HclExpression;
688
+ };
689
+
690
+ /**
691
+ * Cloudflare Worker script configuration
692
+ */
693
+ interface WorkerScriptConfig {
694
+ /** Worker name */
695
+ name: string;
696
+ /** Account ID */
697
+ accountId: string | HclExpression;
698
+ /** Script content or path to script file */
699
+ content: string | HclExpression;
700
+ /** Module format (esm or service-worker) */
701
+ module?: boolean;
702
+ /** Compatibility date */
703
+ compatibilityDate?: string;
704
+ /** Compatibility flags */
705
+ compatibilityFlags?: string[];
706
+ /** Logpush enabled */
707
+ logpush?: boolean;
708
+ /** KV namespace bindings */
709
+ kvNamespaces?: WorkerKvBinding[];
710
+ /** D1 database bindings */
711
+ d1Databases?: WorkerD1Binding[];
712
+ /** R2 bucket bindings */
713
+ r2Buckets?: WorkerR2Binding[];
714
+ /** Environment variables (plain text) */
715
+ plainTextBindings?: Record<string, string>;
716
+ /** Secret bindings */
717
+ secretTextBindings?: Record<string, HclExpression>;
718
+ /** Service bindings */
719
+ serviceBindings?: WorkerServiceBinding[];
720
+ }
721
+ /**
722
+ * Worker KV namespace binding
723
+ */
724
+ interface WorkerKvBinding {
725
+ name: string;
726
+ namespaceId: string | HclExpression;
727
+ }
728
+ /**
729
+ * Worker D1 database binding
730
+ */
731
+ interface WorkerD1Binding {
732
+ name: string;
733
+ databaseId: string | HclExpression;
734
+ }
735
+ /**
736
+ * Worker R2 bucket binding
737
+ */
738
+ interface WorkerR2Binding {
739
+ name: string;
740
+ bucketName: string | HclExpression;
741
+ }
742
+ /**
743
+ * Worker service binding
744
+ */
745
+ interface WorkerServiceBinding {
746
+ name: string;
747
+ service: string;
748
+ environment?: string;
749
+ }
750
+ /**
751
+ * Create a Cloudflare Worker script resource
752
+ */
753
+ declare function cloudflareWorkerScript(config: WorkerScriptConfig): ResourceConfig;
754
+ /**
755
+ * Cloudflare Worker route configuration
756
+ */
757
+ interface WorkerRouteConfig {
758
+ /** Route pattern (e.g., "example.com/*") */
759
+ pattern: string;
760
+ /** Zone ID */
761
+ zoneId: string | HclExpression;
762
+ /** Script name (reference to worker script) */
763
+ scriptName: string | HclExpression;
764
+ }
765
+ /**
766
+ * Create a Cloudflare Worker route resource
767
+ */
768
+ declare function cloudflareWorkerRoute(config: WorkerRouteConfig): ResourceConfig;
769
+ /**
770
+ * Cloudflare Worker custom domain configuration
771
+ */
772
+ interface WorkerDomainConfig {
773
+ /** Account ID */
774
+ accountId: string | HclExpression;
775
+ /** Zone ID */
776
+ zoneId: string | HclExpression;
777
+ /** Hostname */
778
+ hostname: string;
779
+ /** Service (worker script name) */
780
+ service: string | HclExpression;
781
+ /** Environment (default: "production") */
782
+ environment?: string;
783
+ }
784
+ /**
785
+ * Create a Cloudflare Worker domain resource
786
+ */
787
+ declare function cloudflareWorkerDomain(config: WorkerDomainConfig): ResourceConfig;
788
+ /**
789
+ * Create a reference to a worker script
790
+ */
791
+ declare function workerScriptRef(name: string, attribute?: string): HclExpression;
792
+
793
+ /**
794
+ * Cloudflare KV namespace configuration
795
+ */
796
+ interface KvNamespaceConfig {
797
+ /** Namespace title */
798
+ title: string;
799
+ /** Account ID */
800
+ accountId: string | HclExpression;
801
+ }
802
+ /**
803
+ * Create a Cloudflare KV namespace resource
804
+ */
805
+ declare function cloudflareKvNamespace(config: KvNamespaceConfig): ResourceConfig;
806
+ /**
807
+ * Cloudflare KV pair configuration
808
+ */
809
+ interface KvPairConfig {
810
+ /** Namespace ID */
811
+ namespaceId: string | HclExpression;
812
+ /** Account ID */
813
+ accountId: string | HclExpression;
814
+ /** Key name */
815
+ key: string;
816
+ /** Value */
817
+ value: string | HclExpression;
818
+ }
819
+ /**
820
+ * Create a Cloudflare KV pair resource
821
+ */
822
+ declare function cloudflareKvPair(config: KvPairConfig): ResourceConfig;
823
+ /**
824
+ * Create a reference to a KV namespace
825
+ */
826
+ declare function kvNamespaceRef(name: string, attribute?: string): HclExpression;
827
+ /**
828
+ * Create multiple KV namespaces for different environments
829
+ */
830
+ declare function cloudflareKvNamespaces(accountId: string | HclExpression, baseName: string, environments?: string[]): ResourceConfig[];
831
+ /**
832
+ * Bulk KV configuration
833
+ */
834
+ interface BulkKvConfig {
835
+ /** Account ID */
836
+ accountId: string | HclExpression;
837
+ /** Namespace ID */
838
+ namespaceId: string | HclExpression;
839
+ /** Key-value pairs */
840
+ entries: Record<string, string>;
841
+ /** Resource name prefix */
842
+ namePrefix?: string;
843
+ }
844
+ /**
845
+ * Create multiple KV pairs from an object
846
+ */
847
+ declare function cloudflareKvBulk(config: BulkKvConfig): ResourceConfig[];
848
+
849
+ /**
850
+ * Cloudflare D1 database configuration
851
+ */
852
+ interface D1DatabaseConfig {
853
+ /** Database name */
854
+ name: string;
855
+ /** Account ID */
856
+ accountId: string | HclExpression;
857
+ }
858
+ /**
859
+ * Create a Cloudflare D1 database resource
860
+ */
861
+ declare function cloudflareD1Database(config: D1DatabaseConfig): ResourceConfig;
862
+ /**
863
+ * Create a reference to a D1 database
864
+ */
865
+ declare function d1DatabaseRef(name: string, attribute?: string): HclExpression;
866
+ /**
867
+ * Create multiple D1 databases for different environments
868
+ */
869
+ declare function cloudflareD1Databases(accountId: string | HclExpression, baseName: string, environments?: string[]): ResourceConfig[];
870
+ /**
871
+ * D1 database outputs configuration
872
+ */
873
+ interface D1OutputsConfig {
874
+ /** Database resource name */
875
+ resourceName: string;
876
+ /** Output name prefix */
877
+ prefix?: string;
878
+ }
879
+ /**
880
+ * Create outputs for a D1 database
881
+ */
882
+ declare function d1DatabaseOutputs(config: D1OutputsConfig): Record<string, {
883
+ value: HclExpression;
884
+ description?: string;
885
+ }>;
886
+
887
+ /**
888
+ * Cloudflare R2 bucket configuration
889
+ */
890
+ interface R2BucketConfig {
891
+ /** Bucket name */
892
+ name: string;
893
+ /** Account ID */
894
+ accountId: string | HclExpression;
895
+ /** Location hint (optional) */
896
+ location?: 'wnam' | 'enam' | 'weur' | 'eeur' | 'apac';
897
+ }
898
+ /**
899
+ * Create a Cloudflare R2 bucket resource
900
+ */
901
+ declare function cloudflareR2Bucket(config: R2BucketConfig): ResourceConfig;
902
+ /**
903
+ * Create a reference to an R2 bucket
904
+ */
905
+ declare function r2BucketRef(name: string, attribute?: string): HclExpression;
906
+ /**
907
+ * Create multiple R2 buckets for different purposes
908
+ */
909
+ declare function cloudflareR2Buckets(accountId: string | HclExpression, buckets: Array<{
910
+ name: string;
911
+ location?: R2BucketConfig['location'];
912
+ }>): ResourceConfig[];
913
+ /**
914
+ * R2 bucket with CORS configuration (note: CORS is configured via API, not Terraform)
915
+ * This creates outputs that can be used to configure CORS separately
916
+ */
917
+ interface R2BucketWithCorsConfig extends R2BucketConfig {
918
+ /** Allowed origins for CORS */
919
+ corsOrigins?: string[];
920
+ /** Allowed methods for CORS */
921
+ corsMethods?: string[];
922
+ }
923
+ /**
924
+ * Create R2 bucket outputs
925
+ */
926
+ declare function r2BucketOutputs(resourceName: string, prefix?: string): Record<string, {
927
+ value: HclExpression;
928
+ description?: string;
929
+ }>;
930
+ /**
931
+ * Create multiple R2 buckets for different environments
932
+ */
933
+ declare function cloudflareR2BucketsForEnvs(accountId: string | HclExpression, baseName: string, environments?: string[], location?: R2BucketConfig['location']): ResourceConfig[];
934
+
935
+ /**
936
+ * Cloudflare provider required_providers configuration
937
+ */
938
+ declare const cloudflareProvider: {
939
+ source: string;
940
+ version: string;
941
+ };
942
+ /**
943
+ * Common Cloudflare variable definitions
944
+ */
945
+ declare const cloudflareVariables: {
946
+ account_id: {
947
+ type: string;
948
+ description: string;
949
+ sensitive: boolean;
950
+ };
951
+ api_token: {
952
+ type: string;
953
+ description: string;
954
+ sensitive: boolean;
955
+ };
956
+ zone_id: {
957
+ type: string;
958
+ description: string;
959
+ };
960
+ };
961
+ /**
962
+ * Create a reference to var.cloudflare_account_id
963
+ */
964
+ declare const cfAccountId: HclExpression;
965
+ /**
966
+ * Create a reference to var.cloudflare_zone_id
967
+ */
968
+ declare const cfZoneId: HclExpression;
969
+
970
+ export { type AzureBackendOptions, BackendBuilder, type BackendConfig, type BlockType, type BulkKvConfig, type ConsulBackendOptions, type D1DatabaseConfig, type D1OutputsConfig, type DataSourceConfig, type GcsBackendOptions, type HclExpression, type HclOptions, type HclValue, type KvNamespaceConfig, type KvPairConfig, type ModuleConfig, type ModuleDefinition, type ModuleInstance, type OutputConfig, type ProviderConfig, type R2BucketConfig, type R2BucketWithCorsConfig, type RequiredProvider, type ResourceConfig, type S3BackendOptions, type TerraformBlock, type TerraformCloudOptions, type TerraformConfig, TerraformConfigBuilder, TfvarsBuilder, type TfvarsConfig, type VariableConfig, type WorkerD1Binding, type WorkerDomainConfig, type WorkerKvBinding, type WorkerR2Binding, type WorkerRouteConfig, type WorkerScriptConfig, type WorkerServiceBinding, type WriteOptions, type WriteResult, azureBackend, backend, backends, cfAccountId, cfZoneId, cloudflareD1Database, cloudflareD1Databases, cloudflareKvBulk, cloudflareKvNamespace, cloudflareKvNamespaces, cloudflareKvPair, cloudflareProvider, cloudflareR2Bucket, cloudflareR2Buckets, cloudflareR2BucketsForEnvs, cloudflareVariables, cloudflareWorkerDomain, cloudflareWorkerRoute, cloudflareWorkerScript, consulBackend, createFileWriter, d1DatabaseOutputs, d1DatabaseRef, dataRef, defineModule, expr, formatBlock, formatForTfvars, gcsBackend, generateDataSource, generateEnvTfvars, generateLocals, generateModule, generateOutput, generateProvider, generateResource, generateTerraformBlock, generateTerraformConfig, generateTerraformFile, generateTerraformFiles, generateTfvars, generateVariable, isHclExpression, kvNamespaceRef, localBackend, localRef, mergeTfvars, moduleOutput, providers, r2BucketOutputs, r2BucketRef, resourceRef, s3Backend, terraform, terraformCloudBackend, tf, tfvars, tfvarsFromEnv, toHcl, useModule, varRef, workerScriptRef };