Skip to content
v2.278.0

RedirectTarget Struct ​

Specifies a redirect behavior of all requests to a website endpoint of a bucket.

Example ​

ts
const bucket = new s3.Bucket(this, 'MyRedirectedBucket', {
  websiteRedirect: { hostName: 'www.example.com' },
});
python
bucket = s3.Bucket(self, "MyRedirectedBucket",
    website_redirect=s3.RedirectTarget(host_name="www.example.com")
)
java
Bucket bucket = Bucket.Builder.create(this, "MyRedirectedBucket")
        .websiteRedirect(RedirectTarget.builder().hostName("www.example.com").build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var bucket = new Bucket(this, "MyRedirectedBucket", new BucketProps {
    WebsiteRedirect = new RedirectTarget { HostName = "www.example.com" }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
bucket := s3.NewBucket(this, jsii.String("MyRedirectedBucket"), &BucketProps{
	WebsiteRedirect: &RedirectTarget{
		HostName: jsii.String("www.example.com"),
	},
})

Properties ​

hostNamestringhost_namestrhostNameStringHostNamestringHostName*string required #
Name of the host where requests are redirected.
protocoloptionalRedirectProtocolprotocoloptionalRedirectProtocolprotocoloptionalRedirectProtocolProtocoloptionalRedirectProtocolProtocoloptionalRedirectProtocol #
Protocol to use when redirecting requests.

Default: The protocol used in the original request.