LogIndexPolicy class

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"],
    }))
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 main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/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][]string{
			"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
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_cloudwatch_loggroup" "example" {
  name = "example"
}
resource "aws_cloudwatch_logindexpolicy" "example" {
  log_group_name = aws_cloudwatch_loggroup.example.name
  policy_document = jsonencode({
    "Fields" = ["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.ArrayList;
import java.util.Arrays;
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

Import

Identity Schema

Required

  • logGroupName (String) Name of the log group.

Optional

  • accountId (String) AWS Account where this resource is managed.
  • region (String) Region where this resource is managed.

Using pulumi import, import Index Policies using logGroupName. For example:

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

Constructors

LogIndexPolicy(String name, {LogIndexPolicyArgs? args, CustomResourceOptions? options})
Creates a new LogIndexPolicy. name The Pulumi resource name. args Arguments used to configure this LogIndexPolicy. The set of arguments for LogIndexPolicy. options Resource options controlling this resource's behavior.
LogIndexPolicy.reference(String urn)
Creates a typed reference to an existing LogIndexPolicy resource.

Properties

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
logGroupName ↔ Output<String>
Log group name to set the policy for.
latefinal
policyDocument ↔ Output<String>
JSON policy document. This is a JSON formatted string.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {LogIndexPolicyState? state, CustomResourceOptions? options}) → LogIndexPolicy
Gets an existing LogIndexPolicy resource's state with the given name and id.