goacm

package module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 10 Imported by: 0

README

goacm

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

Features

  • List Certificates
  • Get a Certificate
TODO
  • Publish Certificate

Example

package main

import (
	"fmt"

	"github.com/michimani/goacm"
)

func main() {
	acmg, err := goacm.NewGoACM("ap-northeast-1")
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	certificates, err := goacm.ListCertificates(acmg.Client)
	if err != nil {
		fmt.Println(err.Error())
	}

	for _, c := range certificates {
		fmt.Println(c.Arn)
	}
	return
}
$ go run main.go

arn:aws:acm:ap-northeast-1:000000000000:certificate/00000000-xxxx-xxxx-0000-xxxxxxxxxxxx
arn:aws:acm:ap-northeast-1:000000000000:certificate/00000001-xxxx-xxxx-0000-xxxxxxxxxxxx
arn:aws:acm:ap-northeast-1:000000000000:certificate/00000002-xxxx-xxxx-0000-xxxxxxxxxxxx
arn:aws:acm:ap-northeast-1:000000000000:certificate/00000003-xxxx-xxxx-0000-xxxxxxxxxxxx
arn:aws:acm:ap-northeast-1:000000000000:certificate/00000004-xxxx-xxxx-0000-xxxxxxxxxxxx

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCertificate

func DeleteCertificate(api ACMDeleteCertificateAPI, arn string) error

DeleteCertificate returns an error if deleting the certificate fails.

func IssueCertificate

func IssueCertificate(aAPI ACMAPI, rAPI Route53API, method ValidationMethod, targetDomain, hostedDomain string) error

IssueCertificate issues an SSL certificate for the specified domain.

func ListCertificateSummaries

func ListCertificateSummaries(api ACMListCertificatesAPI) ([]acmTypes.CertificateSummary, error)

ListCertificateSummaries returns a list of certificate summary.

func RollbackIssueCertificate

func RollbackIssueCertificate(aAPI ACMAPI, rAPI Route53API, arn string) error

RollbackIssueCertificate rollbacks to issue an SSL certificate.

Types

type ACMAPI

ACMAPI is an interface that defines ACM API.

type ACMDeleteCertificateAPI

type ACMDeleteCertificateAPI interface {
	DeleteCertificate(ctx context.Context, params *acm.DeleteCertificateInput, optFns ...func(*acm.Options)) (*acm.DeleteCertificateOutput, error)
}

ACMDeleteCertificateAPI is an interface that defines the set of ACM API operations required by the DeleteCertificate function.

type ACMDescribeCertificateAPI

type ACMDescribeCertificateAPI interface {
	DescribeCertificate(ctx context.Context, params *acm.DescribeCertificateInput, optFns ...func(*acm.Options)) (*acm.DescribeCertificateOutput, error)
}

ACMDescribeCertificateAPI is an interface that defines the set of ACM API operations required by the DescribeCertificate function.

type ACMListCertificatesAPI

type ACMListCertificatesAPI interface {
	ListCertificates(ctx context.Context, params *acm.ListCertificatesInput, optFns ...func(*acm.Options)) (*acm.ListCertificatesOutput, error)
}

ACMListCertificatesAPI is an interface that defines the set of ACM API operations required by the ListCertificates function.

type ACMRequestCertificateAPI

type ACMRequestCertificateAPI interface {
	RequestCertificate(ctx context.Context, params *acm.RequestCertificateInput, optFns ...func(*acm.Options)) (*acm.RequestCertificateOutput, error)
}

ACMRequestCertificateAPI is an interface that defines the set of ACM API operations required by the DeleteCertificate function.

type Certificate

type Certificate struct {
	Arn           string
	Region        string
	DomainName    string
	Type          types.CertificateType
	Status        types.CertificateStatus
	FailureReason types.FailureReason
}

Certificate is a structure that represents a Certificate.

func GetCertificate

func GetCertificate(api ACMDescribeCertificateAPI, arn string) (Certificate, error)

GetCertificate returns the details of the certificate.

func ListCertificates

func ListCertificates(api ACMAPI) ([]Certificate, error)

ListCertificates returns list of certificate.

type GoACM

type GoACM struct {
	ACMClient     *acm.Client
	Route53Client *route53.Client
	Region        string
}

GoACM is a structure that wraps an ACM client.

func NewGoACM

func NewGoACM(region string) (*GoACM, error)

NewGoACM returns a new GoACM object.

type MockACMAPI

type MockACMAPI struct {
	ListCertificatesAPI    MockACMListCertificatesAPI
	DescribeCertificateAPI MockACMDescribeCertificateAPI
	DeleteCertificateAPI   MockACMDeleteCertificateAPI
	RequestCertificateAPI  MockACMRequestCertificateAPI
}

MockACMAPI is a struct that represents an ACM client.

func GenerateMockACMAPI

func GenerateMockACMAPI(mockParams []MockParams) MockACMAPI

GenerateMockACMAPI return MockACMAPI.

func (MockACMAPI) DeleteCertificate

func (m MockACMAPI) DeleteCertificate(ctx context.Context, params *acm.DeleteCertificateInput, optFns ...func(*acm.Options)) (*acm.DeleteCertificateOutput, error)

DeleteCertificate returns a function that mock original of ACM DeleteCertificate.

func (MockACMAPI) DescribeCertificate

func (m MockACMAPI) DescribeCertificate(ctx context.Context, params *acm.DescribeCertificateInput, optFns ...func(*acm.Options)) (*acm.DescribeCertificateOutput, error)

DescribeCertificate returns a function that mock original of ACM DescribeCertificate.

func (MockACMAPI) ListCertificates

func (m MockACMAPI) ListCertificates(ctx context.Context, params *acm.ListCertificatesInput, optFns ...func(*acm.Options)) (*acm.ListCertificatesOutput, error)

ListCertificates returns a function that mock original of ACM ListCertificates.

func (MockACMAPI) RequestCertificate

func (m MockACMAPI) RequestCertificate(ctx context.Context, params *acm.RequestCertificateInput, optFns ...func(*acm.Options)) (*acm.RequestCertificateOutput, error)

RequestCertificate returns a function that mock original of ACM RequestCertificate.

type MockACMDeleteCertificateAPI

type MockACMDeleteCertificateAPI func(ctx context.Context, params *acm.DeleteCertificateInput, optFns ...func(*acm.Options)) (*acm.DeleteCertificateOutput, error)

MockACMDeleteCertificateAPI is a type that represents a function that mock ACM's DeleteCertificate.

func GenerateMockACMDeleteCertificateAPI

func GenerateMockACMDeleteCertificateAPI(mockParams []MockParams) MockACMDeleteCertificateAPI

GenerateMockACMDeleteCertificateAPI returns MockACMDeleteCertificateAPI

type MockACMDescribeCertificateAPI

type MockACMDescribeCertificateAPI func(ctx context.Context, params *acm.DescribeCertificateInput, optFns ...func(*acm.Options)) (*acm.DescribeCertificateOutput, error)

MockACMDescribeCertificateAPI is a type that represents a function that mock ACM's DescribeCertificate.

func GenerateMockACMDescribeCertificateAPI

func GenerateMockACMDescribeCertificateAPI(mockParams []MockParams) MockACMDescribeCertificateAPI

GenerateMockACMDescribeCertificateAPI returns MockACMDescribeCertificateAPI.

type MockACMListCertificatesAPI

type MockACMListCertificatesAPI func(ctx context.Context, params *acm.ListCertificatesInput, optFns ...func(*acm.Options)) (*acm.ListCertificatesOutput, error)

MockACMListCertificatesAPI is a type that represents a function that mock ACM's ListCertificates.

func GenerateMockACMListCertificatesAPI

func GenerateMockACMListCertificatesAPI(mockParams []MockParams) MockACMListCertificatesAPI

GenerateMockACMListCertificatesAPI returns MockACMDescribeCertificateAPI.

type MockACMRequestCertificateAPI

type MockACMRequestCertificateAPI func(ctx context.Context, params *acm.RequestCertificateInput, optFns ...func(*acm.Options)) (*acm.RequestCertificateOutput, error)

MockACMRequestCertificateAPI is a type that represents a function that mock ACM's RequestCertificate.

func GenerateMockACMRequestCertificateAPI

func GenerateMockACMRequestCertificateAPI(mockParams []MockParams) MockACMRequestCertificateAPI

GenerateMockACMRequestCertificateAPI returns MockACMRequestCertificateAPI

type MockParams

type MockParams struct {
	Arn             string
	DomainName      string
	Status          string
	CertificateType string
	FailureReason   string
	Count           int
}

MockParams is a structure with the elements needed to generate a mock.

type Route53API

Route53API is an interface that defines Route53 API.

type Route53ChangeResourceRecordSetsAPI

type Route53ChangeResourceRecordSetsAPI interface {
	ChangeResourceRecordSets(ctx context.Context, params *route53.ChangeResourceRecordSetsInput, optFns ...func(*route53.Options)) (*route53.ChangeResourceRecordSetsOutput, error)
}

Route53ChangeResourceRecordSetsAPI is an interface that defines the set of Route53 API operations required by the ChangeResourceRecordSets function.

type Route53ListHostedZonesAPI added in v0.1.1

type Route53ListHostedZonesAPI interface {
	ListHostedZones(ctx context.Context, params *route53.ListHostedZonesInput, optFns ...func(*route53.Options)) (*route53.ListHostedZonesOutput, error)
}

Route53ListHostedZonesAPI is an interface that defines the set of Route53 API operations required by the ListHostedZone function.

type ValidationMethod

type ValidationMethod types.ValidationMethod

ValidationMethod is a type that represents the method when requesting a certificate.

const (
	// ValidationMethodDNS is a construct valur for validating certificate with DNS.
	ValidationMethodDNS ValidationMethod = "DNS"

	// ValidationMethodEmail is a construct valur for validating certificate with EMAIL.
	ValidationMethodEmail ValidationMethod = "EMAIL"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL