Skip to content

Commit

Permalink
feat: CDKv2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestelfer committed Jan 23, 2024
1 parent f0ec475 commit de9115c
Show file tree
Hide file tree
Showing 10 changed files with 600 additions and 281 deletions.
3 changes: 2 additions & 1 deletion __integration__/integ.slo.metric.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as cdk from "@aws-cdk/core"
import * as cdk from "aws-cdk-lib"

import { CfnSlo, CfnSloPropsType, ThresholdTimeframe } from "../src"

const app = new cdk.App()
Expand Down
68 changes: 68 additions & 0 deletions __tests__/__snapshots__/slo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

exports[`Given an SLO construct When I supply default values Then the template synthesises correctly 1`] = `
{
"Parameters": {
"BootstrapVersion": {
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]",
"Type": "AWS::SSM::Parameter::Value<String>",
},
},
"Resources": {
"TestSlo": {
"Properties": {
Expand All @@ -18,11 +25,45 @@ exports[`Given an SLO construct When I supply default values Then the template s
"Type": "Datadog::SLOs::SLO",
},
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5",
],
{
"Ref": "BootstrapVersion",
},
],
},
],
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.",
},
],
},
},
}
`;

exports[`Given an SLO construct When I supply optional values Then the template synthesises correctly 1`] = `
{
"Parameters": {
"BootstrapVersion": {
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]",
"Type": "AWS::SSM::Parameter::Value<String>",
},
},
"Resources": {
"TestSlo": {
"Properties": {
Expand Down Expand Up @@ -54,5 +95,32 @@ exports[`Given an SLO construct When I supply optional values Then the template
"Type": "Datadog::SLOs::SLO",
},
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5",
],
{
"Ref": "BootstrapVersion",
},
],
},
],
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.",
},
],
},
},
}
`;
4 changes: 2 additions & 2 deletions __tests__/slo.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as cdk from "@aws-cdk/core"
import { Template } from "@aws-cdk/assertions"
import * as cdk from "aws-cdk-lib"
import { CfnSlo, CfnSloPropsType, ThresholdTimeframe } from "../src"
import { Template } from "aws-cdk-lib/assertions"

const testStack = () => {
const app = new cdk.App()
Expand Down
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,31 @@
"author": "Culture Amp SRE",
"license": "MIT",
"devDependencies": {
"@aws-cdk/assertions": "1.x",
"@aws-cdk/core": "1.x && < 2.x",
"@aws-cdk/integ-runner": "1.x",
"@aws-cdk/integ-runner": "2.122.0-alpha.0",
"@tsconfig/node16": "^1.0.4",
"@types/jest": "^29.5.1",
"@types/node": "16.x",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"aws-cdk": "1.x && < 2.x",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"aws-cdk": "2.112.0",
"aws-cdk-lib": "2.112.0",
"constructs": "^10.0.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^34.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-sort-imports-es6-autofix": "0.6.0",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
},
"peerDependencies": {
"@aws-cdk/core": "1.x && < 2.x"
"aws-cdk-lib": "^2.99.0",
"constructs": "^10.0.0"
}
}
Loading

0 comments on commit de9115c

Please sign in to comment.