Skip to content

Commit 2a1db74

Browse files
committed
Fix missing document update default version
1 parent c565ba8 commit 2a1db74

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

internal/document/document.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ func (d *Document) Deploy() error {
263263
}
264264

265265
// Create document
266-
_, err = d.clients.ssm.CreateDocument(input)
266+
_, err := d.clients.ssm.CreateDocument(input)
267+
if err != nil {
268+
return err
269+
}
267270
} else {
268271
input := &ssm.UpdateDocumentInput{
269272
Name: &d.Name,
@@ -273,7 +276,23 @@ func (d *Document) Deploy() error {
273276
}
274277

275278
// Update document
276-
_, err = d.clients.ssm.UpdateDocument(input)
279+
res, err := d.clients.ssm.UpdateDocument(input)
280+
if err != nil {
281+
if awsErr, ok := err.(awserr.Error); ok {
282+
if awsErr.Code() != ssm.ErrCodeDuplicateDocumentContent {
283+
return err
284+
}
285+
}
286+
} else {
287+
// Update latest document version
288+
_, err = d.clients.ssm.UpdateDocumentDefaultVersion(&ssm.UpdateDocumentDefaultVersionInput{
289+
Name: &d.Name,
290+
DocumentVersion: res.DocumentDescription.DocumentVersion,
291+
})
292+
if err != nil {
293+
return err
294+
}
295+
}
277296
}
278297

279298
// Check for deploy error

0 commit comments

Comments
 (0)