def create_alias_record(alias_domain, distribution): zone_id = route53.get_zone(name=alias_domain).id return route53.Record(alias_domain, name="", zone_id=zone_id, type='A', aliases=[ route53.RecordAliasArgs( name=distribution.domain_name, zone_id=distribution.hosted_zone_id, evaluate_target_health=True, ) ])
def find_zone(domain): """ Attempts to find the Route53 zone for the given domain. """ # FIXME: Cache these results zonename = domain while '.' in zonename: try: zone = route53.get_zone(name=zonename) except Exception: _, zonename = zonename.split('.', 1) else: return zone else: raise ZoneNotFoundError(f"Unable to find zone for domain {domain}")
import pulumi from putils import opts from staticsite import StaticSite from pulumi_aws import route53 config = pulumi.Config('castle') zone = route53.get_zone(name='dingbots.dev') # Create an AWS resource (S3 Bucket) site = StaticSite( 'MainSite', domain=config.require('domain'), zone=zone, content_dir='www', **opts(), ) pulumi.export('website', site.url)
def get_hosted_zone(self): """ Get Route53 Hosted Zone """ zone = route53.get_zone(name=self.zone_name) return zone