Esempio n. 1
0
 public MyStack()
 {
     var yada = new Aws.CloudWatch.LogGroup("yada", new Aws.CloudWatch.LogGroupArgs
     {
     });
     var foo = new Aws.CloudWatch.LogStream("foo", new Aws.CloudWatch.LogStreamArgs
     {
         LogGroupName = yada.Name,
     });
 }
Esempio n. 2
0
 public MyStack()
 {
     var yada = new Aws.CloudWatch.LogGroup("yada", new Aws.CloudWatch.LogGroupArgs
     {
         Tags =
         {
             { "Application", "serviceA"   },
             { "Environment", "production" },
         },
     });
 }
Esempio n. 3
0
    public MyStack()
    {
        var exampleLogGroup = new Aws.CloudWatch.LogGroup("exampleLogGroup", new Aws.CloudWatch.LogGroupArgs
        {
        });
        var exampleRole = new Aws.Iam.Role("exampleRole", new Aws.Iam.RoleArgs
        {
            AssumeRolePolicy = @"{
  ""Version"": ""2012-10-17"",
  ""Statement"": [
    {
      ""Sid"": """",
      ""Effect"": ""Allow"",
      ""Principal"": {
        ""Service"": ""vpc-flow-logs.amazonaws.com""
      },
      ""Action"": ""sts:AssumeRole""
    }
  ]
}

",
        });
        var exampleFlowLog = new Aws.Ec2.FlowLog("exampleFlowLog", new Aws.Ec2.FlowLogArgs
        {
            IamRoleArn     = exampleRole.Arn,
            LogDestination = exampleLogGroup.Arn,
            TrafficType    = "ALL",
            VpcId          = aws_vpc.Example.Id,
        });
        var exampleRolePolicy = new Aws.Iam.RolePolicy("exampleRolePolicy", new Aws.Iam.RolePolicyArgs
        {
            Policy = @"{
  ""Version"": ""2012-10-17"",
  ""Statement"": [
    {
      ""Action"": [
        ""logs:CreateLogGroup"",
        ""logs:CreateLogStream"",
        ""logs:PutLogEvents"",
        ""logs:DescribeLogGroups"",
        ""logs:DescribeLogStreams""
      ],
      ""Effect"": ""Allow"",
      ""Resource"": ""*""
    }
  ]
}

",
            Role   = exampleRole.Id,
        });
    }
Esempio n. 4
0
 public MyStack()
 {
     var exampleLogGroup = new Aws.CloudWatch.LogGroup("exampleLogGroup", new Aws.CloudWatch.LogGroupArgs
     {
         RetentionInDays = 14,
     });
     var ad_log_policyPolicyDocument = exampleLogGroup.Arn.Apply(arn => Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
     {
         Statements =
         {
             new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
             {
                 Actions =
                 {
                     "logs:CreateLogStream",
                     "logs:PutLogEvents",
                 },
                 Effect     = "Allow",
                 Principals =
                 {
                     new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
                     {
                         Identifiers =
                         {
                             "ds.amazonaws.com",
                         },
                         Type = "Service",
                     },
                 },
                 Resources =
                 {
                     arn,
                 },
             },
         },
     }));
     var ad_log_policyLogResourcePolicy = new Aws.CloudWatch.LogResourcePolicy("ad-log-policyLogResourcePolicy", new Aws.CloudWatch.LogResourcePolicyArgs
     {
         PolicyDocument = ad_log_policyPolicyDocument.Apply(ad_log_policyPolicyDocument => ad_log_policyPolicyDocument.Json),
         PolicyName     = "ad-log-policy",
     });
     var exampleLogService = new Aws.DirectoryService.LogService("exampleLogService", new Aws.DirectoryService.LogServiceArgs
     {
         DirectoryId  = aws_directory_service_directory.Example.Id,
         LogGroupName = exampleLogGroup.Name,
     });
 }
Esempio n. 5
0
 public MyStack()
 {
     var exampleLogGroup = new Aws.CloudWatch.LogGroup("exampleLogGroup", new Aws.CloudWatch.LogGroupArgs
     {
         RetentionInDays = 14,
     });
     var exampleJob = new Aws.Glue.Job("exampleJob", new Aws.Glue.JobArgs
     {
         DefaultArguments =
         {
             { "--continuous-log-logGroup",          exampleLogGroup.Name },
             { "--enable-continuous-cloudwatch-log", "true"               },
             { "--enable-continuous-log-filter",     "true"               },
             { "--enable-metrics",                   ""                   },
         },
     });
 }
Esempio n. 6
0
    public MyStack()
    {
        var testLambda = new Aws.Lambda.Function("testLambda", new Aws.Lambda.FunctionArgs
        {
        }, new CustomResourceOptions
        {
            DependsOn =
            {
                "aws_cloudwatch_log_group.example",
                "aws_iam_role_policy_attachment.lambda_logs",
            },
        });
        // This is to optionally manage the CloudWatch Log Group for the Lambda Function.
        // If skipping this resource configuration, also add "logs:CreateLogGroup" to the IAM policy below.
        var example = new Aws.CloudWatch.LogGroup("example", new Aws.CloudWatch.LogGroupArgs
        {
            RetentionInDays = 14,
        });
        // See also the following AWS managed policy: AWSLambdaBasicExecutionRole
        var lambdaLogging = new Aws.Iam.Policy("lambdaLogging", new Aws.Iam.PolicyArgs
        {
            Description = "IAM policy for logging from a lambda",
            Path        = "/",
            Policy      = @"{
  ""Version"": ""2012-10-17"",
  ""Statement"": [
    {
      ""Action"": [
        ""logs:CreateLogGroup"",
        ""logs:CreateLogStream"",
        ""logs:PutLogEvents""
      ],
      ""Resource"": ""arn:aws:logs:*:*:*"",
      ""Effect"": ""Allow""
    }
  ]
}

",
        });
        var lambdaLogs = new Aws.Iam.RolePolicyAttachment("lambdaLogs", new Aws.Iam.RolePolicyAttachmentArgs
        {
            PolicyArn = lambdaLogging.Arn,
            Role      = aws_iam_role.Iam_for_lambda.Name,
        });
    }
Esempio n. 7
0
 public MyStack()
 {
     var dada = new Aws.CloudWatch.LogGroup("dada", new Aws.CloudWatch.LogGroupArgs
     {
     });
     var yada = new Aws.CloudWatch.LogMetricFilter("yada", new Aws.CloudWatch.LogMetricFilterArgs
     {
         LogGroupName         = dada.Name,
         MetricTransformation = new Aws.CloudWatch.Inputs.LogMetricFilterMetricTransformationArgs
         {
             Name      = "EventCount",
             Namespace = "YourNamespace",
             Value     = "1",
         },
         Pattern = "",
     });
 }
Esempio n. 8
0
    public MyStack()
    {
        var exampleLogGroup = new Aws.CloudWatch.LogGroup("exampleLogGroup", new Aws.CloudWatch.LogGroupArgs
        {
        });
        var exampleLogResourcePolicy = new Aws.CloudWatch.LogResourcePolicy("exampleLogResourcePolicy", new Aws.CloudWatch.LogResourcePolicyArgs
        {
            PolicyDocument = @"{
  ""Version"": ""2012-10-17"",
  ""Statement"": [
    {
      ""Effect"": ""Allow"",
      ""Principal"": {
        ""Service"": ""es.amazonaws.com""
      },
      ""Action"": [
        ""logs:PutLogEvents"",
        ""logs:PutLogEventsBatch"",
        ""logs:CreateLogStream""
      ],
      ""Resource"": ""arn:aws:logs:*""
    }
  ]
}

",
            PolicyName     = "example",
        });
        var exampleDomain = new Aws.ElasticSearch.Domain("exampleDomain", new Aws.ElasticSearch.DomainArgs
        {
            LogPublishingOptions =
            {
                new Aws.ElasticSearch.Inputs.DomainLogPublishingOptionArgs
                {
                    CloudwatchLogGroupArn = exampleLogGroup.Arn,
                    LogType = "INDEX_SLOW_LOGS",
                },
            },
        });
    }
Esempio n. 9
0
 public MyStack()
 {
     var config         = new Config();
     var clusterName    = config.Get("clusterName") ?? "example";
     var exampleCluster = new Aws.Eks.Cluster("exampleCluster", new Aws.Eks.ClusterArgs
     {
         EnabledClusterLogTypes =
         {
             "api",
             "audit",
         },
     }, new CustomResourceOptions
     {
         DependsOn =
         {
             "aws_cloudwatch_log_group.example",
         },
     });
     var exampleLogGroup = new Aws.CloudWatch.LogGroup("exampleLogGroup", new Aws.CloudWatch.LogGroupArgs
     {
         RetentionInDays = 7,
     });
 }
Esempio n. 10
0
 public MyStack()
 {
     var us_east_1 = new Aws.Provider("us-east-1", new Aws.ProviderArgs
     {
         Region = "us-east-1",
     });
     var awsRoute53ExampleCom = new Aws.CloudWatch.LogGroup("awsRoute53ExampleCom", new Aws.CloudWatch.LogGroupArgs
     {
         RetentionInDays = 30,
     }, new CustomResourceOptions
     {
         Provider = "aws.us-east-1",
     });
     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",
     }, new CustomResourceOptions
     {
         Provider = "aws.us-east-1",
     });
     var exampleComZone = new Aws.Route53.Zone("exampleComZone", new Aws.Route53.ZoneArgs
     {
     });
     var exampleComQueryLog = new Aws.Route53.QueryLog("exampleComQueryLog", new Aws.Route53.QueryLogArgs
     {
         CloudwatchLogGroupArn = awsRoute53ExampleCom.Arn,
         ZoneId = exampleComZone.ZoneId,
     }, new CustomResourceOptions
     {
         DependsOn =
         {
             "aws_cloudwatch_log_resource_policy.route53-query-logging-policy",
         },
     });
 }