1. Packages
  2. AWS Classic
  3. API Docs
  4. cloudwatch
  5. LogDataProtectionPolicy

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

aws.cloudwatch.LogDataProtectionPolicy

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

    Provides a CloudWatch Log Data Protection Policy resource.

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

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleLogGroup = new Aws.CloudWatch.LogGroup("exampleLogGroup");
    
        var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2");
    
        var exampleLogDataProtectionPolicy = new Aws.CloudWatch.LogDataProtectionPolicy("exampleLogDataProtectionPolicy", new()
        {
            LogGroupName = exampleLogGroup.Name,
            PolicyDocument = exampleBucketV2.Bucket.Apply(bucket => JsonSerializer.Serialize(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"] = 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?>
                                {
                                },
                            },
                        },
                    },
                },
            })),
        });
    
    });
    
    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 {
    		exampleLogGroup, err := cloudwatch.NewLogGroup(ctx, "exampleLogGroup", nil)
    		if err != nil {
    			return err
    		}
    		exampleBucketV2, err := s3.NewBucketV2(ctx, "exampleBucketV2", nil)
    		if err != nil {
    			return err
    		}
    		_, err = cloudwatch.NewLogDataProtectionPolicy(ctx, "exampleLogDataProtectionPolicy", &cloudwatch.LogDataProtectionPolicyArgs{
    			LogGroupName: exampleLogGroup.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": nil,
    								},
    							},
    						},
    					},
    				})
    				if err != nil {
    					return _zero, err
    				}
    				json0 := string(tmpJSON0)
    				return pulumi.String(json0), nil
    			}).(pulumi.StringOutput),
    		})
    		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.aws.cloudwatch.LogGroup;
    import com.pulumi.aws.s3.BucketV2;
    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 exampleLogGroup = new LogGroup("exampleLogGroup");
    
            var exampleBucketV2 = new BucketV2("exampleBucketV2");
    
            var exampleLogDataProtectionPolicy = new LogDataProtectionPolicy("exampleLogDataProtectionPolicy", LogDataProtectionPolicyArgs.builder()        
                .logGroupName(exampleLogGroup.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());
    
        }
    }
    
    import pulumi
    import json
    import pulumi_aws as aws
    
    example_log_group = aws.cloudwatch.LogGroup("exampleLogGroup")
    example_bucket_v2 = aws.s3.BucketV2("exampleBucketV2")
    example_log_data_protection_policy = aws.cloudwatch.LogDataProtectionPolicy("exampleLogDataProtectionPolicy",
        log_group_name=example_log_group.name,
        policy_document=example_bucket_v2.bucket.apply(lambda bucket: json.dumps({
            "Name": "Example",
            "Version": "2021-06-01",
            "Statement": [
                {
                    "Sid": "Audit",
                    "DataIdentifier": ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                    "Operation": {
                        "Audit": {
                            "FindingsDestination": {
                                "S3": {
                                    "Bucket": bucket,
                                },
                            },
                        },
                    },
                },
                {
                    "Sid": "Redact",
                    "DataIdentifier": ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                    "Operation": {
                        "Deidentify": {
                            "MaskConfig": {},
                        },
                    },
                },
            ],
        })))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const exampleLogGroup = new aws.cloudwatch.LogGroup("exampleLogGroup", {});
    const exampleBucketV2 = new aws.s3.BucketV2("exampleBucketV2", {});
    const exampleLogDataProtectionPolicy = new aws.cloudwatch.LogDataProtectionPolicy("exampleLogDataProtectionPolicy", {
        logGroupName: exampleLogGroup.name,
        policyDocument: exampleBucketV2.bucket.apply(bucket => JSON.stringify({
            Name: "Example",
            Version: "2021-06-01",
            Statement: [
                {
                    Sid: "Audit",
                    DataIdentifier: ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                    Operation: {
                        Audit: {
                            FindingsDestination: {
                                S3: {
                                    Bucket: bucket,
                                },
                            },
                        },
                    },
                },
                {
                    Sid: "Redact",
                    DataIdentifier: ["arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
                    Operation: {
                        Deidentify: {
                            MaskConfig: {},
                        },
                    },
                },
            ],
        })),
    });
    
    resources:
      exampleLogGroup:
        type: aws:cloudwatch:LogGroup
      exampleBucketV2:
        type: aws:s3:BucketV2
      exampleLogDataProtectionPolicy:
        type: aws:cloudwatch:LogDataProtectionPolicy
        properties:
          logGroupName: ${exampleLogGroup.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: {}
    

    Create LogDataProtectionPolicy Resource

    new LogDataProtectionPolicy(name: string, args: LogDataProtectionPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def LogDataProtectionPolicy(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                log_group_name: Optional[str] = None,
                                policy_document: Optional[str] = None)
    @overload
    def LogDataProtectionPolicy(resource_name: str,
                                args: LogDataProtectionPolicyArgs,
                                opts: Optional[ResourceOptions] = 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.
    
    
    name string
    The unique name of the resource.
    args LogDataProtectionPolicyArgs
    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 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 string
    The unique name of the resource.
    args LogDataProtectionPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args LogDataProtectionPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args LogDataProtectionPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    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

    The LogDataProtectionPolicy resource accepts the following input properties:

    LogGroupName 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 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 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 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 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 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.

    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)
    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:
    LogGroupName 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 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 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 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 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 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
    

    Package Details

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

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi