I'm curious about how to take an existing S3 bucket and set up an alias record for it using AWS CDK.
Everything seems to be going well :
const myExistingBucket = Bucket.fromBucketName(this, 'myExistingBucket', 'myExistingBucketName')
new route53.ARecord(this, 'myAliasRecord', {
zone: myHostedZone,
target: route53.AddressRecordTarget.fromAlias(new route53_targets.BucketWebsiteTarget(myExistingBucket))
});
But then I encounter this error: Argument of type 'IBucket' is not assignable to parameter of type 'Bucket'.
The functions fromBucketArn()
, fromBucketAttributes()
, and fromBucketName()
all return a type of IBucket
, but the BucketWebsiteTarget()
function requires a type of Bucket
.
So, how can I obtain a Bucket
type from an existing one using AWS CDK?