LogResourcePolicy

Provides a resource to manage a CloudWatch log resource policy.

Example Usage

Elasticsearch Log Publishing

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var elasticsearch_log_publishing_policyPolicyDocument = Output.Create(Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
        {
            Statements = 
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
                {
                    Actions = 
                    {
                        "logs:CreateLogStream",
                        "logs:PutLogEvents",
                        "logs:PutLogEventsBatch",
                    },
                    Principals = 
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
                        {
                            Identifiers = 
                            {
                                "es.amazonaws.com",
                            },
                            Type = "Service",
                        },
                    },
                    Resources = 
                    {
                        "arn:aws:logs:*",
                    },
                },
            },
        }));
        var elasticsearch_log_publishing_policyLogResourcePolicy = new Aws.CloudWatch.LogResourcePolicy("elasticsearch-log-publishing-policyLogResourcePolicy", new Aws.CloudWatch.LogResourcePolicyArgs
        {
            PolicyDocument = elasticsearch_log_publishing_policyPolicyDocument.Apply(elasticsearch_log_publishing_policyPolicyDocument => elasticsearch_log_publishing_policyPolicyDocument.Json),
            PolicyName = "elasticsearch-log-publishing-policy",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cloudwatch"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/iam"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        elasticsearch_log_publishing_policyPolicyDocument, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
            Statements: []iam.GetPolicyDocumentStatement{
                iam.GetPolicyDocumentStatement{
                    Actions: []string{
                        "logs:CreateLogStream",
                        "logs:PutLogEvents",
                        "logs:PutLogEventsBatch",
                    },
                    Principals: []iam.GetPolicyDocumentStatementPrincipal{
                        iam.GetPolicyDocumentStatementPrincipal{
                            Identifiers: []string{
                                "es.amazonaws.com",
                            },
                            Type: "Service",
                        },
                    },
                    Resources: []string{
                        "arn:aws:logs:*",
                    },
                },
            },
        }, nil)
        if err != nil {
            return err
        }
        _, err = cloudwatch.NewLogResourcePolicy(ctx, "elasticsearch_log_publishing_policyLogResourcePolicy", &cloudwatch.LogResourcePolicyArgs{
            PolicyDocument: pulumi.String(elasticsearch_log_publishing_policyPolicyDocument.Json),
            PolicyName:     pulumi.String("elasticsearch-log-publishing-policy"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

elasticsearch_log_publishing_policy_policy_document = aws.iam.get_policy_document(statements=[{
    "actions": [
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:PutLogEventsBatch",
    ],
    "principals": [{
        "identifiers": ["es.amazonaws.com"],
        "type": "Service",
    }],
    "resources": ["arn:aws:logs:*"],
}])
elasticsearch_log_publishing_policy_log_resource_policy = aws.cloudwatch.LogResourcePolicy("elasticsearch-log-publishing-policyLogResourcePolicy",
    policy_document=elasticsearch_log_publishing_policy_policy_document.json,
    policy_name="elasticsearch-log-publishing-policy")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const elasticsearch_log_publishing_policyPolicyDocument = pulumi.output(aws.iam.getPolicyDocument({
    statements: [{
        actions: [
            "logs:CreateLogStream",
            "logs:PutLogEvents",
            "logs:PutLogEventsBatch",
        ],
        principals: [{
            identifiers: ["es.amazonaws.com"],
            type: "Service",
        }],
        resources: ["arn:aws:logs:*"],
    }],
}, { async: true }));
const elasticsearch_log_publishing_policyLogResourcePolicy = new aws.cloudwatch.LogResourcePolicy("elasticsearch-log-publishing-policy", {
    policyDocument: elasticsearch_log_publishing_policyPolicyDocument.json,
    policyName: "elasticsearch-log-publishing-policy",
});

Route53 Query Logging

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var route53_query_logging_policyPolicyDocument = Output.Create(Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
        {
            Statements = 
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
                {
                    Actions = 
                    {
                        "logs:CreateLogStream",
                        "logs:PutLogEvents",
                    },
                    Principals = 
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
                        {
                            Identifiers = 
                            {
                                "route53.amazonaws.com",
                            },
                            Type = "Service",
                        },
                    },
                    Resources = 
                    {
                        "arn:aws:logs:*:*:log-group:/aws/route53/*",
                    },
                },
            },
        }));
        var route53_query_logging_policyLogResourcePolicy = new Aws.CloudWatch.LogResourcePolicy("route53-query-logging-policyLogResourcePolicy", new Aws.CloudWatch.LogResourcePolicyArgs
        {
            PolicyDocument = route53_query_logging_policyPolicyDocument.Apply(route53_query_logging_policyPolicyDocument => route53_query_logging_policyPolicyDocument.Json),
            PolicyName = "route53-query-logging-policy",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cloudwatch"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/iam"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        route53_query_logging_policyPolicyDocument, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
            Statements: []iam.GetPolicyDocumentStatement{
                iam.GetPolicyDocumentStatement{
                    Actions: []string{
                        "logs:CreateLogStream",
                        "logs:PutLogEvents",
                    },
                    Principals: []iam.GetPolicyDocumentStatementPrincipal{
                        iam.GetPolicyDocumentStatementPrincipal{
                            Identifiers: []string{
                                "route53.amazonaws.com",
                            },
                            Type: "Service",
                        },
                    },
                    Resources: []string{
                        "arn:aws:logs:*:*:log-group:/aws/route53/*",
                    },
                },
            },
        }, nil)
        if err != nil {
            return err
        }
        _, err = cloudwatch.NewLogResourcePolicy(ctx, "route53_query_logging_policyLogResourcePolicy", &cloudwatch.LogResourcePolicyArgs{
            PolicyDocument: pulumi.String(route53_query_logging_policyPolicyDocument.Json),
            PolicyName:     pulumi.String("route53-query-logging-policy"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

route53_query_logging_policy_policy_document = aws.iam.get_policy_document(statements=[{
    "actions": [
        "logs:CreateLogStream",
        "logs:PutLogEvents",
    ],
    "principals": [{
        "identifiers": ["route53.amazonaws.com"],
        "type": "Service",
    }],
    "resources": ["arn:aws:logs:*:*:log-group:/aws/route53/*"],
}])
route53_query_logging_policy_log_resource_policy = aws.cloudwatch.LogResourcePolicy("route53-query-logging-policyLogResourcePolicy",
    policy_document=route53_query_logging_policy_policy_document.json,
    policy_name="route53-query-logging-policy")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const route53_query_logging_policyPolicyDocument = pulumi.output(aws.iam.getPolicyDocument({
    statements: [{
        actions: [
            "logs:CreateLogStream",
            "logs:PutLogEvents",
        ],
        principals: [{
            identifiers: ["route53.amazonaws.com"],
            type: "Service",
        }],
        resources: ["arn:aws:logs:*:*:log-group:/aws/route53/*"],
    }],
}, { async: true }));
const route53_query_logging_policyLogResourcePolicy = new aws.cloudwatch.LogResourcePolicy("route53-query-logging-policy", {
    policyDocument: route53_query_logging_policyPolicyDocument.json,
    policyName: "route53-query-logging-policy",
});

Create a LogResourcePolicy Resource

def LogResourcePolicy(resource_name, opts=None, policy_document=None, policy_name=None, __props__=None);
name string
The unique name of the resource.
args LogResourcePolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args LogResourcePolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args LogResourcePolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

LogResourcePolicy Resource Properties

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

Inputs

The LogResourcePolicy resource accepts the following input properties:

PolicyDocument string

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

PolicyName string

Name of the resource policy.

PolicyDocument string

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

PolicyName string

Name of the resource policy.

policyDocument string

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

policyName string

Name of the resource policy.

policy_document str

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

policy_name str

Name of the resource policy.

Outputs

All input properties are implicitly available as output properties. Additionally, the LogResourcePolicy 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing LogResourcePolicy Resource

Get an existing LogResourcePolicy 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?: LogResourcePolicyState, opts?: CustomResourceOptions): LogResourcePolicy
static get(resource_name, id, opts=None, policy_document=None, policy_name=None, __props__=None);
func GetLogResourcePolicy(ctx *Context, name string, id IDInput, state *LogResourcePolicyState, opts ...ResourceOption) (*LogResourcePolicy, error)
public static LogResourcePolicy Get(string name, Input<string> id, LogResourcePolicyState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

PolicyDocument string

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

PolicyName string

Name of the resource policy.

PolicyDocument string

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

PolicyName string

Name of the resource policy.

policyDocument string

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

policyName string

Name of the resource policy.

policy_document str

Details of the resource policy, including the identity of the principal that is enabled to put logs to this account. This is formatted as a JSON string. Maximum length of 5120 characters.

policy_name str

Name of the resource policy.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.