class App (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Amplify.Alpha.App |
![]() | github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2#App |
![]() | software.amazon.awscdk.services.amplify.alpha.App |
![]() | aws_cdk.aws_amplify_alpha.App |
![]() | @aws-cdk/aws-amplify-alpha ยป App |
Implements
IConstruct
, IDependable
, IResource
, IApp
, IGrantable
An Amplify Console application.
Example
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
});
Initializer
new App(scope: Construct, id: string, props: AppProps)
Parameters
Construct Props
Name | Type | Description |
---|---|---|
app | string | The name for the application. |
auto | Auto | The auto branch creation configuration. |
auto | boolean | Automatically disconnect a branch in the Amplify Console when you delete a branch from your Git repository. |
basic | Basic | The Basic Auth configuration. |
build | Build | BuildSpec for the application. |
cache | Cache | The type of cache configuration to use for an Amplify app. |
custom | Custom [] | The custom HTTP response headers for an Amplify app. |
custom | Custom [] | Custom rewrite/redirect rules for the application. |
description? | string | A description for the application. |
environment | { [string]: string } | Environment variables for the application. |
platform? | Platform | Indicates the hosting platform to use. |
role? | IRole | The IAM service role to associate with the application. |
source | ISource | The source code provider for this application. |
appName?
Type:
string
(optional, default: a CDK generated name)
The name for the application.
autoBranchCreation?
Type:
Auto
(optional, default: no auto branch creation)
The auto branch creation configuration.
Use this to automatically create branches that match a certain pattern.
autoBranchDeletion?
Type:
boolean
(optional, default: false)
Automatically disconnect a branch in the Amplify Console when you delete a branch from your Git repository.
basicAuth?
Type:
Basic
(optional, default: no password protection)
The Basic Auth configuration.
Use this to set password protection at an app level to all your branches.
buildSpec?
Type:
Build
(optional, default: no build spec)
BuildSpec for the application.
Alternatively, add a amplify.yml
file to the repository.
See also: https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html
cacheConfigType?
Type:
Cache
(optional, default: CacheConfigType.AMPLIFY_MANAGED)
The type of cache configuration to use for an Amplify app.
customResponseHeaders?
Type:
Custom
[]
(optional, default: no custom response headers)
The custom HTTP response headers for an Amplify app.
See also: https://docs.aws.amazon.com/amplify/latest/userguide/custom-headers.html
customRules?
Type:
Custom
[]
(optional, default: no custom rewrite/redirect rules)
Custom rewrite/redirect rules for the application.
description?
Type:
string
(optional, default: no description)
A description for the application.
environmentVariables?
Type:
{ [string]: string }
(optional, default: no environment variables)
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.
platform?
Type:
Platform
(optional, default: 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).
role?
Type:
IRole
(optional, default: a new role is created)
The IAM service role to associate with the application.
The App implements IGrantable.
sourceCodeProvider?
Type:
ISource
(optional, default: not connected to a source code provider)
The source code provider for this application.
Properties
Name | Type | Description |
---|---|---|
app | string | The application id. |
app | string | The name of the application. |
arn | string | The ARN of the application. |
default | string | The default domain of the application. |
env | Resource | The environment this resource belongs to. |
grant | IPrincipal | The principal to grant permissions to. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
appId
Type:
string
The application id.
appName
Type:
string
The name of the application.
arn
Type:
string
The ARN of the application.
defaultDomain
Type:
string
The default domain of the application.
env
Type:
Resource
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.
grantPrincipal
Type:
IPrincipal
The principal to grant permissions to.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
add | Adds an environment variable to the auto created branch. |
add | Adds a branch to this application. |
add | Adds a custom rewrite/redirect rule to this application. |
add | Adds a domain to this application. |
add | Adds an environment variable to this application. |
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import an existing application. |
addAutoBranchEnvironment(name, value)
public addAutoBranchEnvironment(name: string, value: string): App
Parameters
- name
string
- value
string
Returns
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, options?)
public addBranch(id: string, options?: BranchOptions): Branch
Parameters
- id
string
- options
Branch
Options
Returns
Adds a branch to this application.
addCustomRule(rule)
public addCustomRule(rule: CustomRule): App
Parameters
- rule
Custom
Rule
Returns
Adds a custom rewrite/redirect rule to this application.
addDomain(id, options?)
public addDomain(id: string, options?: DomainOptions): Domain
Parameters
- id
string
- options
Domain
Options
Returns
Adds a domain to this application.
addEnvironment(name, value)
public addEnvironment(name: string, value: string): App
Parameters
- name
string
- value
string
Returns
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.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
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
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromAppId(scope, id, appId)
public static fromAppId(scope: Construct, id: string, appId: string): IApp
Parameters
- scope
Construct
- id
string
- appId
string
Returns
Import an existing application.