Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route53 A record is setting incorrect alias target for s3 website #3928

Closed
harmohan-a opened this issue Sep 4, 2019 · 6 comments · Fixed by #4070
Closed

route53 A record is setting incorrect alias target for s3 website #3928

harmohan-a opened this issue Sep 4, 2019 · 6 comments · Fixed by #4070
Assignees
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 @aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. needs-reproduction This issue needs reproduction. needs-triage This issue or PR still needs to be triaged.

Comments

@harmohan-a
Copy link

🐛 Bug Report

What is the problem?

I created a cdk stack with s3, route53 and A record on an existing zone. when deployed the alias target in route53 is encoded string

http\072\057\057harmohan.<website>.com.s3-website-ap-southeast-2.amazonaws.com.

Reproduction Steps

 const bucketProps: BucketProps = {
      bucketName: DOMAIN_NAME,
      websiteIndexDocument: 'index.html',
      publicReadAccess: true,
      removalPolicy: cdn ? RemovalPolicy.RETAIN : RemovalPolicy.DESTROY,
      websiteErrorDocument: cdn ? undefined : 'index.html'
    }

    const bucket = new Bucket(this, 'S3Bucket', bucketProps);

    const zone = HostedZone.fromLookup(this, 'HostedZone', {
      domainName: <domain name>
    });

    new ARecord(this, 'ARecord', {
      recordName: DOMAIN_NAME,
      zone: zone,
      target: {
        aliasTarget: new BucketWebsiteTarget(bucket)
      }
    });

Verbose Log

Environment

  • CDK CLI Version: 1.6.0
  • Module Version: 1.6.0
  • OS:
  • Language: TypeScript

Other information

Screen Shot 2019-09-04 at 2 00 30 pm

@harmohan-a harmohan-a added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 4, 2019
@SomayaB SomayaB added @aws-cdk/aws-route53 Related to Amazon Route 53 @aws-cdk/aws-s3 Related to Amazon S3 labels Sep 4, 2019
@jokyjang
Copy link

jokyjang commented Sep 5, 2019

I have seen the same issue with Java.

@SomayaB SomayaB added the needs-reproduction This issue needs reproduction. label Sep 10, 2019
@nmussy
Copy link
Contributor

nmussy commented Sep 13, 2019

Definitely my fault, I've used the bucketWebsiteUrl property as a record value, which is prefixed with the http:// protocol:

Sorry about that, I'll get a PR ready

@harmohan-a
Copy link
Author

thanks @nmussy

@jokyjang
Copy link

This is still not working correctly. Based on my experience, the alias target for S3 bucket should be set to the regionalized base domain name such as s3-website-us-west-2.amazonaws.com if the bucket is in us-west-2 instead of the full endpoint name.

It seems Route53 could figure out the full endpoint name since bucket name must exactly match the record name.

@nmussy
Copy link
Contributor

nmussy commented Sep 25, 2019

Hey @jokyjang. Please tell me if I understand correctly, but the DnsName shouldn't be the actual bucket website, but the fixed endpoint depending on the region. So instead of setting <bucket_name>.s3-website-us-west-2.amazonaws.com like we have now, we should use s3-website-us-west-2.amazonaws.com. Your last paragraph (also mentioned in the documentation) got me a little puzzled though:

Route 53 figures out which bucket to route traffic to based on the name of the record.

We might have to add a CNAME to allow the user to transparently have different domain name, unless I'm missing something.

I'll look into it tomorrow morning, it's getting late here. Thanks, and sorry again for the issues everyone.

@nmussy
Copy link
Contributor

nmussy commented Sep 26, 2019

#4250 was just merged to fix the issue raised by @jokyjang.

I'm also looking into making another PR to make sure that the bucketName matches the full domain name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 @aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. needs-reproduction This issue needs reproduction. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants