aws.cloudwatch.LogIndexPolicy
Explore with Pulumi AI
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:
- Log
Group stringName - Log group name to set the policy for.
- Policy
Document string - JSON policy document. This is a JSON formatted string.
- Log
Group stringName - Log group name to set the policy for.
- Policy
Document string - JSON policy document. This is a JSON formatted string.
- log
Group StringName - Log group name to set the policy for.
- policy
Document String - JSON policy document. This is a JSON formatted string.
- log
Group stringName - Log group name to set the policy for.
- policy
Document string - JSON policy document. This is a JSON formatted string.
- log_
group_ strname - Log group name to set the policy for.
- policy_
document str - JSON policy document. This is a JSON formatted string.
- log
Group StringName - Log group name to set the policy for.
- policy
Document 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.
- Log
Group stringName - Log group name to set the policy for.
- Policy
Document string - JSON policy document. This is a JSON formatted string.
- Log
Group stringName - Log group name to set the policy for.
- Policy
Document string - JSON policy document. This is a JSON formatted string.
- log
Group StringName - Log group name to set the policy for.
- policy
Document String - JSON policy document. This is a JSON formatted string.
- log
Group stringName - Log group name to set the policy for.
- policy
Document string - JSON policy document. This is a JSON formatted string.
- log_
group_ strname - Log group name to set the policy for.
- policy_
document str - JSON policy document. This is a JSON formatted string.
- log
Group StringName - Log group name to set the policy for.
- policy
Document 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.