Skip to content

Commit

Permalink
fix(amplify): deployment does not remove basic auth (aws#15243)
Browse files Browse the repository at this point in the history
Removing the `BasicAuthConfig` property from the template doesn't remove
the basic auth. Explicitely set `EnableBasicAuth` to `false` instead.

Closes aws#15028


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jogold authored and Seiya6329 committed Jun 22, 2021
1 parent c0bfb71 commit 249c367
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-amplify/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ export class App extends Resource implements IApp, iam.IGrantable {
accessToken: sourceCodeProviderOptions?.accessToken?.toString(),
autoBranchCreationConfig: props.autoBranchCreation && {
autoBranchCreationPatterns: props.autoBranchCreation.patterns,
basicAuthConfig: props.autoBranchCreation.basicAuth && props.autoBranchCreation.basicAuth.bind(this, 'BranchBasicAuth'),
basicAuthConfig: props.autoBranchCreation.basicAuth
? props.autoBranchCreation.basicAuth.bind(this, 'BranchBasicAuth')
: { enableBasicAuth: false },
buildSpec: props.autoBranchCreation.buildSpec && props.autoBranchCreation.buildSpec.toBuildSpec(),
enableAutoBranchCreation: true,
enableAutoBuild: props.autoBranchCreation.autoBuild ?? true,
Expand All @@ -225,7 +227,9 @@ export class App extends Resource implements IApp, iam.IGrantable {
stage: props.autoBranchCreation.stage,
},
enableBranchAutoDeletion: props.autoBranchDeletion,
basicAuthConfig: props.basicAuth && props.basicAuth.bind(this, 'AppBasicAuth'),
basicAuthConfig: props.basicAuth
? props.basicAuth.bind(this, 'AppBasicAuth')
: { enableBasicAuth: false },
buildSpec: props.buildSpec && props.buildSpec.toBuildSpec(),
customRules: Lazy.any({ produce: () => this.customRules }, { omitEmptyArray: true }),
description: props.description,
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-amplify/test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ test('create an app connected to a GitHub repository', () => {
},
OauthToken: 'secret',
Repository: 'https://github.com/aws/aws-cdk',
BasicAuthConfig: {
EnableBasicAuth: false,
},
});

expect(stack).toHaveResource('AWS::IAM::Role', {
Expand Down Expand Up @@ -355,6 +358,9 @@ test('with auto branch creation', () => {
// THEN
expect(stack).toHaveResource('AWS::Amplify::App', {
AutoBranchCreationConfig: {
BasicAuthConfig: {
EnableBasicAuth: false,
},
EnableAutoBranchCreation: true,
EnableAutoBuild: true,
EnablePullRequestPreview: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"Type": "AWS::Amplify::App",
"Properties": {
"Name": "App",
"BasicAuthConfig": {
"EnableBasicAuth": false
},
"IAMServiceRole": {
"Fn::GetAtt": [
"AppRole1AF9B530",
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-amplify/test/integ.app.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"Properties": {
"Name": "App",
"AutoBranchCreationConfig": {
"BasicAuthConfig": {
"EnableBasicAuth": false
},
"EnableAutoBranchCreation": true,
"EnableAutoBuild": true,
"EnablePullRequestPreview": true
Expand Down

0 comments on commit 249c367

Please sign in to comment.