1. Packages
  2. AWS Classic
  3. API Docs
  4. cloudwatch
  5. LogDestinationPolicy

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

aws.cloudwatch.LogDestinationPolicy

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

    Provides a CloudWatch Logs destination policy resource.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var testDestination = new Aws.CloudWatch.LogDestination("testDestination", new()
        {
            RoleArn = aws_iam_role.Iam_for_cloudwatch.Arn,
            TargetArn = aws_kinesis_stream.Kinesis_for_cloudwatch.Arn,
        });
    
        var testDestinationPolicyPolicyDocument = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Effect = "Allow",
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "AWS",
                            Identifiers = new[]
                            {
                                "123456789012",
                            },
                        },
                    },
                    Actions = new[]
                    {
                        "logs:PutSubscriptionFilter",
                    },
                    Resources = new[]
                    {
                        testDestination.Arn,
                    },
                },
            },
        });
    
        var testDestinationPolicyLogDestinationPolicy = new Aws.CloudWatch.LogDestinationPolicy("testDestinationPolicyLogDestinationPolicy", new()
        {
            DestinationName = testDestination.Name,
            AccessPolicy = testDestinationPolicyPolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    	"github.com/pulumi/pulumi-aws/sdk/v6/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.StringPtrOutput),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.cloudwatch.LogDestination;
    import com.pulumi.aws.cloudwatch.LogDestinationArgs;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.cloudwatch.LogDestinationPolicy;
    import com.pulumi.aws.cloudwatch.LogDestinationPolicyArgs;
    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 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.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult).applyValue(testDestinationPolicyPolicyDocument -> testDestinationPolicyPolicyDocument.applyValue(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 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 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

    Using pulumi import, import CloudWatch Logs destination policies using the destination_name. For example:

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

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi