Last active
February 18, 2021 09:59
-
-
Save thomaspoignant/1b4472778aad10af374a4499b54380b2 to your computer and use it in GitHub Desktop.
Use NestedStack to use the type
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
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