Skip to content

Commit

Permalink
Merge branch 'master' into epolon/eks-asg-replacement-ssm
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Aug 17, 2020
2 parents 381d102 + 4ee37a4 commit 526a8a0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
9 changes: 6 additions & 3 deletions packages/@aws-cdk/aws-amplify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,17 @@ app.addBranch('feature/next', {
});
```

### Automatically creating branches
Use the `autoBranchCreation` prop to automatically create new branches:
### Automatically creating and deleting branches
Use the `autoBranchCreation` and `autoBranchDeletion` props to control creation/deletion
of branches:

```ts
const amplifyApp = new amplify.App(this, 'MyApp', {
repository: 'https://github.com/<user>/<repo>',
oauthToken: cdk.SecretValue.secretsManager('my-github-token'),
autoBranchCreation: {
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
});
```
11 changes: 10 additions & 1 deletion packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ export interface AppProps {
*/
readonly autoBranchCreation?: AutoBranchCreation;

/**
* Automatically disconnect a branch in the Amplify Console when you delete a
* branch from your Git repository.
*
* @default false
*/
readonly autoBranchDeletion?: boolean;

/**
* The Basic Auth configuration. Use this to set password protection at an
* app level to all your branches.
Expand Down Expand Up @@ -210,11 +218,12 @@ export class App extends Resource implements IApp, iam.IGrantable {
buildSpec: props.autoBranchCreation.buildSpec && props.autoBranchCreation.buildSpec.toBuildSpec(),
enableAutoBranchCreation: true,
enableAutoBuild: props.autoBranchCreation.autoBuild === undefined ? true : props.autoBranchCreation.autoBuild,
environmentVariables: Lazy.anyValue({ produce: () => renderEnvironmentVariables(this.autoBranchEnvironmentVariables )}, { omitEmptyArray: true }), // eslint-disable-line max-len
environmentVariables: Lazy.anyValue({ produce: () => renderEnvironmentVariables(this.autoBranchEnvironmentVariables ) }, { omitEmptyArray: true }), // eslint-disable-line max-len
enablePullRequestPreview: props.autoBranchCreation.pullRequestPreview === undefined ? true : props.autoBranchCreation.pullRequestPreview,
pullRequestEnvironmentName: props.autoBranchCreation.pullRequestEnvironmentName,
stage: props.autoBranchCreation.stage,
},
enableBranchAutoDeletion: props.autoBranchDeletion,
basicAuthConfig: props.basicAuth && props.basicAuth.bind(this, 'AppBasicAuth'),
buildSpec: props.buildSpec && props.buildSpec.toBuildSpec(),
customRules: Lazy.anyValue({ produce: () => this.customRules }, { omitEmptyArray: true }),
Expand Down
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-amplify/test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,20 @@ test('with auto branch creation', () => {
},
});
});

test('with auto branch deletion', () => {
// WHEN
new amplify.App(stack, 'App', {
sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
owner: 'aws',
repository: 'aws-cdk',
oauthToken: SecretValue.plainText('secret'),
}),
autoBranchDeletion: true,
});

// THEN
expect(stack).toHaveResource('AWS::Amplify::App', {
EnableBranchAutoDeletion: true,
});
});
2 changes: 1 addition & 1 deletion scripts/check-prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ check_which() {

w=$(which ${app}) || w=""

if [ -z $w ] || [ $w == "$app not found" ]
if [ -z "$w" ] || [ "$w" == "$app not found" ]
then
die "Missing dependency: $app. Install $app >= $min"
else
Expand Down

0 comments on commit 526a8a0

Please sign in to comment.