Class LogResourcePolicy


  • public class LogResourcePolicy
    extends com.pulumi.resources.CustomResource
    Provides a resource to manage a CloudWatch log resource policy. ## Example Usage ### Elasticsearch Log Publishing
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.iam.IamFunctions;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
     import com.pulumi.aws.cloudwatch.LogResourcePolicy;
     import com.pulumi.aws.cloudwatch.LogResourcePolicyArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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) {
             final var elasticsearch-log-publishing-policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                 .statements(GetPolicyDocumentStatementArgs.builder()
                     .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                         .identifiers("es.amazonaws.com")
                         .type("Service")
                         .build())
                     .actions(                
                         "logs:CreateLogStream",
                         "logs:PutLogEvents",
                         "logs:PutLogEventsBatch")
                     .resources("arn:aws:logs:*")
                     .build())
                 .build());
     
             var elasticsearch_log_publishing_policyLogResourcePolicy = new LogResourcePolicy("elasticsearch-log-publishing-policyLogResourcePolicy", LogResourcePolicyArgs.builder()
                 .policyDocument(elasticsearch_log_publishing_policy.json())
                 .policyName("elasticsearch-log-publishing-policy")
                 .build());
     
         }
     }
     
     
    ### Route53 Query Logging
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.iam.IamFunctions;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
     import com.pulumi.aws.cloudwatch.LogResourcePolicy;
     import com.pulumi.aws.cloudwatch.LogResourcePolicyArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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) {
             final var route53-query-logging-policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                 .statements(GetPolicyDocumentStatementArgs.builder()
                     .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                         .identifiers("route53.amazonaws.com")
                         .type("Service")
                         .build())
                     .actions(                
                         "logs:CreateLogStream",
                         "logs:PutLogEvents")
                     .resources("arn:aws:logs:*:*:log-group:/aws/route53/*")
                     .build())
                 .build());
     
             var route53_query_logging_policyLogResourcePolicy = new LogResourcePolicy("route53-query-logging-policyLogResourcePolicy", LogResourcePolicyArgs.builder()
                 .policyDocument(route53_query_logging_policy.json())
                 .policyName("route53-query-logging-policy")
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema Exactly one of `policyName` or `resourceArn` must be configured. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `policyName` (String) Name of the resource policy. * `region` (String) Region where this resource is managed. * `resourceArn` (String) ARN of the resource to which the policy is attached. Using `pulumi import`, import Resource Policies using `policyName` for account-scoped policies, or `resourceArn` for resource-scoped policies. For example: ```sh $ pulumi import aws:cloudwatch/logResourcePolicy:LogResourcePolicy my_policy_account_scoped my_policy ``` ```sh $ pulumi import aws:cloudwatch/logResourcePolicy:LogResourcePolicy my_policy_resource_scoped "arn:aws:logs:us-west-2:123456789012:log-group:/my-log-group" ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static LogResourcePolicy get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, LogResourcePolicyState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> policyDocument()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> policyName()  
      com.pulumi.core.Output<java.lang.String> policyScope()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> resourceArn()  
      com.pulumi.core.Output<java.lang.String> revisionId()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LogResourcePolicy

        public LogResourcePolicy​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • LogResourcePolicy

        public LogResourcePolicy​(java.lang.String name,
                                 LogResourcePolicyArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • LogResourcePolicy

        public LogResourcePolicy​(java.lang.String name,
                                 LogResourcePolicyArgs args,
                                 @Nullable
                                 com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • policyDocument

        public com.pulumi.core.Output<java.lang.String> policyDocument()
        Returns:
        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

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> policyName()
        Returns:
        Name of the resource policy. Exactly one of `policyName` or `resourceArn` must be specified and this argument is required for account-scoped policies. Note that the number of resource policies without `resourceArn` is limited to 10 per region.
      • policyScope

        public com.pulumi.core.Output<java.lang.String> policyScope()
        Returns:
        Scope of the resource policy (`ACCOUNT` or `RESOURCE`).
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • resourceArn

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> resourceArn()
        Returns:
        ARN of the CloudWatch Logs resource to which the resource policy is attached. Exactly one of `policyName` or `resourceArn` must be specified and this argument is required for resource-scoped policies. Only one policy can be attached per log group resource ARN.
      • revisionId

        public com.pulumi.core.Output<java.lang.String> revisionId()
        Returns:
        Revision ID of the resource policy. Only populated for resource-scoped policies.
      • get

        public static LogResourcePolicy get​(java.lang.String name,
                                            com.pulumi.core.Output<java.lang.String> id,
                                            @Nullable
                                            LogResourcePolicyState state,
                                            @Nullable
                                            com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.