datadog.CloudConfigurationRule

Explore with Pulumi AI

Provides a Datadog Cloud Configuration Rule resource.

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Datadog = Pulumi.Datadog;

return await Deployment.RunAsync(() => 
{
    var myrule = new Datadog.CloudConfigurationRule("myrule", new()
    {
        Enabled = true,
        GroupBies = new[]
        {
            "@resource",
        },
        Message = "Rule has triggered",
        Name = "My cloud configuration rule",
        Notifications = new[]
        {
            "@channel",
        },
        Policy = @"        package datadog

        import data.datadog.output as dd_output

        import future.keywords.contains
        import future.keywords.if
        import future.keywords.in

        eval(resource) = ""skip"" if {
            # Logic that evaluates to true if the resource should be skipped
            true
        } else = ""pass"" {
            # Logic that evaluates to true if the resource is compliant
            true
        } else = ""fail"" {
            # Logic that evaluates to true if the resource is not compliant
            true
        }

        # This part remains unchanged for all rules
        results contains result if {
            some resource in input.resources[input.main_resource_type]
            result := dd_output.format(resource, eval(resource))
        }

",
        RelatedResourceTypes = new[] {},
        ResourceType = "aws_s3_bucket",
        Severity = "high",
        Tags = new[]
        {
            "some:tag",
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-datadog/sdk/v4/go/datadog"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := datadog.NewCloudConfigurationRule(ctx, "myrule", &datadog.CloudConfigurationRuleArgs{
			Enabled: pulumi.Bool(true),
			GroupBies: pulumi.StringArray{
				pulumi.String("@resource"),
			},
			Message: pulumi.String("Rule has triggered"),
			Name:    pulumi.String("My cloud configuration rule"),
			Notifications: pulumi.StringArray{
				pulumi.String("@channel"),
			},
			Policy:               pulumi.String("        package datadog\n\n        import data.datadog.output as dd_output\n\n        import future.keywords.contains\n        import future.keywords.if\n        import future.keywords.in\n\n        eval(resource) = \"skip\" if {\n            # Logic that evaluates to true if the resource should be skipped\n            true\n        } else = \"pass\" {\n            # Logic that evaluates to true if the resource is compliant\n            true\n        } else = \"fail\" {\n            # Logic that evaluates to true if the resource is not compliant\n            true\n        }\n\n        # This part remains unchanged for all rules\n        results contains result if {\n            some resource in input.resources[input.main_resource_type]\n            result := dd_output.format(resource, eval(resource))\n        }\n\n"),
			RelatedResourceTypes: pulumi.StringArray{},
			ResourceType:         pulumi.String("aws_s3_bucket"),
			Severity:             pulumi.String("high"),
			Tags: pulumi.StringArray{
				pulumi.String("some:tag"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.datadog.CloudConfigurationRule;
import com.pulumi.datadog.CloudConfigurationRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myrule = new CloudConfigurationRule("myrule", CloudConfigurationRuleArgs.builder()        
            .enabled(true)
            .groupBies("@resource")
            .message("Rule has triggered")
            .name("My cloud configuration rule")
            .notifications("@channel")
            .policy("""
        package datadog

        import data.datadog.output as dd_output

        import future.keywords.contains
        import future.keywords.if
        import future.keywords.in

        eval(resource) = "skip" if {
            # Logic that evaluates to true if the resource should be skipped
            true
        } else = "pass" {
            # Logic that evaluates to true if the resource is compliant
            true
        } else = "fail" {
            # Logic that evaluates to true if the resource is not compliant
            true
        }

        # This part remains unchanged for all rules
        results contains result if {
            some resource in input.resources[input.main_resource_type]
            result := dd_output.format(resource, eval(resource))
        }

            """)
            .relatedResourceTypes()
            .resourceType("aws_s3_bucket")
            .severity("high")
            .tags("some:tag")
            .build());

    }
}
import pulumi
import pulumi_datadog as datadog

myrule = datadog.CloudConfigurationRule("myrule",
    enabled=True,
    group_bies=["@resource"],
    message="Rule has triggered",
    name="My cloud configuration rule",
    notifications=["@channel"],
    policy="""        package datadog

        import data.datadog.output as dd_output

        import future.keywords.contains
        import future.keywords.if
        import future.keywords.in

        eval(resource) = "skip" if {
            # Logic that evaluates to true if the resource should be skipped
            true
        } else = "pass" {
            # Logic that evaluates to true if the resource is compliant
            true
        } else = "fail" {
            # Logic that evaluates to true if the resource is not compliant
            true
        }

        # This part remains unchanged for all rules
        results contains result if {
            some resource in input.resources[input.main_resource_type]
            result := dd_output.format(resource, eval(resource))
        }

""",
    related_resource_types=[],
    resource_type="aws_s3_bucket",
    severity="high",
    tags=["some:tag"])
import * as pulumi from "@pulumi/pulumi";
import * as datadog from "@pulumi/datadog";

const myrule = new datadog.CloudConfigurationRule("myrule", {
    enabled: true,
    groupBies: ["@resource"],
    message: "Rule has triggered",
    name: "My cloud configuration rule",
    notifications: ["@channel"],
    policy: `        package datadog

        import data.datadog.output as dd_output

        import future.keywords.contains
        import future.keywords.if
        import future.keywords.in

        eval(resource) = "skip" if {
            # Logic that evaluates to true if the resource should be skipped
            true
        } else = "pass" {
            # Logic that evaluates to true if the resource is compliant
            true
        } else = "fail" {
            # Logic that evaluates to true if the resource is not compliant
            true
        }

        # This part remains unchanged for all rules
        results contains result if {
            some resource in input.resources[input.main_resource_type]
            result := dd_output.format(resource, eval(resource))
        }

`,
    relatedResourceTypes: [],
    resourceType: "aws_s3_bucket",
    severity: "high",
    tags: ["some:tag"],
});
resources:
  myrule:
    type: datadog:CloudConfigurationRule
    properties:
      enabled: true
      groupBies:
        - '@resource'
      message: Rule has triggered
      name: My cloud configuration rule
      notifications:
        - '@channel'
      policy: |2+
                package datadog

                import data.datadog.output as dd_output

                import future.keywords.contains
                import future.keywords.if
                import future.keywords.in

                eval(resource) = "skip" if {
                    # Logic that evaluates to true if the resource should be skipped
                    true
                } else = "pass" {
                    # Logic that evaluates to true if the resource is compliant
                    true
                } else = "fail" {
                    # Logic that evaluates to true if the resource is not compliant
                    true
                }

                # This part remains unchanged for all rules
                results contains result if {
                    some resource in input.resources[input.main_resource_type]
                    result := dd_output.format(resource, eval(resource))
                }

      relatedResourceTypes: []
      resourceType: aws_s3_bucket
      severity: high
      tags:
        - some:tag

Create CloudConfigurationRule Resource

new CloudConfigurationRule(name: string, args: CloudConfigurationRuleArgs, opts?: CustomResourceOptions);
@overload
def CloudConfigurationRule(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           enabled: Optional[bool] = None,
                           group_bies: Optional[Sequence[str]] = None,
                           message: Optional[str] = None,
                           name: Optional[str] = None,
                           notifications: Optional[Sequence[str]] = None,
                           policy: Optional[str] = None,
                           related_resource_types: Optional[Sequence[str]] = None,
                           resource_type: Optional[str] = None,
                           severity: Optional[str] = None,
                           tags: Optional[Sequence[str]] = None)
@overload
def CloudConfigurationRule(resource_name: str,
                           args: CloudConfigurationRuleArgs,
                           opts: Optional[ResourceOptions] = None)
func NewCloudConfigurationRule(ctx *Context, name string, args CloudConfigurationRuleArgs, opts ...ResourceOption) (*CloudConfigurationRule, error)
public CloudConfigurationRule(string name, CloudConfigurationRuleArgs args, CustomResourceOptions? opts = null)
public CloudConfigurationRule(String name, CloudConfigurationRuleArgs args)
public CloudConfigurationRule(String name, CloudConfigurationRuleArgs args, CustomResourceOptions options)
type: datadog:CloudConfigurationRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args CloudConfigurationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args CloudConfigurationRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args CloudConfigurationRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args CloudConfigurationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args CloudConfigurationRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

CloudConfigurationRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The CloudConfigurationRule resource accepts the following input properties:

Enabled bool

Whether the cloud configuration rule is enabled.

Message string

The message associated to the rule that will be shown in findings and signals.

Name string

The name of the cloud configuration rule.

Policy string

Policy written in Rego format.

ResourceType string

Main resource type to be checked by the rule.

Severity string

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

GroupBies List<string>

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

Notifications List<string>

Notification targets for signals. Defaults to empty list.

RelatedResourceTypes List<string>

Related resource types to be checked by the rule. Defaults to empty list.

Tags List<string>

Tags of the rule, propagated to findings and signals. Defaults to empty list.

Enabled bool

Whether the cloud configuration rule is enabled.

Message string

The message associated to the rule that will be shown in findings and signals.

Name string

The name of the cloud configuration rule.

Policy string

Policy written in Rego format.

ResourceType string

Main resource type to be checked by the rule.

Severity string

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

GroupBies []string

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

Notifications []string

Notification targets for signals. Defaults to empty list.

RelatedResourceTypes []string

Related resource types to be checked by the rule. Defaults to empty list.

Tags []string

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled Boolean

Whether the cloud configuration rule is enabled.

message String

The message associated to the rule that will be shown in findings and signals.

name String

The name of the cloud configuration rule.

policy String

Policy written in Rego format.

resourceType String

Main resource type to be checked by the rule.

severity String

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

groupBies List<String>

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

notifications List<String>

Notification targets for signals. Defaults to empty list.

relatedResourceTypes List<String>

Related resource types to be checked by the rule. Defaults to empty list.

tags List<String>

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled boolean

Whether the cloud configuration rule is enabled.

message string

The message associated to the rule that will be shown in findings and signals.

name string

The name of the cloud configuration rule.

policy string

Policy written in Rego format.

resourceType string

Main resource type to be checked by the rule.

severity string

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

groupBies string[]

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

notifications string[]

Notification targets for signals. Defaults to empty list.

relatedResourceTypes string[]

Related resource types to be checked by the rule. Defaults to empty list.

tags string[]

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled bool

Whether the cloud configuration rule is enabled.

message str

The message associated to the rule that will be shown in findings and signals.

name str

The name of the cloud configuration rule.

policy str

Policy written in Rego format.

resource_type str

Main resource type to be checked by the rule.

severity str

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

group_bies Sequence[str]

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

notifications Sequence[str]

Notification targets for signals. Defaults to empty list.

related_resource_types Sequence[str]

Related resource types to be checked by the rule. Defaults to empty list.

tags Sequence[str]

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled Boolean

Whether the cloud configuration rule is enabled.

message String

The message associated to the rule that will be shown in findings and signals.

name String

The name of the cloud configuration rule.

policy String

Policy written in Rego format.

resourceType String

Main resource type to be checked by the rule.

severity String

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

groupBies List<String>

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

notifications List<String>

Notification targets for signals. Defaults to empty list.

relatedResourceTypes List<String>

Related resource types to be checked by the rule. Defaults to empty list.

tags List<String>

Tags of the rule, propagated to findings and signals. Defaults to empty list.

Outputs

All input properties are implicitly available as output properties. Additionally, the CloudConfigurationRule resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing CloudConfigurationRule Resource

Get an existing CloudConfigurationRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: CloudConfigurationRuleState, opts?: CustomResourceOptions): CloudConfigurationRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        enabled: Optional[bool] = None,
        group_bies: Optional[Sequence[str]] = None,
        message: Optional[str] = None,
        name: Optional[str] = None,
        notifications: Optional[Sequence[str]] = None,
        policy: Optional[str] = None,
        related_resource_types: Optional[Sequence[str]] = None,
        resource_type: Optional[str] = None,
        severity: Optional[str] = None,
        tags: Optional[Sequence[str]] = None) -> CloudConfigurationRule
func GetCloudConfigurationRule(ctx *Context, name string, id IDInput, state *CloudConfigurationRuleState, opts ...ResourceOption) (*CloudConfigurationRule, error)
public static CloudConfigurationRule Get(string name, Input<string> id, CloudConfigurationRuleState? state, CustomResourceOptions? opts = null)
public static CloudConfigurationRule get(String name, Output<String> id, CloudConfigurationRuleState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Enabled bool

Whether the cloud configuration rule is enabled.

GroupBies List<string>

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

Message string

The message associated to the rule that will be shown in findings and signals.

Name string

The name of the cloud configuration rule.

Notifications List<string>

Notification targets for signals. Defaults to empty list.

Policy string

Policy written in Rego format.

RelatedResourceTypes List<string>

Related resource types to be checked by the rule. Defaults to empty list.

ResourceType string

Main resource type to be checked by the rule.

Severity string

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

Tags List<string>

Tags of the rule, propagated to findings and signals. Defaults to empty list.

Enabled bool

Whether the cloud configuration rule is enabled.

GroupBies []string

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

Message string

The message associated to the rule that will be shown in findings and signals.

Name string

The name of the cloud configuration rule.

Notifications []string

Notification targets for signals. Defaults to empty list.

Policy string

Policy written in Rego format.

RelatedResourceTypes []string

Related resource types to be checked by the rule. Defaults to empty list.

ResourceType string

Main resource type to be checked by the rule.

Severity string

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

Tags []string

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled Boolean

Whether the cloud configuration rule is enabled.

groupBies List<String>

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

message String

The message associated to the rule that will be shown in findings and signals.

name String

The name of the cloud configuration rule.

notifications List<String>

Notification targets for signals. Defaults to empty list.

policy String

Policy written in Rego format.

relatedResourceTypes List<String>

Related resource types to be checked by the rule. Defaults to empty list.

resourceType String

Main resource type to be checked by the rule.

severity String

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

tags List<String>

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled boolean

Whether the cloud configuration rule is enabled.

groupBies string[]

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

message string

The message associated to the rule that will be shown in findings and signals.

name string

The name of the cloud configuration rule.

notifications string[]

Notification targets for signals. Defaults to empty list.

policy string

Policy written in Rego format.

relatedResourceTypes string[]

Related resource types to be checked by the rule. Defaults to empty list.

resourceType string

Main resource type to be checked by the rule.

severity string

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

tags string[]

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled bool

Whether the cloud configuration rule is enabled.

group_bies Sequence[str]

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

message str

The message associated to the rule that will be shown in findings and signals.

name str

The name of the cloud configuration rule.

notifications Sequence[str]

Notification targets for signals. Defaults to empty list.

policy str

Policy written in Rego format.

related_resource_types Sequence[str]

Related resource types to be checked by the rule. Defaults to empty list.

resource_type str

Main resource type to be checked by the rule.

severity str

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

tags Sequence[str]

Tags of the rule, propagated to findings and signals. Defaults to empty list.

enabled Boolean

Whether the cloud configuration rule is enabled.

groupBies List<String>

Fields to group by when generating signals, e.g. @resource. Defaults to empty list.

message String

The message associated to the rule that will be shown in findings and signals.

name String

The name of the cloud configuration rule.

notifications List<String>

Notification targets for signals. Defaults to empty list.

policy String

Policy written in Rego format.

relatedResourceTypes List<String>

Related resource types to be checked by the rule. Defaults to empty list.

resourceType String

Main resource type to be checked by the rule.

severity String

Severity of the rule and associated signals. Valid values are info, low, medium, high, critical.

tags List<String>

Tags of the rule, propagated to findings and signals. Defaults to empty list.

Import

Security monitoring rules can be imported using ID, e.g.

 $ pulumi import datadog:index/cloudConfigurationRule:CloudConfigurationRule my_rule m0o-hto-lkb

Package Details

Repository
Datadog pulumi/pulumi-datadog
License
Apache-2.0
Notes

This Pulumi package is based on the datadog Terraform Provider.