RoutingRuleProperty Struct
Specifies the redirect behavior and when a redirect is applied.
For more information about routing rules, see Configuring advanced conditional redirects in the Amazon S3 User Guide .
| Source | |
|---|---|
| Type last changed |
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_s3 as s3 } from 'aws-cdk-lib';
const routingRuleProperty: s3.CfnBucket.RoutingRuleProperty = {
redirectRule: {
hostName: 'hostName',
httpRedirectCode: 'httpRedirectCode',
protocol: 'protocol',
replaceKeyPrefixWith: 'replaceKeyPrefixWith',
replaceKeyWith: 'replaceKeyWith',
},
// the properties below are optional
routingRuleCondition: {
httpErrorCodeReturnedEquals: 'httpErrorCodeReturnedEquals',
keyPrefixEquals: 'keyPrefixEquals',
},
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_s3 as s3
routing_rule_property = s3.CfnBucket.RoutingRuleProperty(
redirect_rule=s3.CfnBucket.RedirectRuleProperty(
host_name="hostName",
http_redirect_code="httpRedirectCode",
protocol="protocol",
replace_key_prefix_with="replaceKeyPrefixWith",
replace_key_with="replaceKeyWith"
),
# the properties below are optional
routing_rule_condition=s3.CfnBucket.RoutingRuleConditionProperty(
http_error_code_returned_equals="httpErrorCodeReturnedEquals",
key_prefix_equals="keyPrefixEquals"
)
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.s3.*;
RoutingRuleProperty routingRuleProperty = RoutingRuleProperty.builder()
.redirectRule(RedirectRuleProperty.builder()
.hostName("hostName")
.httpRedirectCode("httpRedirectCode")
.protocol("protocol")
.replaceKeyPrefixWith("replaceKeyPrefixWith")
.replaceKeyWith("replaceKeyWith")
.build())
// the properties below are optional
.routingRuleCondition(RoutingRuleConditionProperty.builder()
.httpErrorCodeReturnedEquals("httpErrorCodeReturnedEquals")
.keyPrefixEquals("keyPrefixEquals")
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.S3;
var routingRuleProperty = new RoutingRuleProperty {
RedirectRule = new RedirectRuleProperty {
HostName = "hostName",
HttpRedirectCode = "httpRedirectCode",
Protocol = "protocol",
ReplaceKeyPrefixWith = "replaceKeyPrefixWith",
ReplaceKeyWith = "replaceKeyWith"
},
// the properties below are optional
RoutingRuleCondition = new RoutingRuleConditionProperty {
HttpErrorCodeReturnedEquals = "httpErrorCodeReturnedEquals",
KeyPrefixEquals = "keyPrefixEquals"
}
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
routingRuleProperty := &RoutingRuleProperty{
RedirectRule: &RedirectRuleProperty{
HostName: jsii.String("hostName"),
HttpRedirectCode: jsii.String("httpRedirectCode"),
Protocol: jsii.String("protocol"),
ReplaceKeyPrefixWith: jsii.String("replaceKeyPrefixWith"),
ReplaceKeyWith: jsii.String("replaceKeyWith"),
},
// the properties below are optional
RoutingRuleCondition: &RoutingRuleConditionProperty{
HttpErrorCodeReturnedEquals: jsii.String("httpErrorCodeReturnedEquals"),
KeyPrefixEquals: jsii.String("keyPrefixEquals"),
},
}
Properties
redirectRuleIResolvable | CfnBucket.RedirectRulePropertyredirect_ruletyping.Union[IResolvable, RedirectRuleProperty]redirectRuleIResolvableRedirectRuleIResolvableRedirectRuleinterface{} required #Container for redirect information.
You can redirect requests to another host, to another page, or with another protocol. In the event of an error, you can specify a different error code to return.
routingRuleConditionoptionalIResolvable | CfnBucket.routing_rule_conditionoptionaltyping.Union[IResolvable, RoutingRuleConditionProperty]routingRuleConditionoptionalIResolvableRoutingRuleConditionoptionalIResolvableRoutingRuleConditionoptionalinterface{} #A container for describing a condition that must be met for the specified redirect to apply.
For example, 1. If request is for pages in the /docs folder, redirect to the /documents folder. 2. If request results in HTTP error 4xx, redirect request to another host where you might process the error.