Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix: prevent duplicate hosted zone creation (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanketD92 authored Nov 8, 2021
1 parent 831da13 commit ac72b90
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions main/solution/infrastructure/config/infra/cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ Conditions:
IsDev: !Equals ['${self:custom.settings.envType}', 'dev']
UseCustomDomain: !Not
- !Equals ['${self:custom.settings.domainName}', '']
UseHostedZoneId: !Not
- !Equals ['${self:custom.settings.hostedZoneId}', '']
CustomDomainWithoutHostedZoneId: !And
- !Not
- !Equals ['${self:custom.settings.domainName}', '']
- !Equals ['${self:custom.settings.hostedZoneId}', '']

Description: (SO0144) Service Workbench on AWS Solution

Expand Down Expand Up @@ -176,7 +182,7 @@ Resources:

HostedZone:
Type: AWS::Route53::HostedZone
Condition: UseCustomDomain
Condition: CustomDomainWithoutHostedZoneId
DeletionPolicy: Retain
Properties:
Name: ${self:custom.settings.domainName}
Expand All @@ -185,7 +191,12 @@ Resources:
Type: AWS::Route53::RecordSetGroup
Condition: UseCustomDomain
Properties:
HostedZoneId: !Ref HostedZone
# Blank hosted zone ID in stage file creates a new one
# This is to ensure backwards compatibility
HostedZoneId: !If
- UseHostedZoneId
- ${self:custom.settings.hostedZoneId}
- !Ref HostedZone
RecordSets:
- Name: ${self:custom.settings.domainName}
Type: A
Expand Down Expand Up @@ -214,8 +225,9 @@ Outputs:
Value: !Ref WebsiteCloudFront

HostedZoneId:
Condition: UseCustomDomain
Description: Id of the hosted zone created when a custom domain is used
Value: !If
- UseCustomDomain
- UseHostedZoneId
- ${self:custom.settings.hostedZoneId}
- !Ref HostedZone
- 'NotSetAsCustomDomainDisabled'

0 comments on commit ac72b90

Please sign in to comment.