App
- class aws_cdk.aws_amplify_alpha.App(scope, id, *, app_name=None, auto_branch_creation=None, auto_branch_deletion=None, basic_auth=None, build_spec=None, cache_config_type=None, custom_response_headers=None, custom_rules=None, description=None, environment_variables=None, platform=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 nameauto_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 creationauto_branch_deletion (
Optional
[bool
]) – (experimental) Automatically disconnect a branch in the Amplify Console when you delete a branch from your Git repository. Default: falsebasic_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 protectionbuild_spec (
Optional
[BuildSpec
]) – (experimental) BuildSpec for the application. Alternatively, add aamplify.yml
file to the repository. Default: - no build speccache_config_type (
Optional
[CacheConfigType
]) – (experimental) The type of cache configuration to use for an Amplify app. Default: CacheConfigType.AMPLIFY_MANAGEDcustom_response_headers (
Optional
[Sequence
[Union
[CustomResponseHeader
,Dict
[str
,Any
]]]]) – (experimental) The custom HTTP response headers for an Amplify app. Default: - no custom response headerscustom_rules (
Optional
[Sequence
[CustomRule
]]) – (experimental) Custom rewrite/redirect rules for the application. Default: - no custom rewrite/redirect rulesdescription (
Optional
[str
]) – (experimental) A description for the application. Default: - no descriptionenvironment_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 variablesplatform (
Optional
[Platform
]) – (experimental) 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). Default: Platform.WEBrole (
Optional
[IRole
]) – (experimental) The IAM service role to associate with the application. The App implements IGrantable. Default: - a new role is createdsource_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:
- 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 assetauto_build (
Optional
[bool
]) – (experimental) Whether to enable auto building for the branch. Default: truebasic_auth (
Optional
[BasicAuth
]) – (experimental) The Basic Auth configuration. Use this to set password protection for the branch Default: - no password protectionbranch_name (
Optional
[str
]) – (experimental) The name of the branch. Default: - the construct’s idbuild_spec (
Optional
[BuildSpec
]) – (experimental) BuildSpec for the branch. Default: - no build specdescription (
Optional
[str
]) – (experimental) A description for the branch. Default: - no descriptionenvironment_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 variablesperformance_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: falsepull_request_environment_name (
Optional
[str
]) – (experimental) The dedicated backend environment for the pull request previews. Default: - automatically provision a temporary backendpull_request_preview (
Optional
[bool
]) – (experimental) Whether to enable pull request preview for the branch. Default: truestage (
Optional
[str
]) – (experimental) Stage for the branch. Default: - no stage
- Stability:
experimental
- Return type:
- add_custom_rule(rule)
(experimental) Adds a custom rewrite/redirect rule to this application.
- Parameters:
rule (
CustomRule
) –- Stability:
experimental
- Return type:
- add_domain(id, *, auto_subdomain_creation_patterns=None, custom_certificate=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*’]custom_certificate (
Optional
[ICertificate
]) – (experimental) The type of SSL/TLS certificate to use for your custom domain. Default: - Amplify uses the default certificate that it provisions and manages for youdomain_name (
Optional
[str
]) – (experimental) The name of the domain. Default: - the construct’s idenable_auto_subdomain (
Optional
[bool
]) – (experimental) Automatically create subdomains for connected branches. Default: falsesub_domains (
Optional
[Sequence
[Union
[SubDomain
,Dict
[str
,Any
]]]]) – (experimental) Subdomains. Default: - useaddSubDomain()
to add subdomains
- Stability:
experimental
- Return type:
- 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:
- 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 tree node.
- stack
The stack in which this resource is defined.
Static Methods
- classmethod from_app_id(scope, id, app_id)
(experimental) Import an existing application.
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
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 classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
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 theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool