AWS Amplify Console Branch

This page shows how to write Terraform and CloudFormation for Amplify Console Branch and write them securely.

aws_amplify_branch (Terraform)

The Branch in Amplify Console can be configured in Terraform with the resource name aws_amplify_branch. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

app.tf#L35
resource "aws_amplify_branch" "dev" {
  app_id      = aws_amplify_app.jay-biesh-site.id
  branch_name = "dev"

  stage = "DEVELOPMENT"

amplify-branch.tf#L2
resource "aws_amplify_branch" "master" {
  app_id      = aws_amplify_app.testofamplify.id
  branch_name = var.git_production_branch

  framework = "React"
  stage     = "PRODUCTION"
amplify.tf#L32
resource "aws_amplify_branch" "develop" {
  app_id            = aws_amplify_app.front_app.id
  branch_name       = "main"
  stage             = "PRODUCTION"
  enable_auto_build = true
}
main.tf#L40
resource "aws_amplify_branch" "main" {
  app_id      = aws_amplify_app.app2.id
  branch_name = "main"

  stage     = "PRODUCTION"

main.tf#L23
resource "aws_amplify_branch" "master" {
  app_id      = aws_amplify_app.app.id
  branch_name = var.Branch

  stage     = var.Stage

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

The following arguments are supported:

  • app_id - (Required) The unique ID for an Amplify app.
  • branch_name - (Required) The name for the branch.
  • backend_environment_arn - (Optional) The Amazon Resource Name (ARN) for a backend environment that is part of an Amplify app.
  • basic_auth_credentials - (Optional) The basic authorization credentials for the branch.
  • description - (Optional) The description for the branch.
  • display_name - (Optional) The display name for a branch. This is used as the default domain prefix.
  • enable_auto_build - (Optional) Enables auto building for the branch.
  • enable_basic_auth - (Optional) Enables basic authorization for the branch.
  • enable_notification - (Optional) Enables notifications for the branch.
  • enable_performance_mode - (Optional) Enables performance mode for the branch.
  • enable_pull_request_preview - (Optional) Enables pull request previews for this branch.
  • environment_variables - (Optional) The environment variables for the branch.
  • framework - (Optional) The framework for the branch.
  • pull_request_environment_name - (Optional) The Amplify environment name for the pull request.
  • stage - (Optional) Describes the current stage for the branch. Valid values: PRODUCTION, BETA, DEVELOPMENT, EXPERIMENTAL, PULL_REQUEST.
  • tags - (Optional) Key-value mapping of resource tags. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
  • ttl - (Optional) The content Time To Live (TTL) for the website in seconds.

In addition to all arguments above, the following attributes are exported:

  • arn - The Amazon Resource Name (ARN) for the branch.
  • associated_resources - A list of custom resources that are linked to this branch.
  • custom_domains - The custom domains for the branch.
  • destination_branch - The destination branch if the branch is a pull request branch.
  • source_branch - The source branch if the branch is a pull request branch.
  • tags_all - A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Explanation in Terraform Registry

Provides an Amplify Branch resource.

AWS::Amplify::Branch (CloudFormation)

The Branch in Amplify can be configured in CloudFormation with the resource name AWS::Amplify::Branch. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

stack.yml#L61
    Type: AWS::Amplify::Branch
    Properties:
      BranchName: !Ref Branch
      AppId: !GetAtt AmplifyApp.AppId
      EnableAutoBuild: true

cd.yml#L56
    Type: 'AWS::Amplify::Branch'
    Properties:
      BranchName: 'develop'
      AppId: !GetAtt 'AmplifyApp.AppId'
      # BasicAuthConfig:
      #   EnableBasicAuth: true
BuildSpec.yml#L54
      Type: AWS::Amplify::Branch
      Properties:
        AppId: !GetAtt AmplifyApp.AppId
        BranchName: ${{self:custom.branch}}
        EnableAutoBuild: true
        Stage: ${{self:custom.amplifyStage}}
amplify_branch_basic_auth_config_password_parameter_with_noecho_and_default_value.yaml#L9
    Type: AWS::Amplify::Branch
    Properties:
      AppId: foo
      BranchName: bar
      BasicAuthConfig:
        Password: !Ref AmplifyBranchBasicAuthConfigPassword
amplify_branch_basic_auth_config_password_parameter_with_noecho.yaml#L8
    Type: AWS::Amplify::Branch
    Properties:
      AppId: foo
      BranchName: bar
      BasicAuthConfig:
        Password: !Ref AmplifyBranchBasicAuthConfigPassword
amplifyhosting-template.json#L28
            "Type": "AWS::Amplify::Branch",
            "Properties": {
                "BranchName": {
                    "Ref": "env"
                },
                "AppId": {
amplifyhosting-template.json#L28
            "Type": "AWS::Amplify::Branch",
            "Properties": {
                "BranchName": {
                    "Ref": "env"
                },
                "AppId": {
amplifyhosting-template.json#L28
            "Type": "AWS::Amplify::Branch",
            "Properties": {
                "BranchName": {
                    "Ref": "env"
                },
                "AppId": {
amplifyhosting-template.json#L28
            "Type": "AWS::Amplify::Branch",
            "Properties": {
                "BranchName": {
                    "Ref": "env"
                },
                "AppId": {
amplifyhosting-template.json#L28
            "Type": "AWS::Amplify::Branch",
            "Properties": {
                "BranchName": {
                    "Ref": "env"
                },
                "AppId": {

Parameters

Explanation in CloudFormation Registry

The AWS::Amplify::Branch resource creates a new branch within an app.

Frequently asked questions

What is AWS Amplify Console Branch?

AWS Amplify Console Branch is a resource for Amplify Console of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amplify Console Branch?

For Terraform, the DasJayYa/jay_bieshaar_site, naoyahieda/terraform_amplify_cicd_example and Tiino1/serverless-webapp source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the paschalidi/deploy-cloudfomrations-stacks, claptime/claptime and OlawaleLasisi/CD4WebsiteWithAWSAmplify source code examples are useful. See the CloudFormation Example section for further details.