Files
.github
.vscode
docker
internal
applicant
aliyun.go
applicant.go
aws.go
cloudflare.go
godaddy.go
httpreq.go
huaweicloud.go
namesilo.go
pdns.go
tencent.go
deployer
domain
domains
notify
pkg
repository
rest
routes
utils
migrations
ui
.dockerignore
.editorconfig
.gitignore
.goreleaser.yml
CHANGELOG.md
CONTRIBUTING.md
CONTRIBUTING_EN.md
Dockerfile
LICENSE.md
Makefile
README.md
README_EN.md
go.mod
go.sum
main.go
nixpacks.toml
usage.gif
certimate/internal/applicant/aws.go
2024-10-19 21:15:01 +08:00

40 lines
823 B
Go

package applicant
import (
"encoding/json"
"fmt"
"os"
"github.com/go-acme/lego/v4/providers/dns/route53"
"github.com/usual2970/certimate/internal/domain"
)
type aws struct {
option *ApplyOption
}
func NewAws(option *ApplyOption) Applicant {
return &aws{
option: option,
}
}
func (t *aws) Apply() (*Certificate, error) {
access := &domain.AwsAccess{}
json.Unmarshal([]byte(t.option.Access), access)
os.Setenv("AWS_REGION", access.Region)
os.Setenv("AWS_ACCESS_KEY_ID", access.AccessKeyId)
os.Setenv("AWS_SECRET_ACCESS_KEY", access.SecretAccessKey)
os.Setenv("AWS_HOSTED_ZONE_ID", access.HostedZoneId)
os.Setenv("AWS_PROPAGATION_TIMEOUT", fmt.Sprintf("%d", t.option.Timeout))
dnsProvider, err := route53.NewDNSProvider()
if err != nil {
return nil, err
}
return apply(t.option, dnsProvider)
}