Hi, I am trying to create an `A` record in route53...
# aws
c
Hi, I am trying to create an
A
record in route53 with a quick alias to an s3 static website but I keep getting this type of error, any ideas?
Copy code
creating Route53 Record: operation error Route 53: ChangeResourceRecordSets, https response error StatusCode: 400, RequestID: d65c414d-140e-4da6-bc67-ee588f2a97ca, InvalidChangeBatch: [Tried to create an alias that targets BUCKETNAME.s3.amazonaws.com., type A in zone Z21DNDUVLTQW6Q, but the alias target name does not lie within the target zone]
code:
Copy code
hosted_zone = aws.route53.get_zone(name=domain_name)

    aws.route53.Record(
        f"{environment}-frontend-hosting-record",
        name=full_domain_name,
        type="A",
        aliases=[
            aws.route53.RecordAliasArgs(
                evaluate_target_health=True,
                name=bucket.bucket_domain_name,
                zone_id=bucket.hosted_zone_id,
            )
        ],
        zone_id=hosted_zone.id,
    )
q
I think the
name
of the alias is set wrong. It shouldn't be set to
bucket_domain_name
but instead the website endpoint IIRC
c
just figured it out πŸ˜„
Record.name
should match the bucket name, and alias name should be hardcoded as follows
Copy code
aws.route53.Record(
        f"{environment}-frontend-hosting-record",
        name=full_domain_name,
        type="A",
        aliases=[
            aws.route53.RecordAliasArgs(
                evaluate_target_health=True,
                name="<http://s3-website.eu-central-1.amazonaws.com|s3-website.eu-central-1.amazonaws.com>",
                zone_id=bucket.hosted_zone_id,
            )
        ],
        zone_id=hosted_zone.id,
    )
q
I don't recall
Record.name
having to match anythng /wrt the bucket, I think (but maybe my memory is betraying me) that it can be an arbitrary domain name. Btw, you do not need to hardcode
"<http://s3-website.eu-central-1.amazonaws.com|s3-website.eu-central-1.amazonaws.com>"
. Your
BucketWebsiteConfigurationV2
(or
Bucket
, depending on what resources you use) should have a
websiteEndpoint
output that you can use πŸ™‚
c
I don’t recall
Record.name
having to match anythng /wrt the bucket, I think (but maybe my memory is betraying me) that it can be an arbitrary domain name.
well documentation says so πŸ˜„
Copy code
The bucket name should match the name that appears in the Name box.
Btw, you do not need to hardcode
"<http://s3-website.eu-central-1.amazonaws.com|s3-website.eu-central-1.amazonaws.com>"
. Your
BucketWebsiteConfigurationV2
(or
Bucket
, depending on what resources you use) should have a
websiteEndpoint
output that you can use πŸ™‚
that wouldnt work, we dont need to insert the full bucket website but only the hardcoded part I put.. this is actually directly suggested by AWS ( look at gui screenshot )
q
Ah well you're right about the bucket name! Seems like my memory was indeed betraying me here!
c
happens to the best of us πŸ˜„ thanks!