-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(includeApiGWLogs): Adding support for API Gateway logs. Fixes #10 (
#15)
- Loading branch information
1 parent
7dd4377
commit dd7fddd
Showing
12 changed files
with
618 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import _ from 'lodash'; | ||
|
||
import { ITemplate, ITemplateProperty } from '../interfaces'; | ||
|
||
export class LambdaPermissionBuilder { | ||
private readonly defaultTemplate: ITemplate = { | ||
Properties: { | ||
Action: 'lambda:InvokeFunction', | ||
SourceAccount: { | ||
'Fn::Sub': '${AWS::AccountId}', | ||
}, | ||
}, | ||
Type: 'AWS::Lambda::Permission', | ||
}; | ||
|
||
constructor(private template?: ITemplate) { | ||
this.template = _.merge(this.defaultTemplate, template || {}); | ||
} | ||
|
||
public withAction(action: string): LambdaPermissionBuilder { | ||
this.template!.Properties.Action = action; | ||
return this; | ||
} | ||
|
||
public withFunctionName(functionName: ITemplateProperty): LambdaPermissionBuilder { | ||
this.template!.Properties.FunctionName = functionName; | ||
return this; | ||
} | ||
|
||
public withPrincipal(principal: ITemplateProperty): LambdaPermissionBuilder { | ||
this.template!.Properties.Principal = principal; | ||
return this; | ||
} | ||
|
||
public withSourceAccount(sourceAccount: ITemplateProperty): LambdaPermissionBuilder { | ||
this.template!.Properties.SourceAccount = sourceAccount; | ||
return this; | ||
} | ||
|
||
public withSourceArn(sourceArn: ITemplateProperty): LambdaPermissionBuilder { | ||
this.template!.Properties.SourceArn = sourceArn; | ||
return this; | ||
} | ||
|
||
public withDependsOn(dependsOn: string[]): LambdaPermissionBuilder { | ||
this.template!.DependsOn = dependsOn; | ||
return this; | ||
} | ||
|
||
public build(): ITemplate { | ||
const { Action, FunctionName, Principal, SourceAccount, SourceArn } = this.template!.Properties; | ||
if (!Action || !FunctionName || !Principal || !SourceAccount || !SourceArn) { | ||
throw new Error('Missing a required property.'); | ||
} | ||
return this.template as ITemplate; | ||
} | ||
} |
Oops, something went wrong.