LogDestinationPolicy

Provides a CloudWatch Logs destination policy resource.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var testDestination = new Aws.CloudWatch.LogDestination("testDestination", new Aws.CloudWatch.LogDestinationArgs
        {
            RoleArn = aws_iam_role.Iam_for_cloudwatch.Arn,
            TargetArn = aws_kinesis_stream.Kinesis_for_cloudwatch.Arn,
        });
        var testDestinationPolicyPolicyDocument = testDestination.Arn.Apply(arn => Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
        {
            Statements = 
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
                {
                    Actions = 
                    {
                        "logs:PutSubscriptionFilter",
                    },
                    Effect = "Allow",
                    Principals = 
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
                        {
                            Identifiers = 
                            {
                                "123456789012",
                            },
                            Type = "AWS",
                        },
                    },
                    Resources = 
                    {
                        arn,
                    },
                },
            },
        }));
        var testDestinationPolicyLogDestinationPolicy = new Aws.CloudWatch.LogDestinationPolicy("testDestinationPolicyLogDestinationPolicy", new Aws.CloudWatch.LogDestinationPolicyArgs
        {
            AccessPolicy = testDestinationPolicyPolicyDocument.Apply(testDestinationPolicyPolicyDocument => testDestinationPolicyPolicyDocument.Json),
            DestinationName = testDestination.Name,
        });
    }

}
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 {
        testDestination, err := cloudwatch.NewLogDestination(ctx, "testDestination", &cloudwatch.LogDestinationArgs{
            RoleArn:   pulumi.String(aws_iam_role.Iam_for_cloudwatch.Arn),
            TargetArn: pulumi.String(aws_kinesis_stream.Kinesis_for_cloudwatch.Arn),
        })
        if err != nil {
            return err
        }
        _, err = cloudwatch.NewLogDestinationPolicy(ctx, "testDestinationPolicyLogDestinationPolicy", &cloudwatch.LogDestinationPolicyArgs{
            AccessPolicy: testDestinationPolicyPolicyDocument.ApplyT(func(testDestinationPolicyPolicyDocument iam.GetPolicyDocumentResult) (string, error) {
                return testDestinationPolicyPolicyDocument.Json, nil
            }).(pulumi.StringOutput),
            DestinationName: testDestination.Name,
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

test_destination = aws.cloudwatch.LogDestination("testDestination",
    role_arn=aws_iam_role["iam_for_cloudwatch"]["arn"],
    target_arn=aws_kinesis_stream["kinesis_for_cloudwatch"]["arn"])
test_destination_policy_policy_document = test_destination.arn.apply(lambda arn: aws.iam.get_policy_document(statements=[{
    "actions": ["logs:PutSubscriptionFilter"],
    "effect": "Allow",
    "principals": [{
        "identifiers": ["123456789012"],
        "type": "AWS",
    }],
    "resources": [arn],
}]))
test_destination_policy_log_destination_policy = aws.cloudwatch.LogDestinationPolicy("testDestinationPolicyLogDestinationPolicy",
    access_policy=test_destination_policy_policy_document.json,
    destination_name=test_destination.name)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const testDestination = new aws.cloudwatch.LogDestination("test_destination", {
    roleArn: aws_iam_role_iam_for_cloudwatch.arn,
    targetArn: aws_kinesis_stream_kinesis_for_cloudwatch.arn,
});
const testDestinationPolicyPolicyDocument = testDestination.arn.apply(arn => aws.iam.getPolicyDocument({
    statements: [{
        actions: ["logs:PutSubscriptionFilter"],
        effect: "Allow",
        principals: [{
            identifiers: ["123456789012"],
            type: "AWS",
        }],
        resources: [arn],
    }],
}, { async: true }));
const testDestinationPolicyLogDestinationPolicy = new aws.cloudwatch.LogDestinationPolicy("test_destination_policy", {
    accessPolicy: testDestinationPolicyPolicyDocument.json,
    destinationName: testDestination.name,
});

Create a LogDestinationPolicy Resource

def LogDestinationPolicy(resource_name, opts=None, access_policy=None, destination_name=None, __props__=None);
name string
The unique name of the resource.
args LogDestinationPolicyArgs
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 LogDestinationPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args LogDestinationPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

LogDestinationPolicy Resource Properties

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

Inputs

The LogDestinationPolicy resource accepts the following input properties:

AccessPolicy string

The policy document. This is a JSON formatted string.

DestinationName string

A name for the subscription filter

AccessPolicy string

The policy document. This is a JSON formatted string.

DestinationName string

A name for the subscription filter

accessPolicy string

The policy document. This is a JSON formatted string.

destinationName string

A name for the subscription filter

access_policy str

The policy document. This is a JSON formatted string.

destination_name str

A name for the subscription filter

Outputs

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

Get an existing LogDestinationPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

static get(resource_name, id, opts=None, access_policy=None, destination_name=None, __props__=None);
func GetLogDestinationPolicy(ctx *Context, name string, id IDInput, state *LogDestinationPolicyState, opts ...ResourceOption) (*LogDestinationPolicy, error)
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:

AccessPolicy string

The policy document. This is a JSON formatted string.

DestinationName string

A name for the subscription filter

AccessPolicy string

The policy document. This is a JSON formatted string.

DestinationName string

A name for the subscription filter

accessPolicy string

The policy document. This is a JSON formatted string.

destinationName string

A name for the subscription filter

access_policy str

The policy document. This is a JSON formatted string.

destination_name str

A name for the subscription filter

Package Details

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