@@ -62,6 +62,17 @@ character, which cannot be a dash.`,
6262 DiffSuppressFunc : compareSelfLinkOrResourceName ,
6363 Description : `A reference to the disk used to create this snapshot.` ,
6464 },
65+ "chain_name" : {
66+ Type : schema .TypeString ,
67+ Optional : true ,
68+ ForceNew : true ,
69+ Description : `Creates the new snapshot in the snapshot chain labeled with the
70+ specified name. The chain name must be 1-63 characters long and
71+ comply with RFC1035. This is an uncommon option only for advanced
72+ service owners who needs to create separate snapshot chains, for
73+ example, for chargeback tracking. When you describe your snapshot
74+ resource, this field is visible only if it has a non-empty value.` ,
75+ },
6576 "description" : {
6677 Type : schema .TypeString ,
6778 Optional : true ,
@@ -222,6 +233,12 @@ func resourceComputeSnapshotCreate(d *schema.ResourceData, meta interface{}) err
222233 }
223234
224235 obj := make (map [string ]interface {})
236+ chainNameProp , err := expandComputeSnapshotChainName (d .Get ("chain_name" ), d , config )
237+ if err != nil {
238+ return err
239+ } else if v , ok := d .GetOkExists ("chain_name" ); ! isEmptyValue (reflect .ValueOf (chainNameProp )) && (ok || ! reflect .DeepEqual (v , chainNameProp )) {
240+ obj ["chainName" ] = chainNameProp
241+ }
225242 nameProp , err := expandComputeSnapshotName (d .Get ("name" ), d , config )
226243 if err != nil {
227244 return err
@@ -379,6 +396,9 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error
379396 if err := d .Set ("disk_size_gb" , flattenComputeSnapshotDiskSizeGb (res ["diskSizeGb" ], d , config )); err != nil {
380397 return fmt .Errorf ("Error reading Snapshot: %s" , err )
381398 }
399+ if err := d .Set ("chain_name" , flattenComputeSnapshotChainName (res ["chainName" ], d , config )); err != nil {
400+ return fmt .Errorf ("Error reading Snapshot: %s" , err )
401+ }
382402 if err := d .Set ("name" , flattenComputeSnapshotName (res ["name" ], d , config )); err != nil {
383403 return fmt .Errorf ("Error reading Snapshot: %s" , err )
384404 }
@@ -579,6 +599,10 @@ func flattenComputeSnapshotDiskSizeGb(v interface{}, d *schema.ResourceData, con
579599 return v // let terraform core handle it otherwise
580600}
581601
602+ func flattenComputeSnapshotChainName (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
603+ return v
604+ }
605+
582606func flattenComputeSnapshotName (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
583607 return v
584608}
@@ -665,6 +689,10 @@ func flattenComputeSnapshotSnapshotEncryptionKeyKmsKeyServiceAccount(v interface
665689 return v
666690}
667691
692+ func expandComputeSnapshotChainName (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
693+ return v , nil
694+ }
695+
668696func expandComputeSnapshotName (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
669697 return v , nil
670698}
0 commit comments