pulumi / pulumi-aws

An Amazon Web Services (AWS) Pulumi resource package, providing multi-language access to AWS
Apache License 2.0
462 stars 155 forks source link

Route53 + S3 zoneId not being respected #2330

Closed sarink closed 1 week ago

sarink commented 1 year ago

What happened?

It is impossible to create a route53 alias that points to an s3 bucket.

The expected result is achieved immediately by manually creating the record in the UI.

Steps to reproduce

    const rootDomain = 'my-domain.com';

    const zoneId = aws.route53
      .getZone({ name: rootDomain }, { async: true })
      .then((zone) => zone.zoneId);

    const bucket = new aws.s3.Bucket(rootDomain, {
      bucket: rootDomain,
      hostedZoneId: zoneId,
      acl: aws.s3.PrivateAcl,
    });

    // This breaks
    new aws.route53.Record(rootDomain, {
      name: rootDomain,
      zoneId,
      type: 'A',
      aliases: [
        {
          zoneId: bucket.hostedZoneId,
          name: bucket.bucketDomainName,
          evaluateTargetHealth: false,
        },
      ],
    });

Expected Behavior

I expected a route53 alias in my custom zone to be created which points to the s3 bucket

Actual Behavior

[Tried to create an alias that targets my-domain.com.s3.amazonaws.com.,
type A in zone 1234, but the alias target name does not lie within the target zone]

Output of pulumi about

CLI          
Version      3.52.1
Go Version   go1.19.5
Go Compiler  gc

Plugins
NAME    VERSION
nodejs  unknown

Host     
OS       darwin
Version  12.6
Arch     arm64

Additional context

Attempting to do this: https://aws.amazon.com/blogs/aws/root-domain-website-hosting-for-amazon-s3/ but it doesn't seem possible with pulumi

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

squaremo commented 1 year ago

Thanks for logging this, and for the concise explanation of what you're trying to do ⭐ We'll have a look into it.

RomainSF commented 5 months ago

any update on that one? I have the same issue with Bucket v2

t0yv0 commented 4 months ago

Please remember to upvote the issue if it is important to you as it helps our team prioritize!

t0yv0 commented 1 week ago

Having a quick look again here, I believe it's entirely possible to host a static website on S3 with Pulumi. Please check out the https://github.com/pulumi/examples/blob/master/aws-ts-static-website/index.ts example. This example involves a CloudFront configuration which is recommended, but may not be required.

Please have a look at https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucketwebsiteconfigurationv2/ that is definitely required in a complete setup.