Skip to content

Commit

Permalink
fix(apigateway): authorizer name is not optional (#5731)
Browse files Browse the repository at this point in the history
The authorizer name property is marked as optional in CloudFormation
docs but is actually not.

Use the TokenAuthorizer node's uniquId as the default.

fixes #5678

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
nija-at and mergify[bot] committed Jan 9, 2020
1 parent c53356a commit 21c425e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts
Expand Up @@ -13,7 +13,7 @@ export interface TokenAuthorizerProps {
/**
* An optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer.
*
* @default - none
* @default this.node.uniqueId
*/
readonly authorizerName?: string;

Expand Down Expand Up @@ -92,7 +92,7 @@ export class TokenAuthorizer extends Authorizer implements IAuthorizer {
const restApiId = Lazy.stringValue({ produce: () => this.restApiId });

const resource = new CfnAuthorizer(this, 'Resource', {
name: props.authorizerName,
name: props.authorizerName ?? this.node.uniqueId,
restApiId,
type: 'TOKEN',
authorizerUri: `arn:aws:apigateway:${Stack.of(this).region}:lambda:path/2015-03-31/functions/${props.handler.functionArn}/invocations`,
Expand Down
Expand Up @@ -105,6 +105,7 @@
"MyAuthorizer6575980E": {
"Type": "AWS::ApiGateway::Authorizer",
"Properties": {
"Name": "TokenAuthorizerIAMRoleIntegMyAuthorizer1DFDE3B5",
"RestApiId": {
"Ref": "MyRestApi2D1F47A9"
},
Expand Down
Expand Up @@ -199,6 +199,7 @@
"MyAuthorizer6575980E": {
"Type": "AWS::ApiGateway::Authorizer",
"Properties": {
"Name": "TokenAuthorizerIntegMyAuthorizer793B1D5F",
"RestApiId": {
"Ref": "MyRestApi2D1F47A9"
},
Expand Down

0 comments on commit 21c425e

Please sign in to comment.