Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use NestedStack to use the type
import * as cdk from '@aws-cdk/core';
import {CfnResource} from "@aws-cdk/core";
export class CdkCustomResourcesStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const monitorType = new CfnResource(this, 'datadog_monitor_id',{
type: 'AWS::CloudFormation::ResourceVersion',
properties:{
'TypeName': 'Datadog::Monitors::Monitor',
'SchemaHandlerPackage':
's3://datadog-cloudformation-resources/datadog-monitors-monitor/datadog' +
'-monitors-monitor-2.1.0.zip'
}
})
const monitors = new DatadogMonitor(this, "test_monitor" )
monitors.node.addDependency(monitorType)
}
}
export class DatadogMonitor extends cdk.NestedStack {
constructor(scope: cdk.Construct, id: string, props?: cdk.NestedStackProps) {
super(scope, id, props);
new CfnResource(this, "test_id", {
type: 'Datadog::Monitors::Monitor',
properties:{
'Type': 'query alert',
'Query': '<YOUR QUERY>',
'Name': 'Test monitor',
'DatadogCredentials': {
'ApplicationKey': '<YOUR APPLICATION KEY>',
'ApiKey': '<YOUR API KEY>',
'ApiURL': 'https://api.datadoghq.com'
}
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment