Skip to content

Commit d11e814

Browse files
committed
fix acm delete
1 parent 2488dd7 commit d11e814

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Imported arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/zzzzzzzz-zzzz-zzzz-zzzz-
138138

139139
```console
140140
$ ./aws-cert-utils acm delete
141-
? Choose the server certificate you want to delete : arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
141+
? Choose the server certificate you want to delete : [example.com] arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
142142
Deleted arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
143143
```
144144

acm.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,21 @@ func (a *ACM) List(statuses string, maxItems int64, nextToken string) ([]ACMDesc
117117
return descs, err
118118
}
119119

120-
func (a *ACM) ListArns(statuses string, maxItems int64, nextToken string) ([]string, error) {
120+
func (a *ACM) ListDeleteTargets(statuses string, maxItems int64, nextToken string) ([]string, map[string]string, error) {
121121
descs, err := a.List(statuses, maxItems, nextToken)
122+
if err != nil {
123+
return []string{}, map[string]string{}, err
124+
}
122125

126+
targets := make(map[string]string, 0)
123127
arns := make([]string, 0, len(descs))
124128
for _, desc := range descs {
125-
arns = append(arns, desc.arn)
129+
tagArn := fmt.Sprintf("[%s] %s", desc.nameTag, desc.arn)
130+
arns = append(arns, tagArn)
131+
targets[tagArn] = desc.arn
126132
}
127133

128-
return arns, err
134+
return arns, targets, err
129135
}
130136

131137
func toACMTags(tags []Tag) []*acm.Tag {

cli/aws-cert-utils/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,14 @@ func main() {
217217
case "delete":
218218
arn := *acmDeleteArn
219219
if arn == "" {
220-
arns, err := a.ListArns(*acmDeleteStatuses, int64(*acmDeleteMaxItems), "")
220+
arns, targets, err := a.ListDeleteTargets(*acmDeleteStatuses, int64(*acmDeleteMaxItems), "")
221221
if err != nil {
222222
log.Fatal(err)
223223
}
224224
arn = certutils.Choice(arns, "Choose the server certificate you want to delete : ", 20)
225225

226+
arn = targets[arn]
227+
226228
if arn == "" {
227229
os.Exit(0)
228230
}

0 commit comments

Comments
 (0)