Example #1
0
    def getTemplate(self):
        if self.elbName is not None:
            hostedZoneId=GetAtt(self.elbName,'CanonicalHostedZoneNameID')
            dnsName=GetAtt(self.elbName,'DNSName')
            aliasTarget=AliasTarget(hostedZoneId, dnsName)

            self.template.add_resource(RecordSetGroup(
            "DNS",
            HostedZoneName=Join(".", [ self.projectBaseURL, ""]),
            RecordSets=[
                RecordSet(
                    SetIdentifier=Join(" ", [ self.friendlyName, self.branch, self.projectBaseURL ] ),
                    Name=Join(" ", [ self.friendlyName, self.branch, self.projectBaseURL ] ),
                    Type="A",
                    AliasTarget=aliasTarget
                )
            ]))
        else:
            self.template.add_resource(RecordSetGroup(
            "DNS",
            HostedZoneName=Join(".", [ self.projectBaseURL, ""]),
            RecordSets=[
                RecordSet(
                    SetIdentifier=Join(" ", [ self.friendlyName, self.branch, self.projectBaseURL ] ),
                    Name=Join(" ", [ self.friendlyName, self.branch, self.projectBaseURL ] ),
                    Type="A",
                    ResourceRecords=[ GetAtt(self.launchConfigName, 'PublicIp')]
                )
            ]))

        return self.template
Example #2
0
 def dns(self, host, zone, ttl=3600):
     if not zone.endswith('.'):
         zone = zone + '.'
     self.template.add_resource(
         RecordSetGroup(
             ("RSG" + hashlib.sha1(zone + host).hexdigest())[:10],
             Comment=Ref("AWS::StackName"),
             HostedZoneName=zone,
             RecordSets=[
                 RecordSet(Name="%s.%s" % (host, zone),
                           Type="CNAME",
                           ResourceRecords=[GetAtt("ELB", "DNSName")],
                           TTL=ttl)
             ]))
Example #3
0
 RecordSetGroup(
     "myDNSRecord",
     HostedZoneName=Join("", [Ref(hostedzone), "."]),
     Comment=
     "Contrived example to redirect to aws.amazon.com 75% of the time "
     "and www.amazon.com 25% of the time.",
     RecordSets=[
         RecordSet(
             SetIdentifier=Join(" ", [Ref("AWS::StackName"), "AWS"]),
             Name=Join("", [
                 Ref("AWS::StackName"), ".",
                 Ref("AWS::Region"), ".",
                 Ref(hostedzone), "."
             ]),
             Type="CNAME",
             TTL="900",
             ResourceRecords=["aws.amazon.com"],
             Weight="3",
         ),
         RecordSet(
             SetIdentifier=Join(" ", [Ref("AWS::StackName"), "Amazon"]),
             Name=Join("", [
                 Ref("AWS::StackName"), ".",
                 Ref("AWS::Region"), ".",
                 Ref(hostedzone), "."
             ]),
             Type="CNAME",
             TTL="900",
             ResourceRecords=["www.amazon.com"],
             Weight="1",
         ),
     ],
 ))
                  AliasTarget=AliasTarget(
                      FindInMap("RegionMap", Ref("AWS::Region"),
                                "hostedzoneID"),
                      FindInMap("RegionMap", Ref("AWS::Region"),
                                "websiteendpoint"))),
        RecordSet(Name=Join("", ["www.", Ref(HostedZoneName), "."]),
                  Type="CNAME",
                  TTL="900",
                  ResourceRecords=[
                      GetAtt(StaticSiteBucketDistribution, "DomainName")
                  ]),
    ]

StaticSiteDNSRecord = t.add_resource(
    RecordSetGroup("StaticSiteDNSRecord",
                   HostedZoneName=Join("", [Ref(HostedZoneName), "."]),
                   Comment="Records for the root of the hosted zone",
                   RecordSets=record_sets))

t.add_output(
    Output("CloudfrontDomainName",
           Description="Cloudfront domain name",
           Value=GetAtt(StaticSiteBucketDistribution, "DomainName")))

t.add_output(
    Output("S3WebsiteURL",
           Description="S3 Website URL",
           Value=GetAtt(wwwStaticSiteBucket, "WebsiteURL")))


def get():
    return t.to_yaml()
Example #5
0
        Type="String",
        Description=(
            "Backend hostname for your component (e.g. '[component-name]."
            "[env.]account-identifier.xhst.bbci.co.uk')")))

record_set_group = t.add_resource(
    RecordSetGroup(
        "RecordSetGroup",
        HostedZoneName=Ref(hosted_zone_name),
        RecordSets=[{
            "Name":
            Join("", [
                Ref(component_cname),
                Ref(environment),
                Ref(hosted_zone_name)
            ]),
            "Type":
            "CNAME",
            "TTL":
            "3600",
            "ResourceRecords":
            [Join("", [Ref(component_cname),
                       Ref(environment),
                       Ref(backend)])]
        }]))

template = t.to_json()
if len(sys.argv) > 1:
    open(sys.argv[1], "w").write(template + "\n")
else:
    print(template)
Example #6
0
  #DependsOn=["EC2Instance1", "EC2Instance2"]
  DependsOn=["Wait4Instance"]
))

PublicRecords=[
  RecordSet(
    Name=Join("",[ "demo.", Ref(HostedZone), "."]),
    Type="CNAME",
    TTL="400",
    ResourceRecords=[GetAtt("PublicLoadBalancer","DNSName")]
  )
 ]

PublicRecordSet=t.add_resource(RecordSetGroup(
  "PublicRecordSet",
  HostedZoneName=Join("",[Ref(HostedZone),"."]),
  Comment="Public Record sets",
  RecordSets=PublicRecords
))

t.add_output([
    Output(
        "InstanceId",
        Description="InstanceId of the newly created EC2 instance",
        Value=Ref(EC2Instance1),
    ),
    Output(
        "PublicIP",
        Description="Public IP address of the newly created EC2 instance",
        Value=GetAtt(EC2Instance1, "PublicIp"),
    ),
    Output(
 RecordSetGroup(
     'DnsRecords',
     Comment=Ref(AWS_STACK_NAME),
     HostedZoneId=ImportValue(Join('-', [Ref(dns_stack), 'HostedZoneId'])),
     RecordSets=[
         RecordSet(
             Name='robkenis.com',
             Type='A',
             AliasTarget=AliasTarget(
                 DNSName=GetAtt(cloudfront, 'DomainName'),
                 HostedZoneId='Z2FDTNDATAQYW2',
             ),
         ),
         RecordSet(
             Name='robkenis.com',
             Type='AAAA',
             AliasTarget=AliasTarget(
                 DNSName=GetAtt(cloudfront, 'DomainName'),
                 HostedZoneId='Z2FDTNDATAQYW2',
             ),
         ),
         RecordSet(
             Name='www.robkenis.com',
             Type='A',
             AliasTarget=AliasTarget(
                 DNSName=GetAtt(cloudfront, 'DomainName'),
                 HostedZoneId='Z2FDTNDATAQYW2',
             ),
         ),
         RecordSet(
             Name='www.robkenis.com',
             Type='AAAA',
             AliasTarget=AliasTarget(
                 DNSName=GetAtt(cloudfront, 'DomainName'),
                 HostedZoneId='Z2FDTNDATAQYW2',
             ),
         ),
     ],
 ))
Example #8
0
        ),
    ))

template.add_resource(
    RecordSetGroup(
        "DnsRecords",
        HostedZoneId=ImportValue(Join('-', [Ref(dns_stack), 'HostedZoneId'])),
        RecordSets=[
            RecordSet(
                Name=Ref(domain_name),
                Type='A',
                AliasTarget=AliasTarget(
                    HostedZoneId='Z2FDTNDATAQYW2',
                    DNSName=GetAtt(video_cdn, 'DomainName'),
                ),
            ),
            RecordSet(
                Name=Ref(domain_name),
                Type='AAAA',
                AliasTarget=AliasTarget(
                    HostedZoneId='Z2FDTNDATAQYW2',
                    DNSName=GetAtt(video_cdn, 'DomainName'),
                ),
            )
        ],
        Comment=Join('', ['Record for CloudFront in ',
                          Ref(AWS_STACK_NAME)]),
    ))

f = open("output/video_cdn.json", "w")
f.write(template.to_json())
Example #9
0
# )

alb_record_set_group = RecordSetGroup(
    region.replace("-", "") + "ecsliveorigindnsrecordsetgroup",
    HostedZoneId = hosted_zone_id,
    RecordSets = [
        RecordSet(
            Name = GetAtt(certificate_dns_record, "Name"),
            Type = GetAtt(certificate_dns_record, "Type"),
            TTL = "60",
            Weight = "1",
            SetIdentifier = Ref(origin_certificate),
            ResourceRecords = [
                GetAtt(certificate_dns_record, "Value")
            ]
        ),
        RecordSet(
            "origindnsrecord",
            AliasTarget = AliasTarget(
                DNSName = GetAtt(application_load_balancer, "DNSName"),
                EvaluateTargetHealth = False,
                HostedZoneId = GetAtt(application_load_balancer, "CanonicalHostedZoneID")
            ),
            Name = "origin.public.eu-west-1.weblox.io.",
            Type = "A",
            Weight = "1",
            SetIdentifier = "origin",
        )
    ]
)

template.add_resource(origin_certificate),
Example #10
0
                # ApiGateway 의 TTL 을 최대 10분으로 설정한다.
                MaxTTL=600,
            ),
            DefaultRootObject="index.html",
            Enabled=True,
            PriceClass="PriceClass_All",
            HttpVersion="http2",
        ),
    ))

template.add_resource(
    RecordSetGroup(
        "AssetsDNSName",
        HostedZoneName=Join("", [root_domain_name, "."]),
        Comment="Zone apex alias.",
        RecordSets=[
            RecordSet(
                Name=api_domain_name,
                Type="A",
                AliasTarget=AliasTarget(
                    # CloudFront 는 HostedZoneId 가 하나이다.
                    HostedZoneId="Z2FDTNDATAQYW2",
                    DNSName=GetAtt(distribution, "DomainName")),
            ),
        ],
    ))


def get():
    return template.to_yaml()
    '_ccfe3690ea1cbc3f70ac9330debed77d.admin.spunt.be.':
    '_cd81118a1eddc7ee8e96a5d138582443.mzlfeqexyx.acm-validations.aws.',
}

template = Template(Description='Spunt.be validation records')

dns_stack = template.add_parameter(
    Parameter(
        'DnsStack',
        Type=constants.STRING,
        Default='spunt-punt-be-dns',
    ))

_hosted_zone_id = ImportValue(Join('-', [Ref(dns_stack), 'HostedZoneId']))

template.add_resource(
    RecordSetGroup('ValidationRecords',
                   HostedZoneId=_hosted_zone_id,
                   Comment='Validation records for ACM',
                   RecordSets=list(
                       map(
                           lambda name: RecordSet(
                               Name=name,
                               Type='CNAME',
                               TTL=900,
                               ResourceRecords=[RECORDS[name]],
                           ), RECORDS.keys()))))

f = open("output/validation_records.json", "w")
f.write(template.to_json())
Example #12
0
template.add_resource(BasePathMapping(
    'ApiMapping',
    DomainName=Ref(domain_name),
    RestApiId=Ref(admin_api),
    Stage='v1'
))

template.add_resource(RecordSetGroup(
    "DnsRecords",
    HostedZoneId=ImportValue(Join('-', [Ref(dns_stack), 'HostedZoneId'])),
    RecordSets=[RecordSet(
        Name=Ref(domain_name),
        Type='A',
        AliasTarget=AliasTarget(
            HostedZoneId=GetAtt(api_domain_name, 'RegionalHostedZoneId'),
            DNSName=GetAtt(api_domain_name, 'RegionalDomainName'),
        ),
    ), RecordSet(
        Name=Ref(domain_name),
        Type='AAAA',
        AliasTarget=AliasTarget(
            HostedZoneId=GetAtt(api_domain_name, 'RegionalHostedZoneId'),
            DNSName=GetAtt(api_domain_name, 'RegionalDomainName'),
        ),
    )],
    Comment=Join('', ['Record for Api Gateway in ', Ref(AWS_STACK_NAME)]),
))

f = open("output/spunt_video_admin.json", "w")
f.write(template.to_json())
Example #13
0
           BucketName=Join('.', ['www', Ref(hostedzone)]),
           AccessControl=PublicRead,
           WebsiteConfiguration=WebsiteConfiguration(
               RedirectAllRequestsTo=RedirectAllRequestsTo(
                   HostName=Ref(root_bucket)))))

record = t.add_resource(
    RecordSetGroup(
        'RecordSetGroup',
        HostedZoneName=Join("", [Ref(hostedzone), "."]),
        RecordSets=[
            RecordSet(Name=Ref(hostedzone),
                      Type='A',
                      AliasTarget=AliasTarget(
                          hostedzoneid=FindInMap('RegionMap',
                                                 Ref('AWS::Region'),
                                                 'S3hostedzoneID'),
                          dnsname=FindInMap('RegionMap', Ref('AWS::Region'),
                                            'websiteendpoint'),
                      )),
            RecordSet(Name=Join('.', ['www', Ref(hostedzone)]),
                      Type='CNAME',
                      TTL='900',
                      ResourceRecords=[GetAtt(www_bucket, 'DomainName')]),
        ]))

t.add_output(
    Output("BucketName",
           Value=Ref(root_bucket),
           Description="Name of S3 bucket to hold website content"))

#print(t.to_json())
Example #14
0
from troposphere.route53 import AliasTarget, RecordSetType, RecordSetGroup, RecordSet

t = Template()

myDNSRecord = t.add_resource(
    RecordSetGroup(
        "devdevopsdemoELBDNSARecord0",
        HostedZoneName=Join("", ["example.net", "."]),
        Comment="DNS Entry to point to the ELB for devopsdemo",
        RecordSets=[
            RecordSet(
                Name="devopsdemo.dev.example.net.",
                Type="A",
                AliasTarget=AliasTarget(
                    GetAtt("devdevopsdemoELB", "CanonicalHostedZoneNameID"),
                    GetAtt("devdevopsdemoELB", "CanonicalHostedZoneName"),
                ),
            ),
            RecordSet(
                Name="devopsdemo-dev.example.net.",
                Type="A",
                AliasTarget=AliasTarget(
                    GetAtt("devdevopsdemoELB", "CanonicalHostedZoneNameID"),
                    GetAtt("devdevopsdemoELB", "CanonicalHostedZoneName"),
                ),
            ),
        ],
    ))

print t.to_json()
Example #15
0
        ValidationDomain=ImportValue(Join('-', [Ref(dns_stack), 'HostedZoneName'])),
    )],
    ValidationMethod='DNS',
))

template.add_resource(RecordSetGroup(
    "DnsRecords",
    HostedZoneId=ImportValue(Join('-', [Ref(dns_stack), 'HostedZoneId'])),
    RecordSets=[RecordSet(
        Name=Ref(domain_name),
        Type='A',
        AliasTarget=AliasTarget(
            HostedZoneId='Z2FDTNDATAQYW2',
            DNSName=Ref(cognito_domain_name),
        ),
    ), RecordSet(
        Name=Ref(domain_name),
        Type='AAAA',
        AliasTarget=AliasTarget(
            HostedZoneId='Z2FDTNDATAQYW2',
            DNSName=Ref(cognito_domain_name),
        ),
    )],
    Comment=Join('', ['Record for Cognito in ', Ref(AWS_STACK_NAME)]),
    Condition=DOMAIN_IS_CREATED,
))

user_pool = template.add_resource(UserPool(
    'UserPool',
    UserPoolName=Ref(AWS_STACK_NAME),
    MfaConfiguration='OFF',