> **Experimental**
>
> `@aws-cdk/aws-amplify-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# AutoBranchCreation

Auto branch creation configuration.

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/app.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-amplify-alpha/lib/app.ts#L398)

## Example

TypeScript:

```ts
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
});
```

Python:

```python
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
)
```

Java:

```java
App amplifyApp = App.Builder.create(this, "MyApp")
        .sourceCodeProvider(GitHubSourceCodeProvider.Builder.create()
                .owner("<user>")
                .repository("<repo>")
                .oauthToken(SecretValue.secretsManager("my-github-token"))
                .build())
        .autoBranchCreation(AutoBranchCreation.builder() // Automatically connect branches that match a pattern set
                .patterns(List.of("feature/*", "test/*")).build())
        .autoBranchDeletion(true)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Amplify.Alpha
var amplifyApp = new App(this, "MyApp", new AppProps {
    SourceCodeProvider = new GitHubSourceCodeProvider(new GitHubSourceCodeProviderProps {
        Owner = "<user>",
        Repository = "<repo>",
        OauthToken = SecretValue.SecretsManager("my-github-token")
    }),
    AutoBranchCreation = new AutoBranchCreation {  // Automatically connect branches that match a pattern set
        Patterns = new [] { "feature/*", "test/*" } },
    AutoBranchDeletion = true
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2
amplifyApp := amplify.NewApp(this, jsii.String("MyApp"), &AppProps{
	SourceCodeProvider: amplify.NewGitHubSourceCodeProvider(&GitHubSourceCodeProviderProps{
		Owner: jsii.String("<user>"),
		Repository: jsii.String("<repo>"),
		OauthToken: awscdk.SecretValue_SecretsManager(jsii.String("my-github-token")),
	}),
	AutoBranchCreation: &AutoBranchCreation{
		 // Automatically connect branches that match a pattern set
		Patterns: []*string{
			jsii.String("feature/*"),
			jsii.String("test/*"),
		},
	},
	AutoBranchDeletion: jsii.Boolean(true),
})
```

## Properties

- `autoBuild`: boolean = true — Whether to enable auto building for the auto created branch.

- `basicAuth`: [BasicAuth](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-amplify-alpha.BasicAuth.html) — The Basic Auth configuration.

  **Default:** no password protection

  Use this to set password protection for
  the auto created branch.

- `buildSpec`: [BuildSpec](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildSpec.html) — Build spec for the auto created branch.

  **Default:** application build spec

- `environmentVariables`: { [key: string]: string } — Environment variables for the auto created branch.

  **Default:** application environment variables

  All environment variables that you add are encrypted to prevent rogue
  access so you can use them to store secret information.

- `patterns`: string[] — Automated branch creation glob patterns.

  **Default:** all repository branches

- `pullRequestEnvironmentName`: string — The dedicated backend environment for the pull request previews of the auto created branch.

  **Default:** automatically provision a temporary backend

- `pullRequestPreview`: boolean = true — Whether to enable pull request preview for the auto created branch.

- `stage`: string — Stage for the auto created branch.

  **Default:** no stage
