Skip to content
v2.275.0

Experimental

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

Domain L2 construct ​

An Amplify Console domain.

Example ​

ts
declare const amplifyApp: amplify.App;
declare const main: amplify.Branch;
declare const dev: amplify.Branch;

const domain = amplifyApp.addDomain('example.com', {
  enableAutoSubdomain: true, // in case subdomains should be auto registered for branches
  autoSubdomainCreationPatterns: ['*', 'pr*'], // regex for branches that should auto register subdomains
});
domain.mapRoot(main); // map main branch to domain root
domain.mapSubDomain(main, 'www');
domain.mapSubDomain(dev); // sub domain prefix defaults to branch name
python
# amplify_app: amplify.App
# main: amplify.Branch
# dev: amplify.Branch


domain = amplify_app.add_domain("example.com",
    enable_auto_subdomain=True,  # in case subdomains should be auto registered for branches
    auto_subdomain_creation_patterns=["*", "pr*"]
)
domain.map_root(main) # map main branch to domain root
domain.map_sub_domain(main, "www")
domain.map_sub_domain(dev)
java
App amplifyApp;
Branch main;
Branch dev;


Domain domain = amplifyApp.addDomain("example.com", DomainOptions.builder()
        .enableAutoSubdomain(true) // in case subdomains should be auto registered for branches
        .autoSubdomainCreationPatterns(List.of("*", "pr*"))
        .build());
domain.mapRoot(main); // map main branch to domain root
domain.mapSubDomain(main, "www");
domain.mapSubDomain(dev);
csharp
// Install: dotnet add package Amazon.CDK.AWS.Amplify.Alpha
App amplifyApp;
Branch main;
Branch dev;


var domain = amplifyApp.AddDomain("example.com", new DomainOptions {
    EnableAutoSubdomain = true,  // in case subdomains should be auto registered for branches
    AutoSubdomainCreationPatterns = new [] { "*", "pr*" }
});
domain.MapRoot(main); // map main branch to domain root
domain.MapSubDomain(main, "www");
domain.MapSubDomain(dev);
go
// Install: go get github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2
var amplifyApp App
var main Branch
var dev Branch


domain := amplifyApp.AddDomain(jsii.String("example.com"), &DomainOptions{
	EnableAutoSubdomain: jsii.Boolean(true),
	 // in case subdomains should be auto registered for branches
	AutoSubdomainCreationPatterns: []*string{
		jsii.String("*"),
		jsii.String("pr*"),
	},
})
domain.MapRoot(main) // map main branch to domain root
domain.MapSubDomain(main, jsii.String("www"))
domain.MapSubDomain(dev)

Initializer ​

ts
new Domain(scope: Construct, id: string, props: DomainProps)
python
Domain(scope: Construct, id: str, props: DomainProps)
java
new Domain(Construct scope, String id, DomainProps props)
csharp
new Domain(Construct scope, string id, DomainProps props)
go
NewDomain(Scope Construct, Id *string, Props DomainProps)

Construct Props ​

appIAppappIAppappIAppAppIAppAppIApprequired#
The application to which the domain must be connected.
autoSubdomainCreationPatternsoptionalstring[]auto_subdomain_creation_patternsoptionaltyping.List[str]autoSubdomainCreationPatternsoptionalList<String>AutoSubdomainCreationPatternsoptionalstring[]AutoSubdomainCreationPatternsoptional*[]*string#
Branches which should automatically create subdomains.

Default: all repository branches ['', 'pr']

autoSubDomainIamRoleoptionalIRoleauto_sub_domain_iam_roleoptionalIRoleautoSubDomainIamRoleoptionalIRoleAutoSubDomainIamRoleoptionalIRoleAutoSubDomainIamRoleoptionalIRole#
The IAM role with access to Route53 when using enableAutoSubdomain.

Default: the IAM role from App.grantPrincipal

customCertificateoptionalICertificatecustom_certificateoptionalICertificatecustomCertificateoptionalICertificateCustomCertificateoptionalICertificateCustomCertificateoptionalICertificate#
The type of SSL/TLS certificate to use for your custom domain.

Default: Amplify uses the default certificate that it provisions and manages for you

domainNameoptionalstringdomain_nameoptionalstrdomainNameoptionalStringDomainNameoptionalstringDomainNameoptional*string#
The name of the domain.

Default: the construct's id

enableAutoSubdomainoptionalbooleanenable_auto_subdomainoptionalboolenableAutoSubdomainoptionalBooleanEnableAutoSubdomainoptionalboolEnableAutoSubdomainoptional*bool= false#
Automatically create subdomains for connected branches.
subDomainsoptionalSubDomain[]sub_domainsoptionaltyping.List[SubDomain]subDomainsoptionalList<SubDomain>SubDomainsoptionalSubDomain[]SubDomainsoptional*[]SubDomain#
Subdomains.

Default: use addSubDomain() to add subdomains

Properties ​

arnstringarnstrarnStringArnstringArn*string#
The ARN of the domain.
certificateRecordstringcertificate_recordstrcertificateRecordStringCertificateRecordstringCertificateRecord*string#
The DNS Record for certificate verification.
domainAutoSubDomainCreationPatternsstring[]domain_auto_sub_domain_creation_patternstyping.List[str]domainAutoSubDomainCreationPatternsList<String>DomainAutoSubDomainCreationPatternsstring[]DomainAutoSubDomainCreationPatterns*[]*string#
Branch patterns for the automatically created subdomain.
domainAutoSubDomainIamRolestringdomain_auto_sub_domain_iam_rolestrdomainAutoSubDomainIamRoleStringDomainAutoSubDomainIamRolestringDomainAutoSubDomainIamRole*string#
The IAM service role for the subdomain.
domainEnableAutoSubDomainIResolvabledomain_enable_auto_sub_domainIResolvabledomainEnableAutoSubDomainIResolvableDomainEnableAutoSubDomainIResolvableDomainEnableAutoSubDomainIResolvable#
Specifies whether the automated creation of subdomains for branches is enabled.
domainNamestringdomain_namestrdomainNameStringDomainNamestringDomainName*string#
The name of the domain.
domainStatusstringdomain_statusstrdomainStatusStringDomainStatusstringDomainStatus*string#
The status of the domain association.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStack#
The stack in which this resource is defined.
statusReasonstringstatus_reasonstrstatusReasonStringStatusReasonstringStatusReason*string#
The reason for the current status of the domain.

Methods ​

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
mapRoot(branch: IBranch): Domain // chainabledef map_root(self, branch: IBranch) -> Domainpublic Domain mapRoot(IBranch branch)public Domain MapRoot(IBranch branch)func MapRoot(Branch IBranch) Domain#
Maps a branch to the domain root.
mapSubDomain(branch: IBranch, prefix?: string): Domain // chainabledef map_sub_domain(self, branch: IBranch, prefix: typing.Optional[str] = None) -> Domainpublic Domain mapSubDomain(IBranch branch, String prefix)public Domain MapSubDomain(IBranch branch, string? prefix = null)func MapSubDomain(Branch IBranch, Prefix *string) Domain#
Maps a branch to a sub domain.
2 parameters

Parameters

  • branchbranchbranchbranchBranch — The branch.
  • prefixprefixprefixprefixPrefix — The prefix.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.