creamy-beard-50597
01/13/2025, 11:25 AMA record in route53 with a quick alias to an s3 static website but I keep getting this type of error, any ideas?
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]creamy-beard-50597
01/13/2025, 11:25 AMhosted_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,
    )quick-house-41860
01/13/2025, 11:35 AMname of the alias is set wrong. It shouldn't be set to bucket_domain_name but instead the website endpoint IIRCcreamy-beard-50597
01/13/2025, 11:37 AMRecord.name should match the bucket name, and alias name should be hardcoded as follows
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,
    )quick-house-41860
01/13/2025, 11:40 AMRecord.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 πcreamy-beard-50597
01/13/2025, 11:52 AMI donβt recallwell documentation says so πhaving to match anythng /wrt the bucket, I think (but maybe my memory is betraying me) that it can be an arbitrary domain name.Record.name
The bucket name should match the name that appears in the Name box.creamy-beard-50597
01/13/2025, 11:53 AMBtw, you do not need to hardcodethat 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 ). Your"<http://s3-website.eu-central-1.amazonaws.com|s3-website.eu-central-1.amazonaws.com>"(orBucketWebsiteConfigurationV2, depending on what resources you use) should have aBucketoutput that you can use πwebsiteEndpoint
quick-house-41860
01/13/2025, 11:57 AMcreamy-beard-50597
01/13/2025, 11:58 AM