Categorygithub.com/michimani/goacm
modulepackage
0.3.3
Repository: https://github.com/michimani/goacm.git
Documentation: pkg.go.dev

# README

goacm

goacm is a simple package for using AWS Certificate Manager from applications implimented golang.

Features

  • List Certificates
  • Get a Certificate
  • Delete a Certificate
    • with Route 53 RecordSet that validates the domain (if validation method is DNS)
  • Issue an SSL Certificate
    • Create Certificate
    • Create Route 53 RecordSet for validating the domain (if validation method is DNS)

Example

Create goacm client

ctx := context.TODO()
g, err := goacm.NewGoACM(ctx, "ap-northeast-1")
if err != nil {
	fmt.Println(err.Error())
	return
}

List Certificats

ctx := context.TODO()
if certificates, err := goacm.ListCertificates(ctx, g.ACMClient); err != nil {
	fmt.Println(err.Error())
} else {
	fmt.Println("DomainName\tStatus\tARN")
	for _, c := range certificates {
		fmt.Printf("%s\t%s\t%s\n", c.DomainName, c.Status, c.Arn)
	}
}

Get a Certificate

arn := "arn:aws:acm:ap-northeast-1:000000000000:certificate/xxxxxxxx-1111-1111-1111-11111111xxxx"
ctx := context.TODO()
c, err := goacm.GetCertificate(ctx, g.ACMClient, arn)
if err != nil {
	fmt.Println(err.Error())
	return
}

fmt.Println("DomainName\tStatus\tARN")
fmt.Printf("%s\t%s\t%s\n", c.DomainName, c.Status, c.Arn)

Issue a SSL Certificate

Request an ACM Certificate and create a RecordSet in Route 53 to validate the domain.

method := "DNS"
targetDomain := "sample.exapmle.com"
hostedDomain := "example.com"
ctx := context.TODO()
res, err := goacm.IssueCertificate(ctx, g.ACMClient, g.Route53Client, method, targetDomain, hostedDomain)
if err != nil {
	fmt.Println(err.Error())
	return
}

fmt.Printf("ARN: %v", res.CertificateArn)

Delete a Certificate

Delete the Route 53 RecordSet that was created for ACM Certificate and Domain validation.

arn := "arn:aws:acm:ap-northeast-1:000000000000:certificate/xxxxxxxx-1111-1111-1111-11111111xxxx"
ctx := context.TODO()
if err := goacm.DeleteCertificate(ctx, g.ACMClient, g.Route53Client, arn); err != nil {
	fmt.Println(err.Error())
}

# Functions

DeleteCertificate returns an error if deleting the certificate fails.
DeleteRoute53RecordSet deletes a Route 53 record set.
GetCertificate returns the details of the certificate.
IssueCertificate issues an SSL certificate for the specified domain.
ListCertificates returns list of certificate.
ListCertificateSummaries returns a list of certificate summary.
NewGoACM returns a new GoACM object.
NewMockACMAPI return MockACMAPI.
NewMockACMDeleteCertificateAPI returns MockACMDeleteCertificateAPI.
NewMockACMDescribeCertificateAPI returns MockACMDescribeCertificateAPI.
NewMockACMListCertificatesAPI returns MockACMDescribeCertificateAPI.
NewMockACMRequestCertificateAPI returns MockACMRequestCertificateAPI.
NewMockChangeResourceRecordSetsAPI returns MockChangeResourceRecordSetsAPI.
NewMockListHostedZonesAPI returns MockListHostedZonesAPI.
NewMockListResourceRecordSetsAPI returns MockListResourceRecordSetsAPI.
NewMockRoute53API returns MockRoute53API.
RollbackIssueCertificate rollbacks to issue an SSL certificate.

# Structs

Certificate is a structure that represents a Certificate.
GoACM is a structure that wraps an ACM client.
IssueCertificateResult is a structure that represents a reault of IssueCertificate.
MockACMAPI is a struct that represents an ACM client.
MockACMParams is a structure with the elements needed to generate a mock.
MockRoute53API is a struct that represents a Route 53 client.
MockRoute53Params is a structure with the elements needed to generate a mock.
RecordSet is a structure that reopresents a record set for Route 53.

# Interfaces

ACMAPI is an interface that defines ACM API.
ACMDeleteCertificateAPI is an interface that defines the set of ACM API operations required by the DeleteCertificate function.
ACMDescribeCertificateAPI is an interface that defines the set of ACM API operations required by the DescribeCertificate function.
ACMListCertificatesAPI is an interface that defines the set of ACM API operations required by the ListCertificates function.
ACMRequestCertificateAPI is an interface that defines the set of ACM API operations required by the DeleteCertificate function.
Route53API is an interface that defines Route53 API.
Route53ChangeResourceRecordSetsAPI is an interface that defines the set of Route 53 API operations required by the ChangeResourceRecordSets function.
Route53ListHostedZonesAPI is an interface that defines the set of Route 53 API operations required by the ListHostedZone function.
Route53ListResourceRecordSetsAPI is an interface that defines the set of Route 53 API operations required by the ListResourceRecordSets function.

# Type aliases

MockACMDeleteCertificateAPI is a type that represents a function that mock ACM's DeleteCertificate.
MockACMDescribeCertificateAPI is a type that represents a function that mock ACM's DescribeCertificate.
MockACMListCertificatesAPI is a type that represents a function that mock ACM's ListCertificates.
MockACMRequestCertificateAPI is a type that represents a function that mock ACM's RequestCertificate.
MockChangeResourceRecordSetsAPI is a type that represents a function that mock Route 53's MockChangeResourceRecordSets.
MockListHostedZonesAPI is a type that represents a function that mock Route 53's MockListHostedZones.
MockListResourceRecordSetsAPI is a type that represents a function that mock Route 53's MockListResourceRecordSets.