App

class aws_cdk.aws_amplify.App(scope, id, *, app_name=None, auto_branch_creation=None, auto_branch_deletion=None, basic_auth=None, build_spec=None, custom_response_headers=None, custom_rules=None, description=None, environment_variables=None, role=None, source_code_provider=None)

Bases: Resource

(experimental) An Amplify Console application.

Stability:

experimental

ExampleMetadata:

infused

Example:

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
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • app_name (Optional[str]) – (experimental) The name for the application. Default: - a CDK generated name

  • auto_branch_creation (Union[AutoBranchCreation, Dict[str, Any], None]) – (experimental) The auto branch creation configuration. Use this to automatically create branches that match a certain pattern. Default: - no auto branch creation

  • auto_branch_deletion (Optional[bool]) – (experimental) Automatically disconnect a branch in the Amplify Console when you delete a branch from your Git repository. Default: false

  • basic_auth (Optional[BasicAuth]) – (experimental) The Basic Auth configuration. Use this to set password protection at an app level to all your branches. Default: - no password protection

  • build_spec (Optional[BuildSpec]) – (experimental) BuildSpec for the application. Alternatively, add a amplify.yml file to the repository. Default: - no build spec

  • custom_response_headers (Optional[Sequence[Union[CustomResponseHeader, Dict[str, Any]]]]) – (experimental) The custom HTTP response headers for an Amplify app. Default: - no custom response headers

  • custom_rules (Optional[Sequence[CustomRule]]) – (experimental) Custom rewrite/redirect rules for the application. Default: - no custom rewrite/redirect rules

  • description (Optional[str]) – (experimental) A description for the application. Default: - no description

  • environment_variables (Optional[Mapping[str, str]]) – (experimental) Environment variables for the application. All environment variables that you add are encrypted to prevent rogue access so you can use them to store secret information. Default: - no environment variables

  • role (Optional[IRole]) – (experimental) The IAM service role to associate with the application. The App implements IGrantable. Default: - a new role is created

  • source_code_provider (Optional[ISourceCodeProvider]) – (experimental) The source code provider for this application. Default: - not connected to a source code provider

Stability:

experimental

Methods

add_auto_branch_environment(name, value)

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

Parameters:
  • name (str) –

  • value (str) –

Stability:

experimental

Return type:

App

add_branch(id, *, asset=None, auto_build=None, basic_auth=None, branch_name=None, build_spec=None, description=None, environment_variables=None, performance_mode=None, pull_request_environment_name=None, pull_request_preview=None, stage=None)

(experimental) Adds a branch to this application.

Parameters:
  • id (str) –

  • asset (Optional[Asset]) – (experimental) Asset for deployment. The Amplify app must not have a sourceCodeProvider configured as this resource uses Amplify’s startDeployment API to initiate and deploy a S3 asset onto the App. Default: - no asset

  • auto_build (Optional[bool]) – (experimental) Whether to enable auto building for the branch. Default: true

  • basic_auth (Optional[BasicAuth]) – (experimental) The Basic Auth configuration. Use this to set password protection for the branch Default: - no password protection

  • branch_name (Optional[str]) – (experimental) The name of the branch. Default: - the construct’s id

  • build_spec (Optional[BuildSpec]) – (experimental) BuildSpec for the branch. Default: - no build spec

  • description (Optional[str]) – (experimental) A description for the branch. Default: - no description

  • environment_variables (Optional[Mapping[str, str]]) – (experimental) Environment variables for the branch. All environment variables that you add are encrypted to prevent rogue access so you can use them to store secret information. Default: - application environment variables

  • performance_mode (Optional[bool]) – (experimental) Enables performance mode for the branch. Performance mode optimizes for faster hosting performance by keeping content cached at the edge for a longer interval. When performance mode is enabled, hosting configuration or code changes can take up to 10 minutes to roll out. Default: false

  • pull_request_environment_name (Optional[str]) – (experimental) The dedicated backend environment for the pull request previews. Default: - automatically provision a temporary backend

  • pull_request_preview (Optional[bool]) – (experimental) Whether to enable pull request preview for the branch. Default: true

  • stage (Optional[str]) – (experimental) Stage for the branch. Default: - no stage

Stability:

experimental

Return type:

Branch

add_custom_rule(rule)

(experimental) Adds a custom rewrite/redirect rule to this application.

Parameters:

rule (CustomRule) –

Stability:

experimental

Return type:

App

add_domain(id, *, auto_subdomain_creation_patterns=None, domain_name=None, enable_auto_subdomain=None, sub_domains=None)

(experimental) Adds a domain to this application.

Parameters:
  • id (str) –

  • auto_subdomain_creation_patterns (Optional[Sequence[str]]) – (experimental) Branches which should automatically create subdomains. Default: - all repository branches [‘*’, ‘pr*’]

  • domain_name (Optional[str]) – (experimental) The name of the domain. Default: - the construct’s id

  • enable_auto_subdomain (Optional[bool]) – (experimental) Automatically create subdomains for connected branches. Default: false

  • sub_domains (Optional[Sequence[Union[SubDomain, Dict[str, Any]]]]) – (experimental) Subdomains. Default: - use addSubDomain() to add subdomains

Stability:

experimental

Return type:

Domain

add_environment(name, value)

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

Parameters:
  • name (str) –

  • value (str) –

Stability:

experimental

Return type:

App

apply_removal_policy(policy)

Apply the given removal policy to this resource.

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

Parameters:

policy (RemovalPolicy) –

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

app_id

(experimental) The application id.

Stability:

experimental

app_name

(experimental) The name of the application.

Stability:

experimental

Attribute:

true

arn

(experimental) The ARN of the application.

Stability:

experimental

Attribute:

true

default_domain

(experimental) The default domain of the application.

Stability:

experimental

Attribute:

true

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

grant_principal

(experimental) The principal to grant permissions to.

Stability:

experimental

node

The construct tree node associated with this construct.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_app_id(scope, id, app_id)

(experimental) Import an existing application.

Parameters:
  • scope (Construct) –

  • id (str) –

  • app_id (str) –

Stability:

experimental

Return type:

IApp

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool