1. Packages
  2. AWS
  3. API Docs
  4. cloudwatch
  5. LogIndexPolicy
AWS v6.72.0 published on Tuesday, Mar 11, 2025 by Pulumi

aws.cloudwatch.LogIndexPolicy

Explore with Pulumi AI

aws logo
AWS v6.72.0 published on Tuesday, Mar 11, 2025 by Pulumi

    Resource for managing an AWS CloudWatch Logs Index Policy.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.cloudwatch.LogGroup("example", {name: "example"});
    const exampleLogIndexPolicy = new aws.cloudwatch.LogIndexPolicy("example", {
        logGroupName: example.name,
        policyDocument: JSON.stringify({
            Fields: ["eventName"],
        }),
    });
    
    import pulumi
    import json
    import pulumi_aws as aws
    
    example = aws.cloudwatch.LogGroup("example", name="example")
    example_log_index_policy = aws.cloudwatch.LogIndexPolicy("example",
        log_group_name=example.name,
        policy_document=json.dumps({
            "Fields": ["eventName"],
        }))
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    	"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
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Fields": []string{
    				"eventName",
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = cloudwatch.NewLogIndexPolicy(ctx, "example", &cloudwatch.LogIndexPolicyArgs{
    			LogGroupName:   example.Name,
    			PolicyDocument: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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 exampleLogIndexPolicy = new Aws.CloudWatch.LogIndexPolicy("example", new()
        {
            LogGroupName = example.Name,
            PolicyDocument = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Fields"] = new[]
                {
                    "eventName",
                },
            }),
        });
    
    });
    
    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.cloudwatch.LogIndexPolicy;
    import com.pulumi.aws.cloudwatch.LogIndexPolicyArgs;
    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 exampleLogIndexPolicy = new LogIndexPolicy("exampleLogIndexPolicy", LogIndexPolicyArgs.builder()
                .logGroupName(example.name())
                .policyDocument(serializeJson(
                    jsonObject(
                        jsonProperty("Fields", jsonArray("eventName"))
                    )))
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:cloudwatch:LogGroup
        properties:
          name: example
      exampleLogIndexPolicy:
        type: aws:cloudwatch:LogIndexPolicy
        name: example
        properties:
          logGroupName: ${example.name}
          policyDocument:
            fn::toJSON:
              Fields:
                - eventName
    

    Create LogIndexPolicy Resource

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

    Constructor syntax

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

    Parameters

    name string
    The unique name of the resource.
    args LogIndexPolicyArgs
    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 LogIndexPolicyArgs
    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 LogIndexPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args LogIndexPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args LogIndexPolicyArgs
    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 logIndexPolicyResource = new Aws.CloudWatch.LogIndexPolicy("logIndexPolicyResource", new()
    {
        LogGroupName = "string",
        PolicyDocument = "string",
    });
    
    example, err := cloudwatch.NewLogIndexPolicy(ctx, "logIndexPolicyResource", &cloudwatch.LogIndexPolicyArgs{
    	LogGroupName:   pulumi.String("string"),
    	PolicyDocument: pulumi.String("string"),
    })
    
    var logIndexPolicyResource = new LogIndexPolicy("logIndexPolicyResource", LogIndexPolicyArgs.builder()
        .logGroupName("string")
        .policyDocument("string")
        .build());
    
    log_index_policy_resource = aws.cloudwatch.LogIndexPolicy("logIndexPolicyResource",
        log_group_name="string",
        policy_document="string")
    
    const logIndexPolicyResource = new aws.cloudwatch.LogIndexPolicy("logIndexPolicyResource", {
        logGroupName: "string",
        policyDocument: "string",
    });
    
    type: aws:cloudwatch:LogIndexPolicy
    properties:
        logGroupName: string
        policyDocument: string
    

    LogIndexPolicy 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 LogIndexPolicy resource accepts the following input properties:

    LogGroupName string
    Log group name to set the policy for.
    PolicyDocument string
    JSON policy document. This is a JSON formatted string.
    LogGroupName string
    Log group name to set the policy for.
    PolicyDocument string
    JSON policy document. This is a JSON formatted string.
    logGroupName String
    Log group name to set the policy for.
    policyDocument String
    JSON policy document. This is a JSON formatted string.
    logGroupName string
    Log group name to set the policy for.
    policyDocument string
    JSON policy document. This is a JSON formatted string.
    log_group_name str
    Log group name to set the policy for.
    policy_document str
    JSON policy document. This is a JSON formatted string.
    logGroupName String
    Log group name to set the policy for.
    policyDocument String
    JSON policy document. This is a JSON formatted string.

    Outputs

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

    Get an existing LogIndexPolicy 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?: LogIndexPolicyState, opts?: CustomResourceOptions): LogIndexPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            log_group_name: Optional[str] = None,
            policy_document: Optional[str] = None) -> LogIndexPolicy
    func GetLogIndexPolicy(ctx *Context, name string, id IDInput, state *LogIndexPolicyState, opts ...ResourceOption) (*LogIndexPolicy, error)
    public static LogIndexPolicy Get(string name, Input<string> id, LogIndexPolicyState? state, CustomResourceOptions? opts = null)
    public static LogIndexPolicy get(String name, Output<String> id, LogIndexPolicyState state, CustomResourceOptions options)
    resources:  _:    type: aws:cloudwatch:LogIndexPolicy    get:      id: ${id}
    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
    Log group name to set the policy for.
    PolicyDocument string
    JSON policy document. This is a JSON formatted string.
    LogGroupName string
    Log group name to set the policy for.
    PolicyDocument string
    JSON policy document. This is a JSON formatted string.
    logGroupName String
    Log group name to set the policy for.
    policyDocument String
    JSON policy document. This is a JSON formatted string.
    logGroupName string
    Log group name to set the policy for.
    policyDocument string
    JSON policy document. This is a JSON formatted string.
    log_group_name str
    Log group name to set the policy for.
    policy_document str
    JSON policy document. This is a JSON formatted string.
    logGroupName String
    Log group name to set the policy for.
    policyDocument String
    JSON policy document. This is a JSON formatted string.

    Import

    Using pulumi import, import CloudWatch Logs Index Policy using the log_group_name. For example:

    $ pulumi import aws:cloudwatch/logIndexPolicy:LogIndexPolicy example /aws/log/group/name
    

    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.
    aws logo
    AWS v6.72.0 published on Tuesday, Mar 11, 2025 by Pulumi