@@ -92,7 +92,61 @@ func testAccCheckComputeSnapshotExists(n string, snapshot *compute.Snapshot) res
9292 }
9393
9494 if found .Name != rs .Primary .ID {
95- return fmt .Errorf ("Snapshot not found" )
95+ return fmt .Errorf ("Snapshot %s not found" , n )
96+ }
97+
98+ attr := rs .Primary .Attributes ["snapshot_encryption_key_sha256" ]
99+ if found .SnapshotEncryptionKey != nil && found .SnapshotEncryptionKey .Sha256 != attr {
100+ return fmt .Errorf ("Snapshot %s has mismatched encryption key.\n TF State: %+v.\n GCP State: %+v" ,
101+ n , attr , found .SnapshotEncryptionKey .Sha256 )
102+ } else if found .SnapshotEncryptionKey == nil && attr != "" {
103+ return fmt .Errorf ("Snapshot %s has mismatched encryption key.\n TF State: %+v.\n GCP State: %+v" ,
104+ n , attr , found .SnapshotEncryptionKey )
105+ }
106+
107+ attr = rs .Primary .Attributes ["snapshot_encryption_key_raw" ]
108+ if found .SnapshotEncryptionKey != nil && found .SnapshotEncryptionKey .RawKey != attr {
109+ return fmt .Errorf ("Snapshot %s has mismatched encryption key.\n TF State: %+v.\n GCP State: %+v" ,
110+ n , attr , found .SnapshotEncryptionKey .RawKey )
111+ } else if found .SnapshotEncryptionKey == nil && attr != "" {
112+ return fmt .Errorf ("Snapshot %s has mismatched encryption key.\n TF State: %+v.\n GCP State: %+v" ,
113+ n , attr , found .SnapshotEncryptionKey )
114+ }
115+
116+ attr = rs .Primary .Attributes ["source_disk_encryption_key_sha256" ]
117+ if found .SourceDiskEncryptionKey != nil && found .SourceDiskEncryptionKey .Sha256 != attr {
118+ return fmt .Errorf ("Snapshot %s has mismatched source disk encryption key.\n TF State: %+v.\n GCP State: %+v" ,
119+ n , attr , found .SourceDiskEncryptionKey .Sha256 )
120+ } else if found .SourceDiskEncryptionKey == nil && attr != "" {
121+ return fmt .Errorf ("Snapshot %s has mismatched source disk encryption key.\n TF State: %+v.\n GCP State: %+v" ,
122+ n , attr , found .SourceDiskEncryptionKey )
123+ }
124+
125+ attr = rs .Primary .Attributes ["source_disk_encryption_key_raw" ]
126+ if found .SourceDiskEncryptionKey != nil && found .SourceDiskEncryptionKey .RawKey != attr {
127+ return fmt .Errorf ("Snapshot %s has mismatched source disk encryption key.\n TF State: %+v.\n GCP State: %+v" ,
128+ n , attr , found .SourceDiskEncryptionKey .RawKey )
129+ } else if found .SourceDiskEncryptionKey == nil && attr != "" {
130+ return fmt .Errorf ("Snapshot %s has mismatched source disk encryption key.\n TF State: %+v.\n GCP State: %+v" ,
131+ n , attr , found .SourceDiskEncryptionKey )
132+ }
133+
134+ attr = rs .Primary .Attributes ["source_disk_id" ]
135+ if found .SourceDiskId != attr {
136+ return fmt .Errorf ("Snapshot %s has mismatched source disk id.\n TF State: %+v.\n GCP State: %+v" ,
137+ n , attr , found .SourceDiskId )
138+ }
139+
140+ attr = rs .Primary .Attributes ["source_disk" ]
141+ if found .SourceDisk != attr {
142+ return fmt .Errorf ("Snapshot %s has mismatched source disk.\n TF State: %+v.\n GCP State: %+v" ,
143+ n , attr , found .SourceDisk )
144+ }
145+
146+ attr = rs .Primary .Attributes ["self_link" ]
147+ if found .SelfLink != attr {
148+ return fmt .Errorf ("Snapshot %s has mismatched self link.\n TF State: %+v.\n GCP State: %+v" ,
149+ n , attr , found .SelfLink )
96150 }
97151
98152 * snapshot = * found
0 commit comments