Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding cloudwatch_log_group resource output #294

Merged
merged 2 commits into from
Nov 1, 2023

Conversation

rodrigobersa
Copy link
Contributor

@rodrigobersa rodrigobersa commented Nov 1, 2023

What does this PR do?

Add a Terraform output for fargate_fluentbit addon, so it can be consumed by other modules.

Motivation

More

  • Yes, I have tested the PR using my local account setup (Provide any test evidence report under Additional Notes)
  • Yes, I ran pre-commit run -a with this PR

For Moderators

  • E2E Test successfully complete before merge?

Additional Notes

# cat outputs.tf
output "fargate_fluentbit" {
 value = module.eks_blueprints_addons.fargate_fluentbit
}
# terrraform apply -auto-approve

...truncated output

Apply complete! Resources: 58 added, 0 changed, 0 destroyed.

Outputs:

configure_kubectl = "aws eks --region us-west-2 update-kubeconfig --name fargate-fluentbit"
fargate_fluentbit = {
  "cloudwatch_log_group" = [
    {
      "arn" = "arn:aws:logs:us-west-2:xxxxxxxxxxxxx:log-group:/fargate/fargate-fluentbit-logs20231101194544512300000008"
      "id" = "/fargate/fargate-fluentbit-logs20231101194544512300000008"
      "kms_key_id" = ""
      "name" = "/fargate/fargate-fluentbit-logs20231101194544512300000008"
      "name_prefix" = "/fargate/fargate-fluentbit-logs"
      "retention_in_days" = 90
      "skip_destroy" = false
      "tags" = tomap({
        "Blueprint" = "fargate"
        "GithubRepo" = "github.com/aws-ia/terraform-aws-eks-blueprints-addons"
      })
      "tags_all" = tomap({
        "Blueprint" = "fargate"
        "GithubRepo" = "github.com/aws-ia/terraform-aws-eks-blueprints-addons"
      })
    },
  ]
  "configmap" = [
    {
      "binary_data" = tomap({})
      "data" = tomap({
        "filters.conf" = <<-EOT
        [FILTER]
          Name parser
          Match *
          Key_Name log
          Parser regex
          Preserve_Key True
          Reserve_Data True
        
        EOT
        "flb_log_cw" = "true"
        "output.conf" = <<-EOT
        [OUTPUT]
          Name cloudwatch_logs
          Match *
          region us-west-2
          log_group_name /fargate/fargate-fluentbit-logs20231101194544512300000008
          log_stream_prefix fargate-logs-
          auto_create_group true
        
        EOT
        "parsers.conf" = <<-EOT
        [PARSER]
          Name regex
          Format regex
          Regex ^(?<time>[^ ]+) (?<stream>[^ ]+) (?<logtag>[^ ]+) (?<message>.+)$
          Time_Key time
          Time_Format %Y-%m-%dT%H:%M:%S.%L%z
          Time_Keep On
          Decode_Field_As json message
        
        EOT
      })
      "id" = "aws-observability/aws-logging"
      "immutable" = false
      "metadata" = tolist([
        {
          "annotations" = tomap({})
          "generate_name" = ""
          "generation" = 0
          "labels" = tomap({})
          "name" = "aws-logging"
          "namespace" = "aws-observability"
          "resource_version" = "764"
          "uid" = "ea32d79f-6b69-4caf-9c48-96e148b44adc"
        },
      ])
    },
  ]
  "iam_policy" = [
    {
      "arn" = "arn:aws:iam::xxxxxxxxxxxxx:policy/fargate-fargate-fluentbit-logs-20231101194545414700000009"
      "description" = ""
      "id" = "arn:aws:iam::xxxxxxxxxxxxx:policy/fargate-fargate-fluentbit-logs-20231101194545414700000009"
      "name" = "fargate-fargate-fluentbit-logs-20231101194545414700000009"
      "name_prefix" = "fargate-fargate-fluentbit-logs-"
      "path" = "/"
      "policy" = "{\"Statement\":[{\"Action\":[\"logs:PutLogEvents\",\"logs:DescribeLogStreams\",\"logs:CreateLogStream\",\"logs:CreateLogGroup\"],\"Effect\":\"Allow\",\"Resource\":[\"arn:aws:logs:us-west-2:978045894046:log-group:/fargate/fargate-fluentbit-logs20231101194544512300000008:logstream:*\",\"arn:aws:logs:us-west-2:978045894046:log-group:/fargate/fargate-fluentbit-logs20231101194544512300000008:*\"],\"Sid\":\"PutLogEvents\"}],\"Version\":\"2012-10-17\"}"
      "policy_id" = "ANPA6HOAT7WPIDPJNSQ6V"
      "tags" = tomap({})
      "tags_all" = tomap({})
    },
  ]
}

Copy link
Contributor

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable - just curious, what would potentially use this value?

@rodrigobersa rodrigobersa marked this pull request as ready for review November 1, 2023 20:29
@rodrigobersa rodrigobersa requested a review from a team as a code owner November 1, 2023 20:29
@rodrigobersa
Copy link
Contributor Author

seems reasonable - just curious, what would potentially use this value?

Customer wants to consume the log groups to create alarms/metrics on top of them using other TF resources.

@rodrigobersa rodrigobersa merged commit 6bd285c into main Nov 1, 2023
8 checks passed
@rodrigobersa rodrigobersa deleted the fix/fargate_fluentbit_output branch November 1, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add fargate_fluentbit CloudWatch Log Group output.
2 participants