Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(apigatewayv2): authorizer is not removed when HttpNoneAuthorizer is used #14424

Merged
merged 11 commits into from
May 12, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"Ref": "LambdaProxyApi67594471"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down Expand Up @@ -185,6 +186,7 @@
"Ref": "HttpProxyApiD0217C67"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"Ref": "LambdaProxyApi67594471"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-apigatewayv2/lib/http/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export class HttpRoute extends Resource implements IHttpRoute {
]));
}

const authorizationType = authBindResult?.authorizationType === HttpAuthorizerType.NONE ? undefined : authBindResult?.authorizationType;

if (authorizationScopes?.length === 0) {
authorizationScopes = undefined;
}
Expand All @@ -167,7 +165,7 @@ export class HttpRoute extends Resource implements IHttpRoute {
routeKey: props.routeKey.key,
target: `integrations/${integration.integrationId}`,
authorizerId: authBindResult?.authorizerId,
authorizationType,
authorizationType: authBindResult?.authorizationType ?? HttpAuthorizerType.NONE, // must be explicitly NONE (not undefined) for stack updates to work correctly
nija-at marked this conversation as resolved.
Show resolved Hide resolved
authorizationScopes,
};

Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-apigatewayv2/test/http/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ describe('HttpApi', () => {

expect(stack).toHaveResource('AWS::ApiGatewayV2::Route', {
RouteKey: 'GET /chickens',
AuthorizationType: 'NONE',
AuthorizerId: ABSENT,
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-apigatewayv2/test/http/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('HttpRoute', () => {
],
],
},
AuthorizationType: 'NONE',
});

expect(stack).toHaveResource('AWS::ApiGatewayV2::Integration', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"Ref": "MyHttpApi8AEAAC21"
},
"RouteKey": "ANY /",
"AuthorizationType": "NONE",
"Target": {
"Fn::Join": [
"",
Expand Down