Skip to content

Commit

Permalink
feat: upgrade to CDK v2
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Dec 16, 2021
1 parent 0511acc commit 63e9523
Show file tree
Hide file tree
Showing 5 changed files with 6,355 additions and 8,601 deletions.
2 changes: 1 addition & 1 deletion cdk/App.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as CloudFormation from '@aws-cdk/core'
import * as CloudFormation from 'aws-cdk-lib'
import { Stack } from './Stack'

export class App extends CloudFormation.App {
Expand Down
21 changes: 11 additions & 10 deletions cdk/CleanerLambda.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import * as CloudFormation from '@aws-cdk/core'
import * as Lambda from '@aws-cdk/aws-lambda'
import * as IAM from '@aws-cdk/aws-iam'
import * as CloudWatchLogs from '@aws-cdk/aws-logs'
import * as Events from '@aws-cdk/aws-events'
import * as EventsTargets from '@aws-cdk/aws-events-targets'
import { Construct } from 'constructs'
import { Duration, RemovalPolicy } from 'aws-cdk-lib'
import { aws_lambda as Lambda } from 'aws-cdk-lib'
import { aws_iam as IAM } from 'aws-cdk-lib'
import { aws_logs as CloudWatchLogs } from 'aws-cdk-lib'
import { aws_events as Events } from 'aws-cdk-lib'
import { aws_events_targets as EventsTargets } from 'aws-cdk-lib'
import * as path from 'path'
import * as fs from 'fs'

export class CleanerLambda extends CloudFormation.Construct {
export class CleanerLambda extends Construct {
public readonly lambda: Lambda.IFunction
public constructor(
parent: CloudFormation.Construct,
parent: Construct,
id: string,
source: 'stack-cleaner' | 'log-group-cleaner',
layers: Lambda.ILayerVersion[],
Expand All @@ -27,7 +28,7 @@ export class CleanerLambda extends CloudFormation.Construct {
description: `Cleans old CloudFormation resources (${source})`,
handler: 'index.handler',
runtime: Lambda.Runtime.NODEJS_12_X, // NODEJS_14_X does not support inline functions, yet. See https://github.com/aws/aws-cdk/pull/12861#discussion_r570038002,
timeout: CloudFormation.Duration.seconds(60),
timeout: Duration.seconds(60),
initialPolicy: [
new IAM.PolicyStatement({
resources: ['*'],
Expand All @@ -38,7 +39,7 @@ export class CleanerLambda extends CloudFormation.Construct {
})

new CloudWatchLogs.LogGroup(this, 'LogGroup', {
removalPolicy: CloudFormation.RemovalPolicy.DESTROY,
removalPolicy: RemovalPolicy.DESTROY,
logGroupName: `/aws/lambda/${this.lambda.functionName}`,
retention: CloudWatchLogs.RetentionDays.ONE_WEEK,
})
Expand Down
4 changes: 2 additions & 2 deletions cdk/Stack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as CloudFormation from '@aws-cdk/core'
import * as Lambda from '@aws-cdk/aws-lambda'
import * as CloudFormation from 'aws-cdk-lib'
import { aws_lambda as Lambda } from 'aws-cdk-lib'
import { CleanerLambda } from './CleanerLambda'

export class Stack extends CloudFormation.Stack {
Expand Down
Loading

0 comments on commit 63e9523

Please sign in to comment.