Skip to content
v2.274.0

Experimental

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

App L2 construct ​

An Amplify Console application.

Example ​

ts
const amplifyApp = new amplify.App(this, 'MyApp', {
  sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
    owner: '<user>',
    repository: '<repo>',
    oauthToken: SecretValue.secretsManager('my-github-token'),
  }),
  autoBranchCreation: { // Automatically connect branches that match a pattern set
    patterns: ['feature/*', 'test/*'],
  },
  autoBranchDeletion: true, // Automatically disconnect a branch when you delete a branch from your repository
});
python
amplify_app = amplify.App(self, "MyApp",
    source_code_provider=amplify.GitHubSourceCodeProvider(
        owner="<user>",
        repository="<repo>",
        oauth_token=SecretValue.secrets_manager("my-github-token")
    ),
    auto_branch_creation=amplify.AutoBranchCreation( # Automatically connect branches that match a pattern set
        patterns=["feature/*", "test/*"]),
    auto_branch_deletion=True
)
java
App amplifyApp = App.Builder.create(this, "MyApp")
        .sourceCodeProvider(GitHubSourceCodeProvider.Builder.create()
                .owner("<user>")
                .repository("<repo>")
                .oauthToken(SecretValue.secretsManager("my-github-token"))
                .build())
        .autoBranchCreation(AutoBranchCreation.builder() // Automatically connect branches that match a pattern set
                .patterns(List.of("feature/*", "test/*")).build())
        .autoBranchDeletion(true)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Amplify.Alpha
var amplifyApp = new App(this, "MyApp", new AppProps {
    SourceCodeProvider = new GitHubSourceCodeProvider(new GitHubSourceCodeProviderProps {
        Owner = "<user>",
        Repository = "<repo>",
        OauthToken = SecretValue.SecretsManager("my-github-token")
    }),
    AutoBranchCreation = new AutoBranchCreation {  // Automatically connect branches that match a pattern set
        Patterns = new [] { "feature/*", "test/*" } },
    AutoBranchDeletion = true
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2
amplifyApp := amplify.NewApp(this, jsii.String("MyApp"), &AppProps{
	SourceCodeProvider: amplify.NewGitHubSourceCodeProvider(&GitHubSourceCodeProviderProps{
		Owner: jsii.String("<user>"),
		Repository: jsii.String("<repo>"),
		OauthToken: awscdk.SecretValue_SecretsManager(jsii.String("my-github-token")),
	}),
	AutoBranchCreation: &AutoBranchCreation{
		 // Automatically connect branches that match a pattern set
		Patterns: []*string{
			jsii.String("feature/*"),
			jsii.String("test/*"),
		},
	},
	AutoBranchDeletion: jsii.Boolean(true),
})

Initializer ​

ts
new App(scope: Construct, id: string, props: AppProps)
python
App(scope: Construct, id: str, props: AppProps)
java
new App(Construct scope, String id, AppProps props)
csharp
new App(Construct scope, string id, AppProps props)
go
NewApp(Scope Construct, Id *string, Props AppProps)

Construct Props ​

appNameoptionalstringapp_nameoptionalstrappNameoptionalStringAppNameoptionalstringAppNameoptional*string#
The name for the application.

Default: a CDK generated name

autoBranchCreationoptionalAutoBranchCreationauto_branch_creationoptionalAutoBranchCreationautoBranchCreationoptionalAutoBranchCreationAutoBranchCreationoptionalAutoBranchCreationAutoBranchCreationoptionalAutoBranchCreation#
The auto branch creation configuration.

Default: no auto branch creation

Use this to automatically create branches that match a certain pattern.

autoBranchDeletionoptionalbooleanauto_branch_deletionoptionalboolautoBranchDeletionoptionalBooleanAutoBranchDeletionoptionalboolAutoBranchDeletionoptional*bool= false#
Automatically disconnect a branch in the Amplify Console when you delete a branch from your Git repository.
basicAuthoptionalBasicAuthbasic_authoptionalBasicAuthbasicAuthoptionalBasicAuthBasicAuthoptionalBasicAuthBasicAuthoptionalBasicAuth#
The Basic Auth configuration.

Default: no password protection

Use this to set password protection at an app level to all your branches.

buildComputeTypeoptionalBuildComputeTypebuild_compute_typeoptionalBuildComputeTypebuildComputeTypeoptionalBuildComputeTypeBuildComputeTypeoptionalBuildComputeTypeBuildComputeTypeoptionalBuildComputeType#
Specifies the size of the build instance.

Default: undefined - Amplify default setting is BuildComputeType.STANDARD_8GB.

buildSpecoptionalBuildSpecbuild_specoptionalBuildSpecbuildSpecoptionalBuildSpecBuildSpecoptionalBuildSpecBuildSpecoptionalBuildSpec#
BuildSpec for the application.

Default: no build spec

Alternatively, add a amplify.yml file to the repository.

cacheConfigTypeoptionalCacheConfigTypecache_config_typeoptionalCacheConfigTypecacheConfigTypeoptionalCacheConfigTypeCacheConfigTypeoptionalCacheConfigTypeCacheConfigTypeoptionalCacheConfigType= CacheConfigType.AMPLIFY_MANAGED#
The type of cache configuration to use for an Amplify app.
computeRoleoptionalIRolecompute_roleoptionalIRolecomputeRoleoptionalIRoleComputeRoleoptionalIRoleComputeRoleoptionalIRole#
The IAM role for an SSR app.

Default: undefined - a new role is created when platform is Platform.WEB_COMPUTE or Platform.WEB_DYNAMIC, otherwise no compute role

The Compute role allows the Amplify Hosting compute service to securely access specific AWS resources based on the role's permissions.

customResponseHeadersoptionalCustomResponseHeader[]custom_response_headersoptionaltyping.List[CustomResponseHeader]customResponseHeadersoptionalList<CustomResponseHeader>CustomResponseHeadersoptionalCustomResponseHeader[]CustomResponseHeadersoptional*[]CustomResponseHeader#
The custom HTTP response headers for an Amplify app.

Default: no custom response headers

customRulesoptionalCustomRule[]custom_rulesoptionaltyping.List[CustomRule]customRulesoptionalList<CustomRule>CustomRulesoptionalCustomRule[]CustomRulesoptional*[]CustomRule#
Custom rewrite/redirect rules for the application.

Default: no custom rewrite/redirect rules

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#
A description for the application.

Default: no description

environmentVariablesoptional{ [key: string]: string }environment_variablesoptionaltyping.Mapping[str, str]environmentVariablesoptionalMap<String, String>EnvironmentVariablesoptionalIDictionary<string, string>EnvironmentVariablesoptional*map[string]*string#
Environment variables for the application.

Default: no environment variables

All environment variables that you add are encrypted to prevent rogue access so you can use them to store secret information.

platformoptionalPlatformplatformoptionalPlatformplatformoptionalPlatformPlatformoptionalPlatformPlatformoptionalPlatform= Platform.WEB#
Indicates the hosting platform to use.

Set to WEB for static site generated (SSG) apps (i.e. a Create React App or Gatsby) and WEB_COMPUTE for server side rendered (SSR) apps (i.e. NextJS).

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole#
The IAM service role to associate with the application.

Default: a new role is created

The App implements IGrantable.

sourceCodeProvideroptionalISourceCodeProvidersource_code_provideroptionalISourceCodeProvidersourceCodeProvideroptionalISourceCodeProviderSourceCodeProvideroptionalISourceCodeProviderSourceCodeProvideroptionalISourceCodeProvider#
The source code provider for this application.

Default: not connected to a source code provider

Properties ​

appIdstringapp_idstrappIdStringAppIdstringAppId*string#
The application id.
appNamestringapp_namestrappNameStringAppNamestringAppName*string#
The name of the application.
arnstringarnstrarnStringArnstringArn*string#
The ARN of the application.
computeRolemay be undefinedIRolecompute_rolemay be undefinedIRolecomputeRolemay be undefinedIRoleComputeRolemay be undefinedIRoleComputeRolemay be undefinedIRole#
The IAM role for an SSR app.
defaultDomainstringdefault_domainstrdefaultDomainStringDefaultDomainstringDefaultDomain*string#
The default domain of the application.
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.

grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal#
The principal to grant permissions to.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
platformmay be undefinedPlatformplatformmay be undefinedPlatformplatformmay be undefinedPlatformPlatformmay be undefinedPlatformPlatformmay be undefinedPlatform#
The platform of the app.
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.

Methods ​

addAutoBranchEnvironment(name: string, value: string): App // chainabledef add_auto_branch_environment(self, name: str, value: str) -> Apppublic App addAutoBranchEnvironment(String name, String value)public App AddAutoBranchEnvironment(string name, string value)func AddAutoBranchEnvironment(Name *string, Value *string) App#
Adds an environment variable to the auto created branch.

All environment variables that you add are encrypted to prevent rogue access so you can use them to store secret information.

addBranch(id: string, options?: BranchOptions): Branchdef add_branch(self, id: str, options: typing.Optional[BranchOptions] = None) -> Branchpublic Branch addBranch(String id, BranchOptions options)public Branch AddBranch(string id, BranchOptions? options = null)func AddBranch(Id *string, Options BranchOptions) Branch#
Adds a branch to this application.
addCustomRule(rule: CustomRule): App // chainabledef add_custom_rule(self, rule: CustomRule) -> Apppublic App addCustomRule(CustomRule rule)public App AddCustomRule(CustomRule rule)func AddCustomRule(Rule CustomRule) App#
Adds a custom rewrite/redirect rule to this application.
addDomain(id: string, options?: DomainOptions): Domaindef add_domain(self, id: str, options: typing.Optional[DomainOptions] = None) -> Domainpublic Domain addDomain(String id, DomainOptions options)public Domain AddDomain(string id, DomainOptions? options = null)func AddDomain(Id *string, Options DomainOptions) Domain#
Adds a domain to this application.
addEnvironment(name: string, value: string): App // chainabledef add_environment(self, name: str, value: str) -> Apppublic App addEnvironment(String name, String value)public App AddEnvironment(string name, string value)func AddEnvironment(Name *string, Value *string) App#
Adds an environment variable to this application.

All environment variables that you add are encrypted to prevent rogue access so you can use them to store secret information.

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).

fromAppId(scope: Construct, id: string, appId: string): IApp@staticmethod def from_app_id(scope: Construct, id: str, app_id: str) -> IApppublic static IApp fromAppId(Construct scope, String id, String appId)public static IApp FromAppId(Construct scope, string id, string appId)func FromAppId(Scope Construct, Id *string, AppId *string) IAppstatic#
Import an existing application.
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.
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.