1. Packages
  2. AWS
  3. API Docs
  4. cloudwatch
  5. LogDataProtectionPolicy
AWS v6.78.0 published on Thursday, Apr 24, 2025 by Pulumi

aws.cloudwatch.LogDataProtectionPolicy

Explore with Pulumi AI

Provides a CloudWatch Log Data Protection Policy resource.

Read more about protecting sensitive user data in the User Guide.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.cloudwatch.LogGroup("example", {name: "example"});
const exampleBucketV2 = new aws.s3.BucketV2("example", {bucket: "example"});
const exampleLogDataProtectionPolicy = new aws.cloudwatch.LogDataProtectionPolicy("example", {
    logGroupName: example.name,
    policyDocument: pulumi.jsonStringify({
        Name: "Example",
        Version: "2021-06-01",
        Statement: [
            {
                Sid: "Audit",
                DataIdentifier: ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                Operation: {
                    Audit: {
                        FindingsDestination: {
                            S3: {
                                Bucket: exampleBucketV2.bucket,
                            },
                        },
                    },
                },
            },
            {
                Sid: "Redact",
                DataIdentifier: ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                Operation: {
                    Deidentify: {
                        MaskConfig: {},
                    },
                },
            },
        ],
    }),
});
Copy
import pulumi
import json
import pulumi_aws as aws

example = aws.cloudwatch.LogGroup("example", name="example")
example_bucket_v2 = aws.s3.BucketV2("example", bucket="example")
example_log_data_protection_policy = aws.cloudwatch.LogDataProtectionPolicy("example",
    log_group_name=example.name,
    policy_document=pulumi.Output.json_dumps({
        "Name": "Example",
        "Version": "2021-06-01",
        "Statement": [
            {
                "Sid": "Audit",
                "DataIdentifier": ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                "Operation": {
                    "Audit": {
                        "FindingsDestination": {
                            "S3": {
                                "Bucket": example_bucket_v2.bucket,
                            },
                        },
                    },
                },
            },
            {
                "Sid": "Redact",
                "DataIdentifier": ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                "Operation": {
                    "Deidentify": {
                        "MaskConfig": {},
                    },
                },
            },
        ],
    }))
Copy
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := cloudwatch.NewLogGroup(ctx, "example", &cloudwatch.LogGroupArgs{
			Name: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		exampleBucketV2, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
			Bucket: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		_, err = cloudwatch.NewLogDataProtectionPolicy(ctx, "example", &cloudwatch.LogDataProtectionPolicyArgs{
			LogGroupName: example.Name,
			PolicyDocument: exampleBucketV2.Bucket.ApplyT(func(bucket string) (pulumi.String, error) {
				var _zero pulumi.String
				tmpJSON0, err := json.Marshal(map[string]interface{}{
					"Name":    "Example",
					"Version": "2021-06-01",
					"Statement": []interface{}{
						map[string]interface{}{
							"Sid": "Audit",
							"DataIdentifier": []string{
								"arn:aws:dataprotection::aws:data-identifier/EmailAddress",
							},
							"Operation": map[string]interface{}{
								"Audit": map[string]interface{}{
									"FindingsDestination": map[string]interface{}{
										"S3": map[string]interface{}{
											"Bucket": bucket,
										},
									},
								},
							},
						},
						map[string]interface{}{
							"Sid": "Redact",
							"DataIdentifier": []string{
								"arn:aws:dataprotection::aws:data-identifier/EmailAddress",
							},
							"Operation": map[string]interface{}{
								"Deidentify": map[string]interface{}{
									"MaskConfig": map[string]interface{}{},
								},
							},
						},
					},
				})
				if err != nil {
					return _zero, err
				}
				json0 := string(tmpJSON0)
				return pulumi.String(json0), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.CloudWatch.LogGroup("example", new()
    {
        Name = "example",
    });

    var exampleBucketV2 = new Aws.S3.BucketV2("example", new()
    {
        Bucket = "example",
    });

    var exampleLogDataProtectionPolicy = new Aws.CloudWatch.LogDataProtectionPolicy("example", new()
    {
        LogGroupName = example.Name,
        PolicyDocument = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
        {
            ["Name"] = "Example",
            ["Version"] = "2021-06-01",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Sid"] = "Audit",
                    ["DataIdentifier"] = new[]
                    {
                        "arn:aws:dataprotection::aws:data-identifier/EmailAddress",
                    },
                    ["Operation"] = new Dictionary<string, object?>
                    {
                        ["Audit"] = new Dictionary<string, object?>
                        {
                            ["FindingsDestination"] = new Dictionary<string, object?>
                            {
                                ["S3"] = new Dictionary<string, object?>
                                {
                                    ["Bucket"] = exampleBucketV2.Bucket,
                                },
                            },
                        },
                    },
                },
                new Dictionary<string, object?>
                {
                    ["Sid"] = "Redact",
                    ["DataIdentifier"] = new[]
                    {
                        "arn:aws:dataprotection::aws:data-identifier/EmailAddress",
                    },
                    ["Operation"] = new Dictionary<string, object?>
                    {
                        ["Deidentify"] = new Dictionary<string, object?>
                        {
                            ["MaskConfig"] = new Dictionary<string, object?>
                            {
                            },
                        },
                    },
                },
            },
        })),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.LogGroup;
import com.pulumi.aws.cloudwatch.LogGroupArgs;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.cloudwatch.LogDataProtectionPolicy;
import com.pulumi.aws.cloudwatch.LogDataProtectionPolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 example = new LogGroup("example", LogGroupArgs.builder()
            .name("example")
            .build());

        var exampleBucketV2 = new BucketV2("exampleBucketV2", BucketV2Args.builder()
            .bucket("example")
            .build());

        var exampleLogDataProtectionPolicy = new LogDataProtectionPolicy("exampleLogDataProtectionPolicy", LogDataProtectionPolicyArgs.builder()
            .logGroupName(example.name())
            .policyDocument(exampleBucketV2.bucket().applyValue(_bucket -> serializeJson(
                jsonObject(
                    jsonProperty("Name", "Example"),
                    jsonProperty("Version", "2021-06-01"),
                    jsonProperty("Statement", jsonArray(
                        jsonObject(
                            jsonProperty("Sid", "Audit"),
                            jsonProperty("DataIdentifier", jsonArray("arn:aws:dataprotection::aws:data-identifier/EmailAddress")),
                            jsonProperty("Operation", jsonObject(
                                jsonProperty("Audit", jsonObject(
                                    jsonProperty("FindingsDestination", jsonObject(
                                        jsonProperty("S3", jsonObject(
                                            jsonProperty("Bucket", _bucket)
                                        ))
                                    ))
                                ))
                            ))
                        ), 
                        jsonObject(
                            jsonProperty("Sid", "Redact"),
                            jsonProperty("DataIdentifier", jsonArray("arn:aws:dataprotection::aws:data-identifier/EmailAddress")),
                            jsonProperty("Operation", jsonObject(
                                jsonProperty("Deidentify", jsonObject(
                                    jsonProperty("MaskConfig", jsonObject(

                                    ))
                                ))
                            ))
                        )
                    ))
                ))))
            .build());

    }
}
Copy
resources:
  example:
    type: aws:cloudwatch:LogGroup
    properties:
      name: example
  exampleBucketV2:
    type: aws:s3:BucketV2
    name: example
    properties:
      bucket: example
  exampleLogDataProtectionPolicy:
    type: aws:cloudwatch:LogDataProtectionPolicy
    name: example
    properties:
      logGroupName: ${example.name}
      policyDocument:
        fn::toJSON:
          Name: Example
          Version: 2021-06-01
          Statement:
            - Sid: Audit
              DataIdentifier:
                - arn:aws:dataprotection::aws:data-identifier/EmailAddress
              Operation:
                Audit:
                  FindingsDestination:
                    S3:
                      Bucket: ${exampleBucketV2.bucket}
            - Sid: Redact
              DataIdentifier:
                - arn:aws:dataprotection::aws:data-identifier/EmailAddress
              Operation:
                Deidentify:
                  MaskConfig: {}
Copy

Create LogDataProtectionPolicy Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new LogDataProtectionPolicy(name: string, args: LogDataProtectionPolicyArgs, opts?: CustomResourceOptions);
@overload
def LogDataProtectionPolicy(resource_name: str,
                            args: LogDataProtectionPolicyArgs,
                            opts: Optional[ResourceOptions] = None)

@overload
def LogDataProtectionPolicy(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            log_group_name: Optional[str] = None,
                            policy_document: Optional[str] = None)
func NewLogDataProtectionPolicy(ctx *Context, name string, args LogDataProtectionPolicyArgs, opts ...ResourceOption) (*LogDataProtectionPolicy, error)
public LogDataProtectionPolicy(string name, LogDataProtectionPolicyArgs args, CustomResourceOptions? opts = null)
public LogDataProtectionPolicy(String name, LogDataProtectionPolicyArgs args)
public LogDataProtectionPolicy(String name, LogDataProtectionPolicyArgs args, CustomResourceOptions options)
type: aws:cloudwatch:LogDataProtectionPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

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

Constructor example

The following reference example uses placeholder values for all input properties.

var logDataProtectionPolicyResource = new Aws.CloudWatch.LogDataProtectionPolicy("logDataProtectionPolicyResource", new()
{
    LogGroupName = "string",
    PolicyDocument = "string",
});
Copy
example, err := cloudwatch.NewLogDataProtectionPolicy(ctx, "logDataProtectionPolicyResource", &cloudwatch.LogDataProtectionPolicyArgs{
	LogGroupName:   pulumi.String("string"),
	PolicyDocument: pulumi.String("string"),
})
Copy
var logDataProtectionPolicyResource = new LogDataProtectionPolicy("logDataProtectionPolicyResource", LogDataProtectionPolicyArgs.builder()
    .logGroupName("string")
    .policyDocument("string")
    .build());
Copy
log_data_protection_policy_resource = aws.cloudwatch.LogDataProtectionPolicy("logDataProtectionPolicyResource",
    log_group_name="string",
    policy_document="string")
Copy
const logDataProtectionPolicyResource = new aws.cloudwatch.LogDataProtectionPolicy("logDataProtectionPolicyResource", {
    logGroupName: "string",
    policyDocument: "string",
});
Copy
type: aws:cloudwatch:LogDataProtectionPolicy
properties:
    logGroupName: string
    policyDocument: string
Copy

LogDataProtectionPolicy Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The LogDataProtectionPolicy resource accepts the following input properties:

LogGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the log group under which the log stream is to be created.
PolicyDocument This property is required. string
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
LogGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the log group under which the log stream is to be created.
PolicyDocument This property is required. string
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
logGroupName
This property is required.
Changes to this property will trigger replacement.
String
The name of the log group under which the log stream is to be created.
policyDocument This property is required. String
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
logGroupName
This property is required.
Changes to this property will trigger replacement.
string
The name of the log group under which the log stream is to be created.
policyDocument This property is required. string
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
log_group_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the log group under which the log stream is to be created.
policy_document This property is required. str
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
logGroupName
This property is required.
Changes to this property will trigger replacement.
String
The name of the log group under which the log stream is to be created.
policyDocument This property is required. String
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.

Outputs

All input properties are implicitly available as output properties. Additionally, the LogDataProtectionPolicy 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 LogDataProtectionPolicy Resource

Get an existing LogDataProtectionPolicy 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?: LogDataProtectionPolicyState, opts?: CustomResourceOptions): LogDataProtectionPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        log_group_name: Optional[str] = None,
        policy_document: Optional[str] = None) -> LogDataProtectionPolicy
func GetLogDataProtectionPolicy(ctx *Context, name string, id IDInput, state *LogDataProtectionPolicyState, opts ...ResourceOption) (*LogDataProtectionPolicy, error)
public static LogDataProtectionPolicy Get(string name, Input<string> id, LogDataProtectionPolicyState? state, CustomResourceOptions? opts = null)
public static LogDataProtectionPolicy get(String name, Output<String> id, LogDataProtectionPolicyState state, CustomResourceOptions options)
resources:  _:    type: aws:cloudwatch:LogDataProtectionPolicy    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
LogGroupName Changes to this property will trigger replacement. string
The name of the log group under which the log stream is to be created.
PolicyDocument string
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
LogGroupName Changes to this property will trigger replacement. string
The name of the log group under which the log stream is to be created.
PolicyDocument string
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
logGroupName Changes to this property will trigger replacement. String
The name of the log group under which the log stream is to be created.
policyDocument String
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
logGroupName Changes to this property will trigger replacement. string
The name of the log group under which the log stream is to be created.
policyDocument string
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
log_group_name Changes to this property will trigger replacement. str
The name of the log group under which the log stream is to be created.
policy_document str
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.
logGroupName Changes to this property will trigger replacement. String
The name of the log group under which the log stream is to be created.
policyDocument String
Specifies the data protection policy in JSON. Read more at Data protection policy syntax.

Import

Using pulumi import, import this resource using the log_group_name. For example:

$ pulumi import aws:cloudwatch/logDataProtectionPolicy:LogDataProtectionPolicy example my-log-group
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.