Skip to content

Commit b2cd6f9

Browse files
committed
Merge branch 'seang96-rewrite-record-option-support' into next
2 parents 48f035b + c755648 commit b2cd6f9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ open serverless.yml and add the following:
8181
tags:
8282
Name: 'somedomain.com'
8383
Environment: 'prod'
84+
//optional default false. this is useful if you managed to delete your certificate but the dns validation records still exist
85+
rewriteRecords: false
8486

8587

8688
now you can run:
@@ -122,6 +124,7 @@ Open serverless.yml and add the following:
122124
hostedZoneIds: 'XXXXXXXXX' //required if hostedZoneNames is not set
123125
region: eu-west-1 // optional - default is us-east-1 which is required for custom api gateway domains of Type Edge (default)
124126
enabled: true // optional - default is true. For some stages you may not want to use certificates (and custom domains associated with it).
127+
rewriteRecords: false
125128

126129
Now you can run:
127130

examples/certificate-creator-example/serverless.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ custom:
4848
- 'certcreatorsample2.greenelephant.io'
4949
tags:
5050
Name: 'somedomain.com'
51-
Environment: 'prod'
51+
Environment: 'prod'
52+
rewriteRecords: false

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CreateCertificatePlugin {
5555
this.acm = new this.serverless.providers.aws.sdk.ACM(acmCredentials);
5656
this.idempotencyToken = this.serverless.service.custom.customCertificate.idempotencyToken;
5757
this.writeCertInfoToFile = this.serverless.service.custom.customCertificate.writeCertInfoToFile || false;
58+
this.rewriteRecords = this.serverless.service.custom.customCertificate.rewriteRecords || false;
5859
this.certInfoFileName = this.serverless.service.custom.customCertificate.certInfoFileName || 'cert-info.yml';
5960
this.subjectAlternativeNames = this.serverless.service.custom.customCertificate.subjectAlternativeNames || [];
6061
this.tags = this.serverless.service.custom.customCertificate.tags || {};
@@ -268,7 +269,7 @@ class CreateCertificatePlugin {
268269
return Promise.all(hostedZoneIds.map(({ hostedZoneId, Name }) => {
269270
let changes = certificate.Certificate.DomainValidationOptions.filter(({DomainName}) => DomainName.endsWith(Name)).map((x) => {
270271
return {
271-
Action: "CREATE",
272+
Action: this.rewriteRecords ? "UPSERT" : "CREATE",
272273
ResourceRecordSet: {
273274
Name: x.ResourceRecord.Name,
274275
ResourceRecords: [

0 commit comments

Comments
 (0)