AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

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 = Aws.Iam.GetPolicyDocument.Invoke(new Aws.Iam.GetPolicyDocumentInvokeArgs
        {
            Statements = 
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Effect = "Allow",
                    Principals = 
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = 
                            {
                                "123456789012",
                            },
                        },
                    },
                    Actions = 
                    {
                        "logs:PutSubscriptionFilter",
                    },
                    Resources = 
                    {
                        testDestination.Arn,
                    },
                },
            },
        });
        var testDestinationPolicyLogDestinationPolicy = new Aws.CloudWatch.LogDestinationPolicy("testDestinationPolicyLogDestinationPolicy", new Aws.CloudWatch.LogDestinationPolicyArgs
        {
            DestinationName = testDestination.Name,
            AccessPolicy = testDestinationPolicyPolicyDocument.Apply(testDestinationPolicyPolicyDocument => testDestinationPolicyPolicyDocument.Json),
        });
    }

}
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		testDestination, err := cloudwatch.NewLogDestination(ctx, "testDestination", &cloudwatch.LogDestinationArgs{
			RoleArn:   pulumi.Any(aws_iam_role.Iam_for_cloudwatch.Arn),
			TargetArn: pulumi.Any(aws_kinesis_stream.Kinesis_for_cloudwatch.Arn),
		})
		if err != nil {
			return err
		}
		testDestinationPolicyPolicyDocument := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
			Statements: iam.GetPolicyDocumentStatementArray{
				&iam.GetPolicyDocumentStatementArgs{
					Effect: pulumi.String("Allow"),
					Principals: iam.GetPolicyDocumentStatementPrincipalArray{
						&iam.GetPolicyDocumentStatementPrincipalArgs{
							Type: pulumi.String("AWS"),
							Identifiers: pulumi.StringArray{
								pulumi.String("123456789012"),
							},
						},
					},
					Actions: pulumi.StringArray{
						pulumi.String("logs:PutSubscriptionFilter"),
					},
					Resources: pulumi.StringArray{
						testDestination.Arn,
					},
				},
			},
		}, nil)
		_, err = cloudwatch.NewLogDestinationPolicy(ctx, "testDestinationPolicyLogDestinationPolicy", &cloudwatch.LogDestinationPolicyArgs{
			DestinationName: testDestination.Name,
			AccessPolicy: testDestinationPolicyPolicyDocument.ApplyT(func(testDestinationPolicyPolicyDocument iam.GetPolicyDocumentResult) (string, error) {
				return testDestinationPolicyPolicyDocument.Json, nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var testDestination = new LogDestination("testDestination", LogDestinationArgs.builder()        
            .roleArn(aws_iam_role.iam_for_cloudwatch().arn())
            .targetArn(aws_kinesis_stream.kinesis_for_cloudwatch().arn())
            .build());

        final var testDestinationPolicyPolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .effect("Allow")
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("AWS")
                    .identifiers("123456789012")
                    .build())
                .actions("logs:PutSubscriptionFilter")
                .resources(testDestination.arn())
                .build())
            .build());

        var testDestinationPolicyLogDestinationPolicy = new LogDestinationPolicy("testDestinationPolicyLogDestinationPolicy", LogDestinationPolicyArgs.builder()        
            .destinationName(testDestination.name())
            .accessPolicy(testDestinationPolicyPolicyDocument.apply(getPolicyDocumentResult -> getPolicyDocumentResult).apply(testDestinationPolicyPolicyDocument -> testDestinationPolicyPolicyDocument.apply(getPolicyDocumentResult -> getPolicyDocumentResult.json())))
            .build());

    }
}
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 = aws.iam.get_policy_document_output(statements=[aws.iam.GetPolicyDocumentStatementArgs(
    effect="Allow",
    principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
        type="AWS",
        identifiers=["123456789012"],
    )],
    actions=["logs:PutSubscriptionFilter"],
    resources=[test_destination.arn],
)])
test_destination_policy_log_destination_policy = aws.cloudwatch.LogDestinationPolicy("testDestinationPolicyLogDestinationPolicy",
    destination_name=test_destination.name,
    access_policy=test_destination_policy_policy_document.json)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const testDestination = new aws.cloudwatch.LogDestination("testDestination", {
    roleArn: aws_iam_role.iam_for_cloudwatch.arn,
    targetArn: aws_kinesis_stream.kinesis_for_cloudwatch.arn,
});
const testDestinationPolicyPolicyDocument = aws.iam.getPolicyDocumentOutput({
    statements: [{
        effect: "Allow",
        principals: [{
            type: "AWS",
            identifiers: ["123456789012"],
        }],
        actions: ["logs:PutSubscriptionFilter"],
        resources: [testDestination.arn],
    }],
});
const testDestinationPolicyLogDestinationPolicy = new aws.cloudwatch.LogDestinationPolicy("testDestinationPolicyLogDestinationPolicy", {
    destinationName: testDestination.name,
    accessPolicy: testDestinationPolicyPolicyDocument.apply(testDestinationPolicyPolicyDocument => testDestinationPolicyPolicyDocument.json),
});
resources:
  testDestination:
    type: aws:cloudwatch:LogDestination
    properties:
      roleArn: ${aws_iam_role.iam_for_cloudwatch.arn}
      targetArn: ${aws_kinesis_stream.kinesis_for_cloudwatch.arn}
  testDestinationPolicyLogDestinationPolicy:
    type: aws:cloudwatch:LogDestinationPolicy
    properties:
      destinationName: ${testDestination.name}
      accessPolicy: ${testDestinationPolicyPolicyDocument.json}
variables:
  testDestinationPolicyPolicyDocument:
    Fn::Invoke:
      Function: aws:iam:getPolicyDocument
      Arguments:
        statements:
          - effect: Allow
            principals:
              - type: AWS
                identifiers:
                  - 123456789012
            actions:
              - logs:PutSubscriptionFilter
            resources:
              - ${testDestination.arn}

Create a LogDestinationPolicy Resource

new LogDestinationPolicy(name: string, args: LogDestinationPolicyArgs, opts?: CustomResourceOptions);
@overload
def LogDestinationPolicy(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         access_policy: Optional[str] = None,
                         destination_name: Optional[str] = None,
                         force_update: Optional[bool] = None)
@overload
def LogDestinationPolicy(resource_name: str,
                         args: LogDestinationPolicyArgs,
                         opts: Optional[ResourceOptions] = None)
func NewLogDestinationPolicy(ctx *Context, name string, args LogDestinationPolicyArgs, opts ...ResourceOption) (*LogDestinationPolicy, error)
public LogDestinationPolicy(string name, LogDestinationPolicyArgs args, CustomResourceOptions? opts = null)
public LogDestinationPolicy(String name, LogDestinationPolicyArgs args)
public LogDestinationPolicy(String name, LogDestinationPolicyArgs args, CustomResourceOptions options)
type: aws:cloudwatch:LogDestinationPolicy
properties: # The arguments to resource properties.
options: # 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.
resource_name str
The unique name of the resource.
args LogDestinationPolicyArgs
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 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.
name String
The unique name of the resource.
args LogDestinationPolicyArgs
The arguments to resource properties.
options 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 Architecture and Concepts 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

ForceUpdate bool

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

AccessPolicy string

The policy document. This is a JSON formatted string.

DestinationName string

A name for the subscription filter

ForceUpdate bool

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

accessPolicy String

The policy document. This is a JSON formatted string.

destinationName String

A name for the subscription filter

forceUpdate Boolean

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

accessPolicy string

The policy document. This is a JSON formatted string.

destinationName string

A name for the subscription filter

forceUpdate boolean

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

access_policy str

The policy document. This is a JSON formatted string.

destination_name str

A name for the subscription filter

force_update bool

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

accessPolicy String

The policy document. This is a JSON formatted string.

destinationName String

A name for the subscription filter

forceUpdate Boolean

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

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 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 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.

public static get(name: string, id: Input<ID>, state?: LogDestinationPolicyState, opts?: CustomResourceOptions): LogDestinationPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        access_policy: Optional[str] = None,
        destination_name: Optional[str] = None,
        force_update: Optional[bool] = None) -> LogDestinationPolicy
func GetLogDestinationPolicy(ctx *Context, name string, id IDInput, state *LogDestinationPolicyState, opts ...ResourceOption) (*LogDestinationPolicy, error)
public static LogDestinationPolicy Get(string name, Input<string> id, LogDestinationPolicyState? state, CustomResourceOptions? opts = null)
public static LogDestinationPolicy get(String name, Output<String> id, LogDestinationPolicyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
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:
AccessPolicy string

The policy document. This is a JSON formatted string.

DestinationName string

A name for the subscription filter

ForceUpdate bool

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

AccessPolicy string

The policy document. This is a JSON formatted string.

DestinationName string

A name for the subscription filter

ForceUpdate bool

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

accessPolicy String

The policy document. This is a JSON formatted string.

destinationName String

A name for the subscription filter

forceUpdate Boolean

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

accessPolicy string

The policy document. This is a JSON formatted string.

destinationName string

A name for the subscription filter

forceUpdate boolean

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

access_policy str

The policy document. This is a JSON formatted string.

destination_name str

A name for the subscription filter

force_update bool

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

accessPolicy String

The policy document. This is a JSON formatted string.

destinationName String

A name for the subscription filter

forceUpdate Boolean

Specify true if you are updating an existing destination policy to grant permission to an organization ID instead of granting permission to individual AWS accounts.

Import

CloudWatch Logs destination policies can be imported using the destination_name, e.g.,

 $ pulumi import aws:cloudwatch/logDestinationPolicy:LogDestinationPolicy test_destination_policy test_destination

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.