@@ -84,6 +84,20 @@ Example: {instance_type = google_alloydb_cluster.<secondary_cluster_name>.cluste
84
84
If the instance type is SECONDARY, the terraform delete instance operation does not delete the secondary instance but abandons it instead.
85
85
Use deletion_policy = "FORCE" in the associated secondary cluster and delete the cluster forcefully to delete the secondary cluster as well its associated secondary instance.
86
86
Users can undo the delete secondary instance action by importing the deleted secondary instance by calling terraform import. Possible values: ["PRIMARY", "READ_POOL", "SECONDARY"]` ,
87
+ },
88
+ "activation_policy" : {
89
+ Type : schema .TypeString ,
90
+ Computed : true ,
91
+ Optional : true ,
92
+ ValidateFunc : verify .ValidateEnum ([]string {"ACTIVATION_POLICY_UNSPECIFIED" , "ALWAYS" , "NEVER" , "" }),
93
+ Description : `'Specifies whether an instance needs to spin up. Once the instance is
94
+ active, the activation policy can be updated to the 'NEVER' to stop the
95
+ instance. Likewise, the activation policy can be updated to 'ALWAYS' to
96
+ start the instance.
97
+ There are restrictions around when an instance can/cannot be activated (for
98
+ example, a read pool instance should be stopped before stopping primary
99
+ etc.). Please refer to the API documentation for more details.
100
+ Possible values are: 'ACTIVATION_POLICY_UNSPECIFIED', 'ALWAYS', 'NEVER'.' Possible values: ["ACTIVATION_POLICY_UNSPECIFIED", "ALWAYS", "NEVER"]` ,
87
101
},
88
102
"annotations" : {
89
103
Type : schema .TypeMap ,
@@ -477,6 +491,12 @@ func resourceAlloydbInstanceCreate(d *schema.ResourceData, meta interface{}) err
477
491
} else if v , ok := d .GetOkExists ("availability_type" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (availabilityTypeProp )) && (ok || ! reflect .DeepEqual (v , availabilityTypeProp )) {
478
492
obj ["availabilityType" ] = availabilityTypeProp
479
493
}
494
+ activationPolicyProp , err := expandAlloydbInstanceActivationPolicy (d .Get ("activation_policy" ), d , config )
495
+ if err != nil {
496
+ return err
497
+ } else if v , ok := d .GetOkExists ("activation_policy" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (activationPolicyProp )) && (ok || ! reflect .DeepEqual (v , activationPolicyProp )) {
498
+ obj ["activationPolicy" ] = activationPolicyProp
499
+ }
480
500
instanceTypeProp , err := expandAlloydbInstanceInstanceType (d .Get ("instance_type" ), d , config )
481
501
if err != nil {
482
502
return err
@@ -652,6 +672,9 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error
652
672
if err := d .Set ("availability_type" , flattenAlloydbInstanceAvailabilityType (res ["availabilityType" ], d , config )); err != nil {
653
673
return fmt .Errorf ("Error reading Instance: %s" , err )
654
674
}
675
+ if err := d .Set ("activation_policy" , flattenAlloydbInstanceActivationPolicy (res ["activationPolicy" ], d , config )); err != nil {
676
+ return fmt .Errorf ("Error reading Instance: %s" , err )
677
+ }
655
678
if err := d .Set ("instance_type" , flattenAlloydbInstanceInstanceType (res ["instanceType" ], d , config )); err != nil {
656
679
return fmt .Errorf ("Error reading Instance: %s" , err )
657
680
}
@@ -730,6 +753,12 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err
730
753
} else if v , ok := d .GetOkExists ("availability_type" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , availabilityTypeProp )) {
731
754
obj ["availabilityType" ] = availabilityTypeProp
732
755
}
756
+ activationPolicyProp , err := expandAlloydbInstanceActivationPolicy (d .Get ("activation_policy" ), d , config )
757
+ if err != nil {
758
+ return err
759
+ } else if v , ok := d .GetOkExists ("activation_policy" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , activationPolicyProp )) {
760
+ obj ["activationPolicy" ] = activationPolicyProp
761
+ }
733
762
queryInsightsConfigProp , err := expandAlloydbInstanceQueryInsightsConfig (d .Get ("query_insights_config" ), d , config )
734
763
if err != nil {
735
764
return err
@@ -804,6 +833,10 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err
804
833
updateMask = append (updateMask , "availabilityType" )
805
834
}
806
835
836
+ if d .HasChange ("activation_policy" ) {
837
+ updateMask = append (updateMask , "activationPolicy" )
838
+ }
839
+
807
840
if d .HasChange ("query_insights_config" ) {
808
841
updateMask = append (updateMask , "queryInsightsConfig" )
809
842
}
@@ -1033,6 +1066,10 @@ func flattenAlloydbInstanceAvailabilityType(v interface{}, d *schema.ResourceDat
1033
1066
return v
1034
1067
}
1035
1068
1069
+ func flattenAlloydbInstanceActivationPolicy (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1070
+ return v
1071
+ }
1072
+
1036
1073
func flattenAlloydbInstanceInstanceType (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1037
1074
return v
1038
1075
}
@@ -1402,6 +1439,10 @@ func expandAlloydbInstanceAvailabilityType(v interface{}, d tpgresource.Terrafor
1402
1439
return v , nil
1403
1440
}
1404
1441
1442
+ func expandAlloydbInstanceActivationPolicy (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1443
+ return v , nil
1444
+ }
1445
+
1405
1446
func expandAlloydbInstanceInstanceType (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1406
1447
return v , nil
1407
1448
}
0 commit comments