forked from hashicorp/terraform-provider-google
/
resource_app_engine_flexible_app_version.go
3652 lines (3252 loc) · 149 KB
/
resource_app_engine_flexible_app_version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import (
"fmt"
"log"
"reflect"
"strconv"
"time"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceAppEngineFlexibleAppVersion() *schema.Resource {
return &schema.Resource{
Create: resourceAppEngineFlexibleAppVersionCreate,
Read: resourceAppEngineFlexibleAppVersionRead,
Update: resourceAppEngineFlexibleAppVersionUpdate,
Delete: resourceAppEngineFlexibleAppVersionDelete,
Importer: &schema.ResourceImporter{
State: resourceAppEngineFlexibleAppVersionImport,
},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
Schema: map[string]*schema.Schema{
"liveness_check": {
Type: schema.TypeList,
Required: true,
Description: `Health checking configuration for VM instances. Unhealthy instances are killed and replaced with new instances.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"path": {
Type: schema.TypeString,
Required: true,
Description: `The request path.`,
},
"check_interval": {
Type: schema.TypeString,
Optional: true,
Description: `Interval between health checks.`,
Default: "30s",
},
"failure_threshold": {
Type: schema.TypeFloat,
Optional: true,
Description: `Number of consecutive failed checks required before considering the VM unhealthy. Default: 4.`,
Default: 4.0,
},
"host": {
Type: schema.TypeString,
Optional: true,
Description: `Host header to send when performing a HTTP Readiness check. Example: "myapp.appspot.com"`,
},
"initial_delay": {
Type: schema.TypeString,
Optional: true,
Description: `The initial delay before starting to execute the checks. Default: "300s"`,
Default: "300s",
},
"success_threshold": {
Type: schema.TypeFloat,
Optional: true,
Description: `Number of consecutive successful checks required before considering the VM healthy. Default: 2.`,
Default: 2.0,
},
"timeout": {
Type: schema.TypeString,
Optional: true,
Description: `Time before the check is considered failed. Default: "4s"`,
Default: "4s",
},
},
},
},
"readiness_check": {
Type: schema.TypeList,
Required: true,
Description: `Configures readiness health checking for instances. Unhealthy instances are not put into the backend traffic rotation.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"path": {
Type: schema.TypeString,
Required: true,
Description: `The request path.`,
},
"app_start_timeout": {
Type: schema.TypeString,
Optional: true,
Description: `A maximum time limit on application initialization, measured from moment the application successfully
replies to a healthcheck until it is ready to serve traffic. Default: "300s"`,
Default: "300s",
},
"check_interval": {
Type: schema.TypeString,
Optional: true,
Description: `Interval between health checks. Default: "5s".`,
Default: "5s",
},
"failure_threshold": {
Type: schema.TypeFloat,
Optional: true,
Description: `Number of consecutive failed checks required before removing traffic. Default: 2.`,
Default: 2.0,
},
"host": {
Type: schema.TypeString,
Optional: true,
Description: `Host header to send when performing a HTTP Readiness check. Example: "myapp.appspot.com"`,
},
"success_threshold": {
Type: schema.TypeFloat,
Optional: true,
Description: `Number of consecutive successful checks required before receiving traffic. Default: 2.`,
Default: 2.0,
},
"timeout": {
Type: schema.TypeString,
Optional: true,
Description: `Time before the check is considered failed. Default: "4s"`,
Default: "4s",
},
},
},
},
"runtime": {
Type: schema.TypeString,
Required: true,
Description: `Desired runtime. Example python27.`,
},
"service": {
Type: schema.TypeString,
Required: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
Description: `AppEngine service resource`,
},
"api_config": {
Type: schema.TypeList,
Optional: true,
Description: `Serving configuration for Google Cloud Endpoints.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"script": {
Type: schema.TypeString,
Required: true,
Description: `Path to the script from the application root directory.`,
},
"auth_fail_action": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"AUTH_FAIL_ACTION_REDIRECT", "AUTH_FAIL_ACTION_UNAUTHORIZED", ""}, false),
Description: `Action to take when users access resources that require authentication. Default value: "AUTH_FAIL_ACTION_REDIRECT" Possible values: ["AUTH_FAIL_ACTION_REDIRECT", "AUTH_FAIL_ACTION_UNAUTHORIZED"]`,
Default: "AUTH_FAIL_ACTION_REDIRECT",
},
"login": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"LOGIN_OPTIONAL", "LOGIN_ADMIN", "LOGIN_REQUIRED", ""}, false),
Description: `Level of login required to access this resource. Default value: "LOGIN_OPTIONAL" Possible values: ["LOGIN_OPTIONAL", "LOGIN_ADMIN", "LOGIN_REQUIRED"]`,
Default: "LOGIN_OPTIONAL",
},
"security_level": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"SECURE_DEFAULT", "SECURE_NEVER", "SECURE_OPTIONAL", "SECURE_ALWAYS", ""}, false),
Description: `Security (HTTPS) enforcement for this URL. Possible values: ["SECURE_DEFAULT", "SECURE_NEVER", "SECURE_OPTIONAL", "SECURE_ALWAYS"]`,
},
"url": {
Type: schema.TypeString,
Optional: true,
Description: `URL to serve the endpoint at.`,
},
},
},
},
"automatic_scaling": {
Type: schema.TypeList,
Optional: true,
Description: `Automatic scaling is based on request rate, response latencies, and other application metrics.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cpu_utilization": {
Type: schema.TypeList,
Required: true,
Description: `Target scaling by CPU usage.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"target_utilization": {
Type: schema.TypeFloat,
Required: true,
Description: `Target CPU utilization ratio to maintain when scaling. Must be between 0 and 1.`,
},
"aggregation_window_length": {
Type: schema.TypeString,
Optional: true,
Description: `Period of time over which CPU utilization is calculated.`,
},
},
},
},
"cool_down_period": {
Type: schema.TypeString,
Optional: true,
Description: `The time period that the Autoscaler should wait before it starts collecting information from a new instance.
This prevents the autoscaler from collecting information when the instance is initializing,
during which the collected usage would not be reliable. Default: 120s`,
Default: "120s",
},
"disk_utilization": {
Type: schema.TypeList,
Optional: true,
Description: `Target scaling by disk usage.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"target_read_bytes_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target bytes read per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.disk_utilization.0.target_write_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_write_ops_per_second", "automatic_scaling.0.disk_utilization.0.target_read_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_read_ops_per_second"},
},
"target_read_ops_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target ops read per seconds.`,
AtLeastOneOf: []string{"automatic_scaling.0.disk_utilization.0.target_write_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_write_ops_per_second", "automatic_scaling.0.disk_utilization.0.target_read_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_read_ops_per_second"},
},
"target_write_bytes_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target bytes written per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.disk_utilization.0.target_write_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_write_ops_per_second", "automatic_scaling.0.disk_utilization.0.target_read_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_read_ops_per_second"},
},
"target_write_ops_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target ops written per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.disk_utilization.0.target_write_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_write_ops_per_second", "automatic_scaling.0.disk_utilization.0.target_read_bytes_per_second", "automatic_scaling.0.disk_utilization.0.target_read_ops_per_second"},
},
},
},
},
"max_concurrent_requests": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `Number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance.
Defaults to a runtime-specific value.`,
},
"max_idle_instances": {
Type: schema.TypeInt,
Optional: true,
Description: `Maximum number of idle instances that should be maintained for this version.`,
},
"max_pending_latency": {
Type: schema.TypeString,
Optional: true,
Description: `Maximum amount of time that a request should wait in the pending queue before starting a new instance to handle it.`,
},
"max_total_instances": {
Type: schema.TypeInt,
Optional: true,
Description: `Maximum number of instances that should be started to handle requests for this version. Default: 20`,
Default: 20,
},
"min_idle_instances": {
Type: schema.TypeInt,
Optional: true,
Description: `Minimum number of idle instances that should be maintained for this version. Only applicable for the default version of a service.`,
},
"min_pending_latency": {
Type: schema.TypeString,
Optional: true,
Description: `Minimum amount of time a request should wait in the pending queue before starting a new instance to handle it.`,
},
"min_total_instances": {
Type: schema.TypeInt,
Optional: true,
Description: `Minimum number of running instances that should be maintained for this version. Default: 2`,
Default: 2,
},
"network_utilization": {
Type: schema.TypeList,
Optional: true,
Description: `Target scaling by network usage.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"target_received_bytes_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target bytes received per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.network_utilization.0.target_sent_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_sent_packets_per_second", "automatic_scaling.0.network_utilization.0.target_received_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_received_packets_per_second"},
},
"target_received_packets_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target packets received per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.network_utilization.0.target_sent_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_sent_packets_per_second", "automatic_scaling.0.network_utilization.0.target_received_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_received_packets_per_second"},
},
"target_sent_bytes_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target bytes sent per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.network_utilization.0.target_sent_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_sent_packets_per_second", "automatic_scaling.0.network_utilization.0.target_received_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_received_packets_per_second"},
},
"target_sent_packets_per_second": {
Type: schema.TypeInt,
Optional: true,
Description: `Target packets sent per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.network_utilization.0.target_sent_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_sent_packets_per_second", "automatic_scaling.0.network_utilization.0.target_received_bytes_per_second", "automatic_scaling.0.network_utilization.0.target_received_packets_per_second"},
},
},
},
},
"request_utilization": {
Type: schema.TypeList,
Optional: true,
Description: `Target scaling by request utilization.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"target_concurrent_requests": {
Type: schema.TypeFloat,
Optional: true,
Description: `Target number of concurrent requests.`,
AtLeastOneOf: []string{"automatic_scaling.0.request_utilization.0.target_request_count_per_second", "automatic_scaling.0.request_utilization.0.target_concurrent_requests"},
},
"target_request_count_per_second": {
Type: schema.TypeString,
Optional: true,
Description: `Target requests per second.`,
AtLeastOneOf: []string{"automatic_scaling.0.request_utilization.0.target_request_count_per_second", "automatic_scaling.0.request_utilization.0.target_concurrent_requests"},
},
},
},
},
},
},
ExactlyOneOf: []string{"automatic_scaling", "manual_scaling"},
},
"beta_settings": {
Type: schema.TypeMap,
Optional: true,
Description: `Metadata settings that are supplied to this version to enable beta runtime features.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"default_expiration": {
Type: schema.TypeString,
Optional: true,
Description: `Duration that static files should be cached by web proxies and browsers.
Only applicable if the corresponding StaticFilesHandler does not specify its own expiration time.`,
},
"deployment": {
Type: schema.TypeList,
Optional: true,
Description: `Code and application artifacts that make up this version.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cloud_build_options": {
Type: schema.TypeList,
Optional: true,
Description: `Options for the build operations performed as a part of the version deployment. Only applicable when creating a version using source code directly.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"app_yaml_path": {
Type: schema.TypeString,
Required: true,
Description: `Path to the yaml file used in deployment, used to determine runtime configuration details.`,
},
"cloud_build_timeout": {
Type: schema.TypeString,
Optional: true,
Description: `The Cloud Build timeout used as part of any dependent builds performed by version creation. Defaults to 10 minutes.
A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".`,
},
},
},
AtLeastOneOf: []string{"deployment.0.zip", "deployment.0.files", "deployment.0.container"},
},
"container": {
Type: schema.TypeList,
Optional: true,
Description: `The Docker image for the container that runs the version.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"image": {
Type: schema.TypeString,
Required: true,
Description: `URI to the hosted container image in Google Container Registry. The URI must be fully qualified and include a tag or digest.
Examples: "gcr.io/my-project/image:tag" or "gcr.io/my-project/image@digest"`,
},
},
},
AtLeastOneOf: []string{"deployment.0.zip", "deployment.0.files", "deployment.0.container"},
},
"files": {
Type: schema.TypeSet,
Optional: true,
Description: `Manifest of the files stored in Google Cloud Storage that are included as part of this version.
All files must be readable using the credentials supplied with this call.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"source_url": {
Type: schema.TypeString,
Required: true,
Description: `Source URL`,
},
"sha1_sum": {
Type: schema.TypeString,
Optional: true,
Description: `SHA1 checksum of the file`,
},
},
},
AtLeastOneOf: []string{"deployment.0.zip", "deployment.0.files", "deployment.0.container"},
},
"zip": {
Type: schema.TypeList,
Optional: true,
Description: `Zip File`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"source_url": {
Type: schema.TypeString,
Required: true,
Description: `Source URL`,
},
"files_count": {
Type: schema.TypeInt,
Optional: true,
Description: `files count`,
},
},
},
AtLeastOneOf: []string{"deployment.0.zip", "deployment.0.files", "deployment.0.container"},
},
},
},
},
"endpoints_api_service": {
Type: schema.TypeList,
Optional: true,
Description: `Code and application artifacts that make up this version.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `Endpoints service name which is the name of the "service" resource in the Service Management API.
For example "myapi.endpoints.myproject.cloud.goog"`,
},
"config_id": {
Type: schema.TypeString,
Optional: true,
Description: `Endpoints service configuration ID as specified by the Service Management API. For example "2016-09-19r1".
By default, the rollout strategy for Endpoints is "FIXED". This means that Endpoints starts up with a particular configuration ID.
When a new configuration is rolled out, Endpoints must be given the new configuration ID. The configId field is used to give the configuration ID
and is required in this case.
Endpoints also has a rollout strategy called "MANAGED". When using this, Endpoints fetches the latest configuration and does not need
the configuration ID. In this case, configId must be omitted.`,
},
"disable_trace_sampling": {
Type: schema.TypeBool,
Optional: true,
Description: `Enable or disable trace sampling. By default, this is set to false for enabled.`,
Default: false,
},
"rollout_strategy": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"FIXED", "MANAGED", ""}, false),
Description: `Endpoints rollout strategy. If FIXED, configId must be specified. If MANAGED, configId must be omitted. Default value: "FIXED" Possible values: ["FIXED", "MANAGED"]`,
Default: "FIXED",
},
},
},
},
"entrypoint": {
Type: schema.TypeList,
Optional: true,
Description: `The entrypoint for the application.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"shell": {
Type: schema.TypeString,
Required: true,
Description: `The format should be a shell command that can be fed to bash -c.`,
},
},
},
},
"env_variables": {
Type: schema.TypeMap,
Optional: true,
Description: `Environment variables available to the application. As these are not returned in the API request, Terraform will not detect any changes made outside of the Terraform config.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"handlers": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `An ordered list of URL-matching patterns that should be applied to incoming requests.
The first matching URL handles the request and other request handlers are not attempted.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"auth_fail_action": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"AUTH_FAIL_ACTION_REDIRECT", "AUTH_FAIL_ACTION_UNAUTHORIZED", ""}, false),
Description: `Actions to take when the user is not logged in. Possible values: ["AUTH_FAIL_ACTION_REDIRECT", "AUTH_FAIL_ACTION_UNAUTHORIZED"]`,
},
"login": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"LOGIN_OPTIONAL", "LOGIN_ADMIN", "LOGIN_REQUIRED", ""}, false),
Description: `Methods to restrict access to a URL based on login status. Possible values: ["LOGIN_OPTIONAL", "LOGIN_ADMIN", "LOGIN_REQUIRED"]`,
},
"redirect_http_response_code": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"REDIRECT_HTTP_RESPONSE_CODE_301", "REDIRECT_HTTP_RESPONSE_CODE_302", "REDIRECT_HTTP_RESPONSE_CODE_303", "REDIRECT_HTTP_RESPONSE_CODE_307", ""}, false),
Description: `30x code to use when performing redirects for the secure field. Possible values: ["REDIRECT_HTTP_RESPONSE_CODE_301", "REDIRECT_HTTP_RESPONSE_CODE_302", "REDIRECT_HTTP_RESPONSE_CODE_303", "REDIRECT_HTTP_RESPONSE_CODE_307"]`,
},
"script": {
Type: schema.TypeList,
Optional: true,
Description: `Executes a script to handle the requests that match this URL pattern.
Only the auto value is supported for Node.js in the App Engine standard environment, for example "script:" "auto".`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"script_path": {
Type: schema.TypeString,
Required: true,
Description: `Path to the script from the application root directory.`,
},
},
},
},
"security_level": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"SECURE_DEFAULT", "SECURE_NEVER", "SECURE_OPTIONAL", "SECURE_ALWAYS", ""}, false),
Description: `Security (HTTPS) enforcement for this URL. Possible values: ["SECURE_DEFAULT", "SECURE_NEVER", "SECURE_OPTIONAL", "SECURE_ALWAYS"]`,
},
"static_files": {
Type: schema.TypeList,
Optional: true,
Description: `Files served directly to the user for a given URL, such as images, CSS stylesheets, or JavaScript source files.
Static file handlers describe which files in the application directory are static files, and which URLs serve them.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"application_readable": {
Type: schema.TypeBool,
Optional: true,
Description: `Whether files should also be uploaded as code data. By default, files declared in static file handlers are
uploaded as static data and are only served to end users; they cannot be read by the application. If enabled,
uploads are charged against both your code and static data storage resource quotas.`,
},
"expiration": {
Type: schema.TypeString,
Optional: true,
Description: `Time a static file served by this handler should be cached by web proxies and browsers.
A duration in seconds with up to nine fractional digits, terminated by 's'. Example "3.5s".
Default is '0s'`,
Default: "0s",
},
"http_headers": {
Type: schema.TypeMap,
Optional: true,
Description: `HTTP headers to use for all responses from these URLs.
An object containing a list of "key:value" value pairs.".`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"mime_type": {
Type: schema.TypeString,
Optional: true,
Description: `MIME type used to serve all files served by this handler.
Defaults to file-specific MIME types, which are derived from each file's filename extension.`,
},
"path": {
Type: schema.TypeString,
Optional: true,
Description: `Path to the static files matched by the URL pattern, from the application root directory.
The path can refer to text matched in groupings in the URL pattern.`,
},
"require_matching_file": {
Type: schema.TypeBool,
Optional: true,
Description: `Whether this handler should match the request if the file referenced by the handler does not exist.`,
},
"upload_path_regex": {
Type: schema.TypeString,
Optional: true,
Description: `Regular expression that matches the file paths for all files that should be referenced by this handler.`,
},
},
},
},
"url_regex": {
Type: schema.TypeString,
Optional: true,
Description: `URL prefix. Uses regular expression syntax, which means regexp special characters must be escaped, but should not contain groupings.
All URLs that begin with this prefix are handled by this handler, using the portion of the URL after the prefix as part of the file path.`,
},
},
},
},
"inbound_services": {
Type: schema.TypeSet,
Optional: true,
Description: `A list of the types of messages that this application is able to receive. Possible values: ["INBOUND_SERVICE_MAIL", "INBOUND_SERVICE_MAIL_BOUNCE", "INBOUND_SERVICE_XMPP_ERROR", "INBOUND_SERVICE_XMPP_MESSAGE", "INBOUND_SERVICE_XMPP_SUBSCRIBE", "INBOUND_SERVICE_XMPP_PRESENCE", "INBOUND_SERVICE_CHANNEL_PRESENCE", "INBOUND_SERVICE_WARMUP"]`,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"INBOUND_SERVICE_MAIL", "INBOUND_SERVICE_MAIL_BOUNCE", "INBOUND_SERVICE_XMPP_ERROR", "INBOUND_SERVICE_XMPP_MESSAGE", "INBOUND_SERVICE_XMPP_SUBSCRIBE", "INBOUND_SERVICE_XMPP_PRESENCE", "INBOUND_SERVICE_CHANNEL_PRESENCE", "INBOUND_SERVICE_WARMUP"}, false),
},
Set: schema.HashString,
},
"instance_class": {
Type: schema.TypeString,
Optional: true,
Description: `Instance class that is used to run this version. Valid values are
AutomaticScaling: F1, F2, F4, F4_1G
ManualScaling: B1, B2, B4, B8, B4_1G
Defaults to F1 for AutomaticScaling and B1 for ManualScaling.`,
},
"manual_scaling": {
Type: schema.TypeList,
Optional: true,
Description: `A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"instances": {
Type: schema.TypeInt,
Required: true,
Description: `Number of instances to assign to the service at the start.
**Note:** When managing the number of instances at runtime through the App Engine Admin API or the (now deprecated) Python 2
Modules API set_num_instances() you must use 'lifecycle.ignore_changes = ["manual_scaling"[0].instances]' to prevent drift detection.`,
},
},
},
ExactlyOneOf: []string{"automatic_scaling", "manual_scaling"},
},
"network": {
Type: schema.TypeList,
Optional: true,
Description: `Extra network settings`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `Google Compute Engine network where the virtual machines are created. Specify the short name, not the resource path.`,
},
"forwarded_ports": {
Type: schema.TypeList,
Optional: true,
Description: `List of ports, or port pairs, to forward from the virtual machine to the application container.`,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"instance_tag": {
Type: schema.TypeString,
Optional: true,
Description: `Tag to apply to the instance during creation.`,
},
"session_affinity": {
Type: schema.TypeBool,
Optional: true,
Description: `Enable session affinity.`,
},
"subnetwork": {
Type: schema.TypeString,
Optional: true,
Description: `Google Cloud Platform sub-network where the virtual machines are created. Specify the short name, not the resource path.
If the network that the instance is being created in is a Legacy network, then the IP address is allocated from the IPv4Range.
If the network that the instance is being created in is an auto Subnet Mode Network, then only network name should be specified (not the subnetworkName) and the IP address is created from the IPCidrRange of the subnetwork that exists in that zone for that network.
If the network that the instance is being created in is a custom Subnet Mode Network, then the subnetworkName must be specified and the IP address is created from the IPCidrRange of the subnetwork.
If specified, the subnetwork must exist in the same region as the App Engine flexible environment application.`,
},
},
},
},
"nobuild_files_regex": {
Type: schema.TypeString,
Optional: true,
Description: `Files that match this pattern will not be built into this version. Only applicable for Go runtimes.`,
},
"resources": {
Type: schema.TypeList,
Optional: true,
Description: `Machine resources for a version.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cpu": {
Type: schema.TypeInt,
Optional: true,
Description: `Number of CPU cores needed.`,
AtLeastOneOf: []string{"resources.0.cpu", "resources.0.disk_gb", "resources.0.memory_gb", "resources.0.volumes"},
},
"disk_gb": {
Type: schema.TypeInt,
Optional: true,
Description: `Disk size (GB) needed.`,
AtLeastOneOf: []string{"resources.0.cpu", "resources.0.disk_gb", "resources.0.memory_gb", "resources.0.volumes"},
},
"memory_gb": {
Type: schema.TypeFloat,
Optional: true,
Description: `Memory (GB) needed.`,
AtLeastOneOf: []string{"resources.0.cpu", "resources.0.disk_gb", "resources.0.memory_gb", "resources.0.volumes"},
},
"volumes": {
Type: schema.TypeList,
Optional: true,
Description: `List of ports, or port pairs, to forward from the virtual machine to the application container.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `Unique name for the volume.`,
},
"size_gb": {
Type: schema.TypeInt,
Required: true,
Description: `Volume size in gigabytes.`,
},
"volume_type": {
Type: schema.TypeString,
Required: true,
Description: `Underlying volume type, e.g. 'tmpfs'.`,
},
},
},
AtLeastOneOf: []string{"resources.0.cpu", "resources.0.disk_gb", "resources.0.memory_gb", "resources.0.volumes"},
},
},
},
},
"runtime_api_version": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `The version of the API in the given runtime environment.
Please see the app.yaml reference for valid values at https://cloud.google.com/appengine/docs/standard//config/appref`,
},
"runtime_channel": {
Type: schema.TypeString,
Optional: true,
Description: `The channel of the runtime to use. Only available for some runtimes.`,
},
"runtime_main_executable_path": {
Type: schema.TypeString,
Optional: true,
Description: `The path or name of the app's main executable.`,
},
"serving_status": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"SERVING", "STOPPED", ""}, false),
Description: `Current serving status of this version. Only the versions with a SERVING status create instances and can be billed. Default value: "SERVING" Possible values: ["SERVING", "STOPPED"]`,
Default: "SERVING",
},
"version_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `Relative name of the version within the service. For example, 'v1'. Version names can contain only lowercase letters, numbers, or hyphens.
Reserved names,"default", "latest", and any name with the prefix "ah-".`,
},
"vpc_access_connector": {
Type: schema.TypeList,
Optional: true,
Description: `Enables VPC connectivity for standard apps.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `Full Serverless VPC Access Connector name e.g. /projects/my-project/locations/us-central1/connectors/c1.`,
},
},
},
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: `Full path to the Version resource in the API. Example, "v1".`,
},
"noop_on_destroy": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"delete_service_on_destroy": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
UseJSONNumber: true,
}
}
func resourceAppEngineFlexibleAppVersionCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
userAgent, err := generateUserAgentString(d, config.userAgent)
if err != nil {
return err
}
obj := make(map[string]interface{})
idProp, err := expandAppEngineFlexibleAppVersionVersionId(d.Get("version_id"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("version_id"); !isEmptyValue(reflect.ValueOf(idProp)) && (ok || !reflect.DeepEqual(v, idProp)) {
obj["id"] = idProp
}
inboundServicesProp, err := expandAppEngineFlexibleAppVersionInboundServices(d.Get("inbound_services"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("inbound_services"); !isEmptyValue(reflect.ValueOf(inboundServicesProp)) && (ok || !reflect.DeepEqual(v, inboundServicesProp)) {
obj["inboundServices"] = inboundServicesProp
}
instanceClassProp, err := expandAppEngineFlexibleAppVersionInstanceClass(d.Get("instance_class"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("instance_class"); !isEmptyValue(reflect.ValueOf(instanceClassProp)) && (ok || !reflect.DeepEqual(v, instanceClassProp)) {
obj["instanceClass"] = instanceClassProp
}
networkProp, err := expandAppEngineFlexibleAppVersionNetwork(d.Get("network"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("network"); !isEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) {
obj["network"] = networkProp
}
resourcesProp, err := expandAppEngineFlexibleAppVersionResources(d.Get("resources"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("resources"); !isEmptyValue(reflect.ValueOf(resourcesProp)) && (ok || !reflect.DeepEqual(v, resourcesProp)) {
obj["resources"] = resourcesProp
}
runtimeProp, err := expandAppEngineFlexibleAppVersionRuntime(d.Get("runtime"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("runtime"); !isEmptyValue(reflect.ValueOf(runtimeProp)) && (ok || !reflect.DeepEqual(v, runtimeProp)) {
obj["runtime"] = runtimeProp
}
runtimeChannelProp, err := expandAppEngineFlexibleAppVersionRuntimeChannel(d.Get("runtime_channel"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("runtime_channel"); !isEmptyValue(reflect.ValueOf(runtimeChannelProp)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) {
obj["runtimeChannel"] = runtimeChannelProp
}
betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("beta_settings"); !isEmptyValue(reflect.ValueOf(betaSettingsProp)) && (ok || !reflect.DeepEqual(v, betaSettingsProp)) {
obj["betaSettings"] = betaSettingsProp
}
servingStatusProp, err := expandAppEngineFlexibleAppVersionServingStatus(d.Get("serving_status"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("serving_status"); !isEmptyValue(reflect.ValueOf(servingStatusProp)) && (ok || !reflect.DeepEqual(v, servingStatusProp)) {
obj["servingStatus"] = servingStatusProp
}
runtimeApiVersionProp, err := expandAppEngineFlexibleAppVersionRuntimeApiVersion(d.Get("runtime_api_version"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("runtime_api_version"); !isEmptyValue(reflect.ValueOf(runtimeApiVersionProp)) && (ok || !reflect.DeepEqual(v, runtimeApiVersionProp)) {
obj["runtimeApiVersion"] = runtimeApiVersionProp
}
handlersProp, err := expandAppEngineFlexibleAppVersionHandlers(d.Get("handlers"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("handlers"); !isEmptyValue(reflect.ValueOf(handlersProp)) && (ok || !reflect.DeepEqual(v, handlersProp)) {
obj["handlers"] = handlersProp
}
runtimeMainExecutablePathProp, err := expandAppEngineFlexibleAppVersionRuntimeMainExecutablePath(d.Get("runtime_main_executable_path"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("runtime_main_executable_path"); !isEmptyValue(reflect.ValueOf(runtimeMainExecutablePathProp)) && (ok || !reflect.DeepEqual(v, runtimeMainExecutablePathProp)) {
obj["runtimeMainExecutablePath"] = runtimeMainExecutablePathProp
}
apiConfigProp, err := expandAppEngineFlexibleAppVersionApiConfig(d.Get("api_config"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("api_config"); !isEmptyValue(reflect.ValueOf(apiConfigProp)) && (ok || !reflect.DeepEqual(v, apiConfigProp)) {
obj["apiConfig"] = apiConfigProp
}
envVariablesProp, err := expandAppEngineFlexibleAppVersionEnvVariables(d.Get("env_variables"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("env_variables"); !isEmptyValue(reflect.ValueOf(envVariablesProp)) && (ok || !reflect.DeepEqual(v, envVariablesProp)) {
obj["envVariables"] = envVariablesProp
}
defaultExpirationProp, err := expandAppEngineFlexibleAppVersionDefaultExpiration(d.Get("default_expiration"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("default_expiration"); !isEmptyValue(reflect.ValueOf(defaultExpirationProp)) && (ok || !reflect.DeepEqual(v, defaultExpirationProp)) {
obj["defaultExpiration"] = defaultExpirationProp
}
readinessCheckProp, err := expandAppEngineFlexibleAppVersionReadinessCheck(d.Get("readiness_check"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("readiness_check"); !isEmptyValue(reflect.ValueOf(readinessCheckProp)) && (ok || !reflect.DeepEqual(v, readinessCheckProp)) {
obj["readinessCheck"] = readinessCheckProp
}
livenessCheckProp, err := expandAppEngineFlexibleAppVersionLivenessCheck(d.Get("liveness_check"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("liveness_check"); !isEmptyValue(reflect.ValueOf(livenessCheckProp)) && (ok || !reflect.DeepEqual(v, livenessCheckProp)) {
obj["livenessCheck"] = livenessCheckProp
}
nobuildFilesRegexProp, err := expandAppEngineFlexibleAppVersionNobuildFilesRegex(d.Get("nobuild_files_regex"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("nobuild_files_regex"); !isEmptyValue(reflect.ValueOf(nobuildFilesRegexProp)) && (ok || !reflect.DeepEqual(v, nobuildFilesRegexProp)) {
obj["nobuildFilesRegex"] = nobuildFilesRegexProp
}
deploymentProp, err := expandAppEngineFlexibleAppVersionDeployment(d.Get("deployment"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("deployment"); !isEmptyValue(reflect.ValueOf(deploymentProp)) && (ok || !reflect.DeepEqual(v, deploymentProp)) {
obj["deployment"] = deploymentProp
}
endpointsApiServiceProp, err := expandAppEngineFlexibleAppVersionEndpointsApiService(d.Get("endpoints_api_service"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("endpoints_api_service"); !isEmptyValue(reflect.ValueOf(endpointsApiServiceProp)) && (ok || !reflect.DeepEqual(v, endpointsApiServiceProp)) {
obj["endpointsApiService"] = endpointsApiServiceProp
}
entrypointProp, err := expandAppEngineFlexibleAppVersionEntrypoint(d.Get("entrypoint"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("entrypoint"); !isEmptyValue(reflect.ValueOf(entrypointProp)) && (ok || !reflect.DeepEqual(v, entrypointProp)) {
obj["entrypoint"] = entrypointProp
}
vpcAccessConnectorProp, err := expandAppEngineFlexibleAppVersionVPCAccessConnector(d.Get("vpc_access_connector"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("vpc_access_connector"); !isEmptyValue(reflect.ValueOf(vpcAccessConnectorProp)) && (ok || !reflect.DeepEqual(v, vpcAccessConnectorProp)) {
obj["vpcAccessConnector"] = vpcAccessConnectorProp
}
automaticScalingProp, err := expandAppEngineFlexibleAppVersionAutomaticScaling(d.Get("automatic_scaling"), d, config)
if err != nil {