-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for logs construct library (#207)
re #183
- Loading branch information
Showing
8 changed files
with
124 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ integration/**/yarn.lock | |
|
||
# Logs | ||
logs | ||
!integration/logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
|
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,3 @@ | ||
name: pulumi-aws-logs | ||
runtime: nodejs | ||
description: logs integration test |
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 * as kinesis from 'aws-cdk-lib/aws-kinesis'; | ||
import * as iam from 'aws-cdk-lib/aws-iam'; | ||
import * as logs_destinations from 'aws-cdk-lib/aws-logs-destinations'; | ||
import * as logs from 'aws-cdk-lib/aws-logs'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
|
||
class LogsStack extends pulumicdk.Stack { | ||
constructor(app: pulumicdk.App, id: string, options?: pulumicdk.StackOptions) { | ||
super(app, id, options); | ||
const logGroup = new logs.LogGroup(this, 'LogGroup', { | ||
retention: logs.RetentionDays.ONE_DAY, | ||
}); | ||
new logs.LogStream(this, 'LogStream', { | ||
logGroup, | ||
}); | ||
new logs.MetricFilter(this, 'MetricFilter', { | ||
logGroup, | ||
filterPattern: logs.FilterPattern.allTerms('ERROR'), | ||
metricNamespace: 'MyApp', | ||
metricName: 'ErrorCount', | ||
}); | ||
const queryString = new logs.QueryString({ | ||
fields: ['@timestamp', '@message'], | ||
sort: '@timestamp desc', | ||
limit: 20, | ||
}); | ||
new logs.QueryDefinition(this, 'QueryDefinition', { | ||
queryString, | ||
logGroups: [logGroup], | ||
queryDefinitionName: 'cdk-test-query', | ||
}); | ||
|
||
logGroup.addToResourcePolicy( | ||
new iam.PolicyStatement({ | ||
effect: iam.Effect.ALLOW, | ||
resources: ['*'], | ||
actions: ['logs:PutLogEvents'], | ||
principals: [new iam.ServicePrincipal('logs.amazonaws.com')], | ||
}), | ||
); | ||
|
||
const logGroup2 = new logs.LogGroup(this, 'LogGroup2', { | ||
retention: logs.RetentionDays.ONE_DAY, | ||
}); | ||
const stream = new kinesis.Stream(this, 'stream', { | ||
encryption: kinesis.StreamEncryption.UNENCRYPTED, | ||
}); | ||
logGroup2.addSubscriptionFilter('cdk-filter', { | ||
destination: new logs_destinations.KinesisDestination(stream), | ||
filterPattern: logs.FilterPattern.allTerms('ERROR'), | ||
}); | ||
} | ||
} | ||
|
||
new pulumicdk.App('app', (scope: pulumicdk.App) => { | ||
new LogsStack(scope, 'teststack'); | ||
}); |
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,15 @@ | ||
{ | ||
"name": "pulumi-aws-cdk", | ||
"devDependencies": { | ||
"@types/node": "^10.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "^6.0.0", | ||
"@pulumi/aws-native": "^1.5.0", | ||
"@pulumi/cdk": "^0.5.0", | ||
"@pulumi/pulumi": "^3.0.0", | ||
"aws-cdk-lib": "2.149.0", | ||
"constructs": "10.3.0", | ||
"esbuild": "^0.24.0" | ||
} | ||
} |
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,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2019", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"include": [ | ||
"./*.ts" | ||
] | ||
} |
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