Skip to content

Commit

Permalink
- Added A Alias support to route53 record sets.
Browse files Browse the repository at this point in the history
  • Loading branch information
gitwater committed Mar 11, 2021
1 parent 52f9c73 commit ebeaadf
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/paco/cftemplates/route53_hostedzone.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,26 @@ def __init__(self, stack, paco_ctx):
if len(zone_config.record_sets) > 0:
record_set_list = []
for record_set_config in zone_config.record_sets:
record_set_res = troposphere.route53.RecordSet(
Name=record_set_config.record_name,
Type=record_set_config.type,
TTL=record_set_config.ttl,
ResourceRecords=record_set_config.resource_records
)
record_set_dict = {
'Name': record_set_config.record_name,
}
if record_set_config.type == 'Alias':
record_set_dict['Type'] = 'A'
if record_set_config.resource_records[0].find('cloudfront.net') != -1:
hosted_zone_id = 'Z2FDTNDATAQYW2'
elif record_set_config.resource_records[0].find('elb.amazonaws.com') != -1:
elb_region = record_set_config.resource_records[0].split('.')[1]
hosted_zone_id = self.lb_hosted_zone_id('alb', elb_region)
record_set_dict['AliasTarget'] = troposphere.route53.AliasTarget(
HostedZoneId=hosted_zone_id,
DNSName=record_set_config.resource_records[0]
)
else:
record_set_dict['Type'] = record_set_config.type
record_set_dict['ResourceRecords'] = record_set_config.resource_records
record_set_dict['TTL'] = record_set_config.ttl

record_set_res = troposphere.route53.RecordSet(**record_set_dict)
record_set_list.append(record_set_res)

group_res = troposphere.route53.RecordSetGroup(
Expand Down

0 comments on commit ebeaadf

Please sign in to comment.