Skip to content
v2.273.0

Experimental

@aws-cdk/aws-amplify-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

CustomRule Class ​

Custom rewrite/redirect rule for an Amplify App.

Example ​

ts
import { CustomRule } from '@aws-cdk/aws-amplify-alpha';

declare const amplifyApp: amplify.App;
amplifyApp.addCustomRule(new CustomRule({
  source: '/docs/specific-filename.html',
  target: '/documents/different-filename.html',
  status: amplify.RedirectStatus.TEMPORARY_REDIRECT,
}));
python
from aws_cdk.aws_amplify_alpha import CustomRule

# amplify_app: amplify.App

amplify_app.add_custom_rule(CustomRule(
    source="/docs/specific-filename.html",
    target="/documents/different-filename.html",
    status=amplify.RedirectStatus.TEMPORARY_REDIRECT
))
java
import software.amazon.awscdk.services.amplify.alpha.CustomRule;

App amplifyApp;

amplifyApp.addCustomRule(CustomRule.Builder.create()
        .source("/docs/specific-filename.html")
        .target("/documents/different-filename.html")
        .status(RedirectStatus.TEMPORARY_REDIRECT)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.AWS.Amplify.Alpha
using Amazon.CDK.AWS.Amplify.Alpha;

App amplifyApp;

amplifyApp.AddCustomRule(new CustomRule(new CustomRuleOptions {
    Source = "/docs/specific-filename.html",
    Target = "/documents/different-filename.html",
    Status = RedirectStatus.TEMPORARY_REDIRECT
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2
import "github.com/aws/aws-cdk-go/awscdkamplifyalpha"

var amplifyApp App

amplifyApp.AddCustomRule(awscdkamplifyalpha.NewCustomRule(&CustomRuleOptions{
	Source: jsii.String("/docs/specific-filename.html"),
	Target: jsii.String("/documents/different-filename.html"),
	Status: amplify.RedirectStatus_TEMPORARY_REDIRECT,
}))

Initializer ​

ts
new CustomRule(options: CustomRuleOptions)
python
CustomRule(options: CustomRuleOptions)
java
new CustomRule(CustomRuleOptions options)
csharp
new CustomRule(CustomRuleOptions options)
go
NewCustomRule(Options CustomRuleOptions)

Properties ​

conditionstringconditionstrconditionStringConditionstringCondition*string= no condition#
The condition for a URL rewrite or redirect rule, e.g. country code.
SINGLE_PAGE_APPLICATION_REDIRECTCustomRulesingle_page_application_redirectCustomRuleSINGLE_PAGE_APPLICATION_REDIRECTCustomRuleSINGLE_PAGE_APPLICATION_REDIRECTCustomRuleSINGLE_PAGE_APPLICATION_REDIRECTCustomRulerequiredstatic#
Sets up a 200 rewrite for all paths to `index.html` except for path containing a file extension.
sourcestringsourcestrsourceStringSourcestringSource*stringrequired#
The source pattern for a URL rewrite or redirect rule.
statusRedirectStatusstatusRedirectStatusstatusRedirectStatusStatusRedirectStatusStatusRedirectStatus= PERMANENT_REDIRECT#
The status code for a URL rewrite or redirect rule.
targetstringtargetstrtargetStringTargetstringTarget*stringrequired#
The target pattern for a URL rewrite or redirect rule.