Skip to content

Commit

Permalink
Add condition for custom URL in cfn template
Browse files Browse the repository at this point in the history
  • Loading branch information
dakotabenjamin authored and willemarcel committed Jan 5, 2021
1 parent 0a0e89d commit 96241ae
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/aws/cloudformation/tasking-manager.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ const Parameters = {
},
TaskingManagerURL: {
Description: 'URL for setting CNAME in Distribution; Ex: example.hotosm.org',
Type: 'String'
Type: 'String',
AllowedPattern: '^([a-zA-Z0-9-]*\\.){2}(\\w){2,20}$',
ConstraintDescription: 'Parameter must be in the form of a url with subdomain.'
},
TaskingManagerOrgName: {
Description: 'Org Name',
Expand All @@ -134,7 +136,10 @@ const Conditions = {
UseASnapshot: cf.notEquals(cf.ref('DBSnapshot'), ''),
DatabaseDumpFileGiven: cf.notEquals(cf.ref('DatabaseDump'), ''),
IsTaskingManagerProduction: cf.equals(cf.ref('AutoscalingPolicy'), 'production'),
IsTaskingManagerDemo: cf.equals(cf.ref('AutoscalingPolicy'), 'Demo (max 3)')
IsTaskingManagerDemo: cf.equals(cf.ref('AutoscalingPolicy'), 'Demo (max 3)'),
IsHOTOSMUrl: cf.equals(
cf.select('1', cf.split('.', cf.ref('TaskingManagerURL')))
, 'hotosm')
};

const Resources = {
Expand Down Expand Up @@ -708,6 +713,7 @@ const Resources = {
},
TaskingManagerRoute53: {
Type: 'AWS::Route53::RecordSet',
Condition: 'IsHOTOSMUrl',
Properties: {
Name: cf.ref('TaskingManagerURL'),
Type: 'A',
Expand Down

0 comments on commit 96241ae

Please sign in to comment.