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: aws_cdk.core.Resource

(experimental) An Amplify Console application.

Stability

experimental

Example:

# Example automatically generated from non-compiling source. May contain errors.
import aws_cdk.aws_codebuild as codebuild
import aws_cdk.aws_amplify as amplify
import aws_cdk.core as cdk

amplify_app = amplify.App(self, "MyApp",
    source_code_provider=amplify.GitHubSourceCodeProvider(
        owner="<user>",
        repository="<repo>",
        oauth_token=cdk.SecretValue.secrets_manager("my-github-token")
    ),
    build_spec=codebuild.BuildSpec.from_object_to_yaml({ # Alternatively add a `amplify.yml` to the repo
        "version": "1.0",
        "frontend": {
            "phases": {
                "pre_build": {
                    "commands": ["yarn"
                    ]
                },
                "build": {
                    "commands": ["yarn build"
                    ]
                }
            },
            "artifacts": {
                "base_directory": "public",
                "files": -"**/*"
            }
        }})
)
Parameters
  • scope (Construct) –

  • id (str) –

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

  • auto_branch_creation (Optional[AutoBranchCreation]) – (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[CustomResponseHeader]]) – (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, *, auto_build=None, basic_auth=None, branch_name=None, build_spec=None, description=None, environment_variables=None, pull_request_environment_name=None, pull_request_preview=None, stage=None)

(experimental) Adds a branch to this application.

Parameters
  • id (str) –

  • 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

  • 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[SubDomain]]) – (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

Return type

str

app_name

(experimental) The name of the application.

Stability

experimental

Attribute

true

Return type

str

arn

(experimental) The ARN of the application.

Stability

experimental

Attribute

true

Return type

str

default_domain

(experimental) The default domain of the application.

Stability

experimental

Attribute

true

Return type

str

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.

Return type

ResourceEnvironment

grant_principal

(experimental) The principal to grant permissions to.

Stability

experimental

Return type

IPrincipal

node

The construct tree node associated with this construct.

Return type

ConstructNode

stack

The stack in which this resource is defined.

Return type

Stack

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