@@ -15,62 +15,67 @@ goacm is a simple package for using AWS Certificate Manager from applications im
1515
1616# Example
1717
18- ``` go
19- package main
18+ ## Create goacm client
2019
21- import (
22- " fmt"
20+ ``` go
21+ g , err := goacm.NewGoACM (" ap-northeast-1" )
22+ if err != nil {
23+ fmt.Println (err.Error ())
24+ return
25+ }
26+ ```
2327
24- " github.com/michimani/goacm"
25- )
28+ ## List Certificats
2629
27- func main () {
28- gacm , err := goacm.NewGoACM (" ap-northeast-1" )
29- if err != nil {
30- fmt.Println (err.Error ())
31- return
30+ ``` go
31+ if certificates , err := goacm.ListCertificates (g.ACMClient ); err != nil {
32+ fmt.Println (err.Error ())
33+ } else {
34+ fmt.Println (" DomainName\t Status\t ARN" )
35+ for _ , c := range certificates {
36+ fmt.Printf (" %s \t %s \t %s \n " , c.DomainName , c.Status , c.Arn )
3237 }
38+ }
39+ ```
3340
34- // List certificates and print each ARN.
35- fmt.Println (" List certificates and print each ARN." )
36- listCertificate (gacm)
41+ ## Get a Certificate
3742
38- // Issue an SSL certificate.
39- fmt.Println (" Issue an SSL certificate." )
40- issueCertificate (gacm)
43+ ``` go
44+ arn := " arn:aws:acm:ap-northeast-1:000000000000:certificate/xxxxxxxx-1111-1111-1111-11111111xxxx"
45+ c , err := goacm.GetCertificate (g.ACMClient , arn)
46+ if err != nil {
47+ fmt.Println (err.Error ())
48+ return
4149}
4250
43- func listCertificate (g *goacm .GoACM ) {
44- if certificates , err := goacm.ListCertificates (g.ACMClient ); err != nil {
45- fmt.Println (err.Error ())
46- } else {
47- for _ , c := range certificates {
48- fmt.Println (c.Arn )
49- }
50- }
51- }
51+ fmt.Println (" DomainName\t Status\t ARN" )
52+ fmt.Printf (" %s \t %s \t %s \n " , c.DomainName , c.Status , c.Arn )
53+ ```
5254
53- func issueCertificate (g *goacm .GoACM ) {
54- targetDomain := " goacm.example.com"
55- hostedDomain := " example.com"
56- var validationMethod goacm.ValidationMethod = " DNS"
57- if res , err := goacm.IssueCertificate (g.ACMClient , g.Route53Client , validationMethod, targetDomain, hostedDomain); err != nil {
58- fmt.Println (err.Error ())
59- } else {
60- fmt.Printf (" %v " , res)
61- }
55+ ## Issue a SSL Certificate
56+
57+ Request an ACM Certificate and create a RecordSet in Route 53 to validate the domain.
58+
59+ ``` go
60+ method := " DNS"
61+ targetDomain := " sample.exapmle.com"
62+ hostedDomain := " example.com"
63+ res , err := goacm.IssueCertificate (g.ACMClient , g.Route53Client , method, targetDomain, hostedDomain)
64+ if err != nil {
65+ fmt.Println (err.Error ())
66+ return
6267}
68+
69+ fmt.Printf (" ARN: %v " , res.CertificateArn )
6370```
6471
65- ``` bash
66- $ go run main.go
67-
68- List certificates and print each ARN.
69- arn:aws:acm:ap-northeast-1:000000000000:certificate/00000000-xxxx-xxxx-0000-xxxxxxxxxxxx
70- arn:aws:acm:ap-northeast-1:000000000000:certificate/00000001-xxxx-xxxx-0000-xxxxxxxxxxxx
71- arn:aws:acm:ap-northeast-1:000000000000:certificate/00000002-xxxx-xxxx-0000-xxxxxxxxxxxx
72- arn:aws:acm:ap-northeast-1:000000000000:certificate/00000003-xxxx-xxxx-0000-xxxxxxxxxxxx
73- arn:aws:acm:ap-northeast-1:000000000000:certificate/00000004-xxxx-xxxx-0000-xxxxxxxxxxxx
74- Issue an SSL certificate.
75- {arn:aws:acm:ap-northeast-1:000000000000:certificate/00000005-xxxx-xxxx-0000-xxxxxxxxxxxx goacm.example.com example.com /hostedzone/Z3XXXXXXXXXXXX DNS _32xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.goacm.example.com. _80xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxx.acm-validations.aws.}
72+ ## Delete a Certificate
73+
74+ Delete the Route 53 RecordSet that was created for ACM Certificate and Domain validation.
75+
76+ ``` go
77+ arn := " arn:aws:acm:ap-northeast-1:000000000000:certificate/xxxxxxxx-1111-1111-1111-11111111xxxx"
78+ if err := goacm.DeleteCertificate (g.ACMClient , g.Route53Client , arn); err != nil {
79+ fmt.Println (err.Error ())
80+ }
7681```
0 commit comments