Skip to content

Commit e771f41

Browse files
author
ccushing
committed
Instance resource outputs useful error message when trying to update 'ssh_authorized_keys' or 'user_data'
1 parent 35eed83 commit e771f41

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

oci/core_instance_resource.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,16 @@ func (s *InstanceResourceCrud) Update() error {
557557

558558
response, err := s.Client.UpdateInstance(context.Background(), request)
559559
if err != nil {
560+
if response.RawResponse.StatusCode == 400 &&
561+
strings.Contains(err.Error(), "metadata field cannot be updated") {
562+
return fmt.Errorf(`%s
563+
564+
To change 'ssh_authorized_keys' or 'user_data' properties in the
565+
'metadata' field, the resource must be tainted and recreated.
566+
Use the terraform "taint" command to target this resource then
567+
run apply again.`, err)
568+
}
569+
560570
return err
561571
}
562572

0 commit comments

Comments
 (0)