class App (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Amplify.App |
Java | software.amazon.awscdk.services.amplify.App |
Python | aws_cdk.aws_amplify.App |
TypeScript (source) | @aws-cdk/aws-amplify ยป App |
Implements
IConstruct
, 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. |
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. |
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
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.
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 | Construct | The construct tree node associated with this construct. |
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:
Construct
The construct tree node associated with this construct.
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. |
AutoBranchEnvironment(name, value)
addpublic 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.
Branch(id, options?)
addpublic addBranch(id: string, options?: BranchOptions): Branch
Parameters
- id
string
- options
Branch
Options
Returns
Adds a branch to this application.
CustomRule(rule)
addpublic addCustomRule(rule: CustomRule): App
Parameters
- rule
Custom
Rule
Returns
Adds a custom rewrite/redirect rule to this application.
Domain(id, options?)
addpublic addDomain(id: string, options?: DomainOptions): Domain
Parameters
- id
string
- options
Domain
Options
Returns
Adds a domain to this application.
Environment(name, value)
addpublic 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.
RemovalPolicy(policy)
applypublic 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
).
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
AppId(scope, id, appId)
static frompublic static fromAppId(scope: Construct, id: string, appId: string): IApp
Parameters
- scope
Construct
- id
string
- appId
string
Returns
Import an existing application.