Skip to content

Instantly share code, notes, and snippets.

@thomaspoignant
Last active February 18, 2021 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaspoignant/1b4472778aad10af374a4499b54380b2 to your computer and use it in GitHub Desktop.
Save thomaspoignant/1b4472778aad10af374a4499b54380b2 to your computer and use it in GitHub Desktop.
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