-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
resource_cloud_run_service.go
5389 lines (4886 loc) · 212 KB
/
resource_cloud_run_service.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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// 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 cloudrun
import (
"context"
"fmt"
"log"
"net/http"
"reflect"
"regexp"
"strings"
"time"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
"google.golang.org/api/googleapi"
)
func revisionNameCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v interface{}) error {
autogen := diff.Get("autogenerate_revision_name").(bool)
if autogen && diff.HasChange("template.0.metadata.0.name") {
return fmt.Errorf("google_cloud_run_service: `template.metadata.name` cannot be set while `autogenerate_revision_name` is true. Please remove the field or set `autogenerate_revision_name` to false.")
}
return nil
}
var cloudRunGoogleProvidedTemplateAnnotations = regexp.MustCompile(`template\.0\.metadata\.0\.annotations\.run\.googleapis\.com/sandbox`)
var cloudRunGoogleProvidedTemplateAnnotations_autoscaling_maxscale = regexp.MustCompile(`template\.0\.metadata\.0\.annotations\.autoscaling\.knative\.dev/maxScale`)
func cloudrunTemplateAnnotationDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for the annotations provided by API
if cloudRunGoogleProvidedTemplateAnnotations.MatchString(k) &&
old == "gvisor" && new == "" {
return true
}
if cloudRunGoogleProvidedTemplateAnnotations_autoscaling_maxscale.MatchString(k) && new == "" {
return true
}
// For other keys, don't suppress diff.
return false
}
var cloudRunGoogleProvidedTemplateLabels = []string{
"run.googleapis.com/startupProbeType",
}
func cloudrunTemplateLabelDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for the labels provided by Google
for _, label := range cloudRunGoogleProvidedTemplateLabels {
if strings.Contains(k, label) && new == "" {
return true
}
}
// Let diff be determined by labels (above)
if strings.Contains(k, "labels.%") {
return true
}
// For other keys, don't suppress diff.
return false
}
func ResourceCloudRunService() *schema.Resource {
return &schema.Resource{
Create: resourceCloudRunServiceCreate,
Read: resourceCloudRunServiceRead,
Update: resourceCloudRunServiceUpdate,
Delete: resourceCloudRunServiceDelete,
Importer: &schema.ResourceImporter{
State: resourceCloudRunServiceImport,
},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(20 * time.Minute),
Update: schema.DefaultTimeout(20 * time.Minute),
Delete: schema.DefaultTimeout(20 * time.Minute),
},
SchemaVersion: 2,
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceCloudRunServiceResourceV1().CoreConfigSchema().ImpliedType(),
Upgrade: ResourceCloudRunServiceUpgradeV1,
Version: 1,
},
},
CustomizeDiff: customdiff.All(
revisionNameCustomizeDiff,
tpgresource.SetMetadataLabelsDiff,
tpgresource.SetMetadataAnnotationsDiff,
tpgresource.DefaultProviderProject,
),
Schema: map[string]*schema.Schema{
"location": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `The location of the cloud run instance. eg us-central1`,
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Name must be unique within a Google Cloud project and region.
Is required when creating resources. Name is primarily intended
for creation idempotence and configuration definition. Cannot be updated.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names`,
},
"template": {
Type: schema.TypeList,
Optional: true,
Description: `template holds the latest specification for the Revision to
be stamped out. The template references the container image, and may also
include labels and annotations that should be attached to the Revision.
To correlate a Revision, and/or to force a Revision to be created when the
spec doesn't otherwise change, a nonce label may be provided in the
template metadata. For more details, see:
https://github.com/knative/serving/blob/main/docs/client-conventions.md#associate-modifications-with-revisions
Cloud Run does not currently support referencing a build that is
responsible for materializing the container image from source.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"spec": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `RevisionSpec holds the desired state of the Revision (from the client).`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"containers": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `Containers defines the unit of execution for this Revision.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"image": {
Type: schema.TypeString,
Required: true,
Description: `Docker image name. This is most often a reference to a container located
in the container registry, such as gcr.io/cloudrun/hello`,
},
"args": {
Type: schema.TypeList,
Optional: true,
Description: `Arguments to the entrypoint.
The docker image's CMD is used if this is not provided.`,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"command": {
Type: schema.TypeList,
Optional: true,
Description: `Entrypoint array. Not executed within a shell.
The docker image's ENTRYPOINT is used if this is not provided.`,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"env": {
Type: schema.TypeSet,
Optional: true,
Description: `List of environment variables to set in the container.`,
Elem: cloudrunServiceSpecTemplateSpecContainersContainersEnvSchema(),
// Default schema.HashSchema is used.
},
"env_from": {
Type: schema.TypeList,
Optional: true,
Deprecated: "`env_from` is deprecated and will be removed in a future major release. This field is not supported by the Cloud Run API.",
ForceNew: true,
Description: `List of sources to populate environment variables in the container.
All invalid keys will be reported as an event when the container is starting.
When a key exists in multiple sources, the value associated with the last source will
take precedence. Values defined by an Env with a duplicate key will take
precedence.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"config_map_ref": {
Type: schema.TypeList,
Optional: true,
Description: `The ConfigMap to select from.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"local_object_reference": {
Type: schema.TypeList,
Optional: true,
Description: `The ConfigMap to select from.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `Name of the referent.`,
},
},
},
},
"optional": {
Type: schema.TypeBool,
Optional: true,
Description: `Specify whether the ConfigMap must be defined`,
},
},
},
},
"prefix": {
Type: schema.TypeString,
Optional: true,
Description: `An optional identifier to prepend to each key in the ConfigMap.`,
},
"secret_ref": {
Type: schema.TypeList,
Optional: true,
Description: `The Secret to select from.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"local_object_reference": {
Type: schema.TypeList,
Optional: true,
Description: `The Secret to select from.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `Name of the referent.`,
},
},
},
},
"optional": {
Type: schema.TypeBool,
Optional: true,
Description: `Specify whether the Secret must be defined`,
},
},
},
},
},
},
},
"liveness_probe": {
Type: schema.TypeList,
Optional: true,
Description: `Periodic probe of container liveness. Container will be restarted if the probe fails.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"failure_threshold": {
Type: schema.TypeInt,
Optional: true,
Description: `Minimum consecutive failures for the probe to be considered failed after
having succeeded. Defaults to 3. Minimum value is 1.`,
Default: 3,
},
"grpc": {
Type: schema.TypeList,
Optional: true,
Description: `GRPC specifies an action involving a GRPC port.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"port": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `Port number to access on the container. Number must be in the range 1 to 65535.
If not specified, defaults to the same value as container.ports[0].containerPort.`,
},
"service": {
Type: schema.TypeString,
Optional: true,
Description: `The name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
If this is not specified, the default behavior is defined by gRPC.`,
},
},
},
ExactlyOneOf: []string{},
},
"http_get": {
Type: schema.TypeList,
Optional: true,
Description: `HttpGet specifies the http request to perform.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"http_headers": {
Type: schema.TypeList,
Optional: true,
Description: `Custom headers to set in the request. HTTP allows repeated headers.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `The header field name.`,
},
"value": {
Type: schema.TypeString,
Optional: true,
Description: `The header field value.`,
Default: "",
},
},
},
},
"path": {
Type: schema.TypeString,
Optional: true,
Description: `Path to access on the HTTP server. If set, it should not be empty string.`,
Default: "/",
},
"port": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `Port number to access on the container. Number must be in the range 1 to 65535.
If not specified, defaults to the same value as container.ports[0].containerPort.`,
},
},
},
ExactlyOneOf: []string{},
},
"initial_delay_seconds": {
Type: schema.TypeInt,
Optional: true,
Description: `Number of seconds after the container has started before the probe is
initiated.
Defaults to 0 seconds. Minimum value is 0. Maximum value is 3600.`,
Default: 0,
},
"period_seconds": {
Type: schema.TypeInt,
Optional: true,
Description: `How often (in seconds) to perform the probe.
Default to 10 seconds. Minimum value is 1. Maximum value is 3600.`,
Default: 10,
},
"timeout_seconds": {
Type: schema.TypeInt,
Optional: true,
Description: `Number of seconds after which the probe times out.
Defaults to 1 second. Minimum value is 1. Maximum value is 3600.
Must be smaller than period_seconds.`,
Default: 1,
},
},
},
},
"name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `Name of the container`,
},
"ports": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `List of open ports in the container.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"container_port": {
Type: schema.TypeInt,
Optional: true,
Description: `Port number the container listens on. This must be a valid port number (between 1 and 65535). Defaults to "8080".`,
},
"name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `If specified, used to specify which protocol to use. Allowed values are "http1" (HTTP/1) and "h2c" (HTTP/2 end-to-end). Defaults to "http1".`,
},
"protocol": {
Type: schema.TypeString,
Optional: true,
Description: `Protocol for port. Must be "TCP". Defaults to "TCP".`,
},
},
},
},
"resources": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `Compute Resources required by this container. Used to set values such as max memory`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"limits": {
Type: schema.TypeMap,
Computed: true,
Optional: true,
Description: `Limits describes the maximum amount of compute resources allowed.
The values of the map is string form of the 'quantity' k8s type:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"requests": {
Type: schema.TypeMap,
Optional: true,
Description: `Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is
explicitly specified, otherwise to an implementation-defined value.
The values of the map is string form of the 'quantity' k8s type:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go`,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},
"startup_probe": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `Startup probe of application within the container.
All other probes are disabled if a startup probe is provided, until it
succeeds. Container will not be added to service endpoints if the probe fails.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"failure_threshold": {
Type: schema.TypeInt,
Optional: true,
Description: `Minimum consecutive failures for the probe to be considered failed after
having succeeded. Defaults to 3. Minimum value is 1.`,
Default: 3,
},
"grpc": {
Type: schema.TypeList,
Optional: true,
Description: `GRPC specifies an action involving a GRPC port.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"port": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `Port number to access on the container. Number must be in the range 1 to 65535.
If not specified, defaults to the same value as container.ports[0].containerPort.`,
},
"service": {
Type: schema.TypeString,
Optional: true,
Description: `The name of the service to place in the gRPC HealthCheckRequest
(see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
If this is not specified, the default behavior is defined by gRPC.`,
},
},
},
ExactlyOneOf: []string{},
},
"http_get": {
Type: schema.TypeList,
Optional: true,
Description: `HttpGet specifies the http request to perform.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"http_headers": {
Type: schema.TypeList,
Optional: true,
Description: `Custom headers to set in the request. HTTP allows repeated headers.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `The header field name.`,
},
"value": {
Type: schema.TypeString,
Optional: true,
Description: `The header field value.`,
Default: "",
},
},
},
},
"path": {
Type: schema.TypeString,
Optional: true,
Description: `Path to access on the HTTP server. If set, it should not be empty string.`,
Default: "/",
},
"port": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `Port number to access on the container. Number must be in the range 1 to 65535.
If not specified, defaults to the same value as container.ports[0].containerPort.`,
},
},
},
ExactlyOneOf: []string{},
},
"initial_delay_seconds": {
Type: schema.TypeInt,
Optional: true,
Description: `Number of seconds after the container has started before the probe is
initiated.
Defaults to 0 seconds. Minimum value is 0. Maximum value is 240.`,
Default: 0,
},
"period_seconds": {
Type: schema.TypeInt,
Optional: true,
Description: `How often (in seconds) to perform the probe.
Default to 10 seconds. Minimum value is 1. Maximum value is 240.`,
Default: 10,
},
"tcp_socket": {
Type: schema.TypeList,
Optional: true,
Description: `TcpSocket specifies an action involving a TCP port.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"port": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `Port number to access on the container. Number must be in the range 1 to 65535.
If not specified, defaults to the same value as container.ports[0].containerPort.`,
},
},
},
ExactlyOneOf: []string{},
},
"timeout_seconds": {
Type: schema.TypeInt,
Optional: true,
Description: `Number of seconds after which the probe times out.
Defaults to 1 second. Minimum value is 1. Maximum value is 3600.
Must be smaller than periodSeconds.`,
Default: 1,
},
},
},
},
"volume_mounts": {
Type: schema.TypeList,
Optional: true,
Description: `Volume to mount into the container's filesystem.
Only supports SecretVolumeSources.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"mount_path": {
Type: schema.TypeString,
Required: true,
Description: `Path within the container at which the volume should be mounted. Must
not contain ':'.`,
},
"name": {
Type: schema.TypeString,
Required: true,
Description: `This must match the Name of a Volume.`,
},
},
},
},
"working_dir": {
Type: schema.TypeString,
Optional: true,
Deprecated: "`working_dir` is deprecated and will be removed in a future major release. This field is not supported by the Cloud Run API.",
ForceNew: true,
Description: `Container's working directory.
If not specified, the container runtime's default will be used, which
might be configured in the container image.`,
},
},
},
},
"container_concurrency": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `ContainerConcurrency specifies the maximum allowed in-flight (concurrent)
requests per container of the Revision. Values are:
- '0' thread-safe, the system should manage the max concurrency. This is
the default value.
- '1' not-thread-safe. Single concurrency
- '2-N' thread-safe, max concurrency of N`,
},
"service_account_name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `Email address of the IAM service account associated with the revision of the
service. The service account represents the identity of the running revision,
and determines what permissions the revision has. If not provided, the revision
will use the project's default service account.`,
},
"timeout_seconds": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: `TimeoutSeconds holds the max duration the instance is allowed for responding to a request.`,
},
"volumes": {
Type: schema.TypeList,
Optional: true,
Description: `Volume represents a named volume in a container.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: `Volume's name.`,
},
"secret": {
Type: schema.TypeList,
Optional: true,
Description: `The secret's value will be presented as the content of a file whose
name is defined in the item path. If no items are defined, the name of
the file is the secret_name.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"secret_name": {
Type: schema.TypeString,
Required: true,
Description: `The name of the secret in Cloud Secret Manager. By default, the secret
is assumed to be in the same project.
If the secret is in another project, you must define an alias.
An alias definition has the form:
{alias}:projects/{project-id|project-number}/secrets/{secret-name}.
If multiple alias definitions are needed, they must be separated by
commas.
The alias definitions must be set on the run.googleapis.com/secrets
annotation.`,
},
"default_mode": {
Type: schema.TypeInt,
Optional: true,
Description: `Mode bits to use on created files by default. Must be a value between 0000
and 0777. Defaults to 0644. Directories within the path are not affected by
this setting. This might be in conflict with other options that affect the
file mode, like fsGroup, and the result can be other mode bits set.`,
},
"items": {
Type: schema.TypeList,
Optional: true,
Description: `If unspecified, the volume will expose a file whose name is the
secret_name.
If specified, the key will be used as the version to fetch from Cloud
Secret Manager and the path will be the name of the file exposed in the
volume. When items are defined, they must specify a key and a path.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Type: schema.TypeString,
Required: true,
Description: `The Cloud Secret Manager secret version.
Can be 'latest' for the latest value or an integer for a specific version.`,
},
"path": {
Type: schema.TypeString,
Required: true,
Description: `The relative path of the file to map the key to.
May not be an absolute path.
May not contain the path element '..'.
May not start with the string '..'.`,
},
"mode": {
Type: schema.TypeInt,
Optional: true,
Description: `Mode bits to use on this file, must be a value between 0000 and 0777. If
not specified, the volume defaultMode will be used. This might be in
conflict with other options that affect the file mode, like fsGroup, and
the result can be other mode bits set.`,
},
},
},
},
},
},
},
},
},
},
"serving_state": {
Type: schema.TypeString,
Computed: true,
Deprecated: "`serving_state` is deprecated and will be removed in a future major release. This field is not supported by the Cloud Run API.",
Description: `ServingState holds a value describing the state the resources
are in for this Revision.
It is expected
that the system will manipulate this based on routability and load.`,
},
},
},
},
"metadata": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `Optional metadata for this Revision, including labels and annotations.
Name will be generated by the Configuration. To set minimum instances
for this revision, use the "autoscaling.knative.dev/minScale" annotation
key. To set maximum instances for this revision, use the
"autoscaling.knative.dev/maxScale" annotation key. To set Cloud SQL
connections for the revision, use the "run.googleapis.com/cloudsql-instances"
annotation key.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"annotations": {
Type: schema.TypeMap,
Computed: true,
Optional: true,
DiffSuppressFunc: cloudrunTemplateAnnotationDiffSuppress,
Description: `Annotations is a key value map stored with a resource that
may be set by external tools to store and retrieve arbitrary metadata. More
info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
**Note**: The Cloud Run API may add additional annotations that were not provided in your config.
If terraform plan shows a diff where a server-side annotation is added, you can add it to your config
or apply the lifecycle.ignore_changes rule to the metadata.0.annotations field.
Annotations with 'run.googleapis.com/' and 'autoscaling.knative.dev' are restricted. Use the following annotation
keys to configure features on a Revision template:
- 'autoscaling.knative.dev/maxScale' sets the [maximum number of container
instances](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--max-instances) of the Revision to run.
- 'autoscaling.knative.dev/minScale' sets the [minimum number of container
instances](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--min-instances) of the Revision to run.
- 'run.googleapis.com/client-name' sets the client name calling the Cloud Run API.
- 'run.googleapis.com/cloudsql-instances' sets the [Cloud SQL
instances](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--add-cloudsql-instances) the Revision connects to.
- 'run.googleapis.com/cpu-throttling' sets whether to throttle the CPU when the container is not actively serving
requests. See https://cloud.google.com/sdk/gcloud/reference/run/deploy#--[no-]cpu-throttling.
- 'run.googleapis.com/encryption-key-shutdown-hours' sets the number of hours to wait before an automatic shutdown
server after CMEK key revocation is detected.
- 'run.googleapis.com/encryption-key' sets the [CMEK key](https://cloud.google.com/run/docs/securing/using-cmek)
reference to encrypt the container with.
- 'run.googleapis.com/execution-environment' sets the [execution
environment](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--execution-environment)
where the application will run.
- 'run.googleapis.com/post-key-revocation-action-type' sets the
[action type](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--post-key-revocation-action-type)
after CMEK key revocation.
- 'run.googleapis.com/secrets' sets a list of key-value pairs to set as
[secrets](https://cloud.google.com/run/docs/configuring/secrets#yaml).
- 'run.googleapis.com/sessionAffinity' sets whether to enable
[session affinity](https://cloud.google.com/sdk/gcloud/reference/beta/run/deploy#--[no-]session-affinity)
for connections to the Revision.
- 'run.googleapis.com/startup-cpu-boost' sets whether to allocate extra CPU to containers on startup.
See https://cloud.google.com/sdk/gcloud/reference/run/deploy#--[no-]cpu-boost.
- 'run.googleapis.com/vpc-access-connector' sets a [VPC connector](https://cloud.google.com/run/docs/configuring/connecting-vpc#terraform_1)
for the Revision.
- 'run.googleapis.com/vpc-access-egress' sets the outbound traffic to send through the VPC connector for this resource.
See https://cloud.google.com/sdk/gcloud/reference/run/deploy#--vpc-egress.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"labels": {
Type: schema.TypeMap,
Computed: true,
Optional: true,
DiffSuppressFunc: cloudrunTemplateLabelDiffSuppress,
Description: `Map of string keys and values that can be used to organize and categorize
(scope and select) objects.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `Name must be unique within a Google Cloud project and region.
Is required when creating resources. Name is primarily intended
for creation idempotence and configuration definition. Cannot be updated.`,
},
"namespace": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `In Cloud Run the namespace must be equal to either the
project ID or project number. It will default to the resource's project.`,
},
"generation": {
Type: schema.TypeInt,
Computed: true,
Description: `A sequence number representing a specific generation of the desired state.`,
},
"resource_version": {
Type: schema.TypeString,
Computed: true,
Description: `An opaque value that represents the internal version of this object that
can be used by clients to determine when objects have changed. May be used
for optimistic concurrency, change detection, and the watch operation on a
resource or set of resources. They may only be valid for a
particular resource or set of resources.`,
},
"self_link": {
Type: schema.TypeString,
Computed: true,
Description: `SelfLink is a URL representing this object.`,
},
"uid": {
Type: schema.TypeString,
Computed: true,
Description: `UID is a unique id generated by the server on successful creation of a resource and is not
allowed to change on PUT operations.`,
},
},
},
},
},
},
},
"traffic": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `Traffic specifies how to distribute traffic over a collection of Knative Revisions
and Configurations`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"percent": {
Type: schema.TypeInt,
Required: true,
Description: `Percent specifies percent of the traffic to this Revision or Configuration.`,
},
"latest_revision": {
Type: schema.TypeBool,
Optional: true,
Description: `LatestRevision may be optionally provided to indicate that the latest ready
Revision of the Configuration should be used for this traffic target. When
provided LatestRevision must be true if RevisionName is empty; it must be
false when RevisionName is non-empty.`,
},
"revision_name": {
Type: schema.TypeString,
Optional: true,
Description: `RevisionName of a specific revision to which to send this portion of traffic.`,
},
"tag": {
Type: schema.TypeString,
Optional: true,
Description: `Tag is optionally used to expose a dedicated url for referencing this target exclusively.`,
},
"url": {
Type: schema.TypeString,
Computed: true,
Description: `URL displays the URL for accessing tagged traffic targets. URL is displayed in status,
and is disallowed on spec. URL must contain a scheme (e.g. http://) and a hostname,
but may not contain anything else (e.g. basic auth, url path, etc.)`,
},
},
},
},
"metadata": {
Type: schema.TypeList,
Computed: true,
Optional: true,
Description: `Metadata associated with this Service, including name, namespace, labels,
and annotations.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"annotations": {
Type: schema.TypeMap,
Optional: true,
Description: `Annotations is a key value map stored with a resource that
may be set by external tools to store and retrieve arbitrary metadata. More
info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
**Note**: The Cloud Run API may add additional annotations that were not provided in your config.
If terraform plan shows a diff where a server-side annotation is added, you can add it to your config
or apply the lifecycle.ignore_changes rule to the metadata.0.annotations field.
Annotations with 'run.googleapis.com/' and 'autoscaling.knative.dev' are restricted. Use the following annotation
keys to configure features on a Service:
- 'run.googleapis.com/binary-authorization-breakglass' sets the [Binary Authorization breakglass](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--breakglass).
- 'run.googleapis.com/binary-authorization' sets the [Binary Authorization](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--binary-authorization).
- 'run.googleapis.com/client-name' sets the client name calling the Cloud Run API.
- 'run.googleapis.com/custom-audiences' sets the [custom audiences](https://cloud.google.com/sdk/gcloud/reference/alpha/run/deploy#--add-custom-audiences)
that can be used in the audience field of ID token for authenticated requests.
- 'run.googleapis.com/description' sets a user defined description for the Service.
- 'run.googleapis.com/ingress' sets the [ingress settings](https://cloud.google.com/sdk/gcloud/reference/run/deploy#--ingress)
for the Service. For example, '"run.googleapis.com/ingress" = "all"'.
- 'run.googleapis.com/launch-stage' sets the [launch stage](https://cloud.google.com/run/docs/troubleshooting#launch-stage-validation)
when a preview feature is used. For example, '"run.googleapis.com/launch-stage": "BETA"'
**Note**: This field is non-authoritative, and will only manage the annotations present in your configuration.
Please refer to the field 'effective_annotations' for all of the annotations present on the resource.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"labels": {
Type: schema.TypeMap,
Optional: true,
Description: `Map of string keys and values that can be used to organize and categorize
(scope and select) objects. May match selectors of replication controllers
and routes.
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"namespace": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: `In Cloud Run the namespace must be equal to either the
project ID or project number.`,
},
"effective_annotations": {
Type: schema.TypeMap,
Computed: true,
Description: `All of annotations (key/value pairs) present on the resource in GCP, including the annotations configured through Terraform, other clients and services.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"effective_labels": {
Type: schema.TypeMap,
Computed: true,
Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"generation": {
Type: schema.TypeInt,
Computed: true,
Description: `A sequence number representing a specific generation of the desired state.`,
},
"resource_version": {
Type: schema.TypeString,
Computed: true,
Description: `An opaque value that represents the internal version of this object that
can be used by clients to determine when objects have changed. May be used
for optimistic concurrency, change detection, and the watch operation on a
resource or set of resources. They may only be valid for a
particular resource or set of resources.`,
},
"self_link": {
Type: schema.TypeString,
Computed: true,
Description: `SelfLink is a URL representing this object.`,
},
"terraform_labels": {
Type: schema.TypeMap,
Computed: true,
Description: `The combination of labels configured directly on the resource
and default labels configured on the provider.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"uid": {
Type: schema.TypeString,
Computed: true,
Description: `UID is a unique id generated by the server on successful creation of a resource and is not
allowed to change on PUT operations.`,
},
},
},
},
"status": {
Type: schema.TypeList,
Computed: true,
Description: `The current status of the Service.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"conditions": {