class Branch (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Amplify.Branch |
Java | software.amazon.awscdk.services.amplify.Branch |
Python | aws_cdk.aws_amplify.Branch |
TypeScript (source) | @aws-cdk/aws-amplify ยป Branch |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IBranch
An Amplify Console branch.
Example
declare const amplifyApp: amplify.App;
const master = amplifyApp.addBranch('master'); // `id` will be used as repo branch name
const dev = amplifyApp.addBranch('dev', {
performanceMode: true, // optional, enables performance mode
});
dev.addEnvironment('STAGE', 'dev');
Initializer
new Branch(scope: Construct, id: string, props: BranchProps)
Parameters
- scope
Construct
- id
string
- props
Branch
Props
Construct Props
Name | Type | Description |
---|---|---|
app | IApp | The application within which the branch must be created. |
asset? | Asset | Asset for deployment. |
auto | boolean | Whether to enable auto building for the branch. |
basic | Basic | The Basic Auth configuration. |
branch | string | The name of the branch. |
build | Build | BuildSpec for the branch. |
description? | string | A description for the branch. |
environment | { [string]: string } | Environment variables for the branch. |
performance | boolean | Enables performance mode for the branch. |
pull | string | The dedicated backend environment for the pull request previews. |
pull | boolean | Whether to enable pull request preview for the branch. |
stage? | string | Stage for the branch. |
app
Type:
IApp
The application within which the branch must be created.
asset?
Type:
Asset
(optional, default: no asset)
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.
autoBuild?
Type:
boolean
(optional, default: true)
Whether to enable auto building for the branch.
basicAuth?
Type:
Basic
(optional, default: no password protection)
The Basic Auth configuration.
Use this to set password protection for the branch
branchName?
Type:
string
(optional, default: the construct's id)
The name of the branch.
buildSpec?
Type:
Build
(optional, default: no build spec)
BuildSpec for the branch.
See also: https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html
description?
Type:
string
(optional, default: no description)
A description for the branch.
environmentVariables?
Type:
{ [string]: string }
(optional, default: application environment variables)
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.
performanceMode?
Type:
boolean
(optional, default: false)
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.
pullRequestEnvironmentName?
Type:
string
(optional, default: automatically provision a temporary backend)
The dedicated backend environment for the pull request previews.
pullRequestPreview?
Type:
boolean
(optional, default: true)
Whether to enable pull request preview for the branch.
stage?
Type:
string
(optional, default: no stage)
Stage for the branch.
Properties
Name | Type | Description |
---|---|---|
arn | string | The ARN of the branch. |
branch | string | The name of the branch. |
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
arn
Type:
string
The ARN of the branch.
branchName
Type:
string
The name of the branch.
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.
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 this branch. |
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import an existing branch. |
addEnvironment(name, value)
public addEnvironment(name: string, value: string): Branch
Parameters
- name
string
- value
string
Returns
Adds an environment variable to this branch.
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 fromBranchName(scope, id, branchName)
public static fromBranchName(scope: Construct, id: string, branchName: string): IBranch
Parameters
- scope
Construct
- id
string
- branchName
string
Returns
Import an existing branch.