22
33// eslint-disable-next-line import/no-extraneous-dependencies
44import * as AWS from 'aws-sdk' ;
5- import { LogRetentionRetryOptions } from '../log-retention' ;
65
76/**
87 * Creates a log group and doesn't throw if it exists.
98 *
10- * @param logGroupName the name of the log group to create
9+ * @param logGroupName the name of the log group to create.
10+ * @param options CloudWatch API SDK options.
1111 */
12- async function createLogGroupSafe ( logGroupName : string , retryOptions ?: LogRetentionRetryOptions ) {
12+ async function createLogGroupSafe ( logGroupName : string , options ?: any ) {
1313 try { // Try to create the log group
14- const cloudwatchlogs = new AWS . CloudWatchLogs ( { apiVersion : '2014-03-28' , ...retryOptions } ) ;
14+ const cloudwatchlogs = new AWS . CloudWatchLogs ( { apiVersion : '2014-03-28' , ...options } ) ;
1515 await cloudwatchlogs . createLogGroup ( { logGroupName } ) . promise ( ) ;
1616 } catch ( e ) {
1717 if ( e . code !== 'ResourceAlreadyExistsException' ) {
@@ -24,10 +24,11 @@ async function createLogGroupSafe(logGroupName: string, retryOptions?: LogRetent
2424 * Puts or deletes a retention policy on a log group.
2525 *
2626 * @param logGroupName the name of the log group to create
27+ * @param options CloudWatch API SDK options.
2728 * @param retentionInDays the number of days to retain the log events in the specified log group.
2829 */
29- async function setRetentionPolicy ( logGroupName : string , retryOptions ?: LogRetentionRetryOptions , retentionInDays ?: number ) {
30- const cloudwatchlogs = new AWS . CloudWatchLogs ( { apiVersion : '2014-03-28' , ...retryOptions } ) ;
30+ async function setRetentionPolicy ( logGroupName : string , options ?: any , retentionInDays ?: number ) {
31+ const cloudwatchlogs = new AWS . CloudWatchLogs ( { apiVersion : '2014-03-28' , ...options } ) ;
3132 if ( ! retentionInDays ) {
3233 await cloudwatchlogs . deleteRetentionPolicy ( { logGroupName } ) . promise ( ) ;
3334 } else {
@@ -42,8 +43,8 @@ export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent
4243 // The target log group
4344 const logGroupName = event . ResourceProperties . LogGroupName ;
4445
45- // Parse retry options for creating the target log group
46- const retryOptions = parseRetryOptions ( event . ResourceProperties . LogRetentionRetryOptions ) ;
46+ // Parse to AWS SDK retry options
47+ const retryOptions = parseRetryOptions ( event . ResourceProperties . SdkRetry ) ;
4748
4849 if ( event . RequestType === 'Create' || event . RequestType === 'Update' ) {
4950 // Act on the target log group
0 commit comments