(aws-amplify-alpha): Amplify ProductionBranch not being populated on cdk deploy
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### What is the problem?
When using CDK to deploy Amplify, the Production Branch field is not being populated. Production Branch also does not populate after successful build. I cannot find anywhere in the documentation where ProductionBranch can be defined. This is the closest documentation i could find: [Amplify API](https://docs.aws.amazon.com/amplify/latest/APIReference/API_ProductionBranch.html).
I also tried with the aws_amplify package for cdk2.0 as well.

### Reproduction Steps
Deploy Amplify App using GitHub repo as the provider.
Code I am using:
```
import * as cdk from "aws-cdk-lib";
import * as amplify from '@aws-cdk/aws-amplify-alpha';
import { Construct } from "constructs";
export interface CdkInfraStack extends cdk.StackProps {
owner: string;
repository: string;
role: string;
domain: string;
}
export class AmplifyInfraStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: CdkInfraStack) {
super(scope, id, props);
// Amplify Application
const amplifyApp = new amplify.App(this, "next-js-amplify", {
sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
owner: props.owner,
repository: props.repository,
oauthToken: cdk.SecretValue.secretsManager("github/pat/crs-k", {
jsonField: "githubPat",
}),
}),
role: cdk.aws_iam.Role.fromRoleArn(this,'service-role',props.role) // necessary for explictly defining a service role that can create other resources as needed.
});
const main = amplifyApp.addBranch("main", {autoBuild: true});
const domain = amplifyApp.addDomain(props.domain, {
enableAutoSubdomain: true, // subdomains auto registered for branches
autoSubdomainCreationPatterns: ['*'], // regex for branches that should auto registered as subdomains
});
domain.mapRoot(main); // map main branch to domain root
domain.mapSubDomain(main, 'www');
}
}
```
### What did you expect to happen?
Production Branch field to be populated with addBranch or default branch name.
### What actually happened?
Production Branch field was unpopulated.
### CDK CLI Version
2.10.0
### Framework Version
_No response_
### Node.js Version
17.3
### OS
windows & ubuntu
### Language
Typescript
### Language Version
4.5.5
### Other information
_No response_
Contributor guide
Research direction
Reproduce the provided TypeScript stack using the aws-amplify-alpha App, addBranch, and GitHubSourceCodeProvider entry points, then trace how the branch and production-branch settings are represented during deployment. Done means the deployed Amplify application populates Production Branch after CDK deployment or a successful build, with a regression test covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100