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

#11185: Allow specifying a KMS key and tags for newly created AWS CloudWatch log groups. #22274

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

johannesfloriangeiger
Copy link

@johannesfloriangeiger johannesfloriangeiger commented Jan 22, 2025

Summary

Implements the feature request #11185 by allowing users to specify a KMS key and tags for AWS CloudWatch log group sinks that are being used when creating new groups.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

  • New integration test is provided in the PR.
  • Manually
    • Get yourself an AWS environment.
    • Create a new KMS key and make sure that key can be used to encrypt CloudWatch log groups (for an example Key policy snippet see below).
    • Create a Vector config file as seen below, replace $KMS_KEY with the ARN of the key created in the previous step.
    • Run Vector: vector --config ./vector.yaml, see 3 new log groups being created: One without both custom KMS key and tags, one with only tags and one with both custom KMS key and tags.

Key policy that allows the usage in log groups in us-east-1:

{
  "Sid": "Allow use of the key for CloudWatch",
  "Effect": "Allow",
  "Principal": {
    "Service": "logs.us-east-1.amazonaws.com"
  },
  "Action": [
    "kms:Encrypt",
    "kms:Decrypt",
    "kms:ReEncrypt*",
    "kms:GenerateDataKey*",
    "kms:DescribeKey"
  ],
  "Resource": "*"
}

vector.yaml

sources:
  demo_logs:
    type: demo_logs
    format: json
sinks:
  cloudwatch_logs_without:
    type: aws_cloudwatch_logs
    inputs: [demo_logs]
    group_name: /without
    stream_name: demo-stream
    encoding:
      codec: json
  cloudwatch_logs_standard:
    type: aws_cloudwatch_logs
    inputs: [demo_logs]
    group_name: /standard
    stream_name: demo-stream
    encoding:
      codec: json
    tags:
      type: standard
  cloudwatch_logs_custom_kms_key:
    type: aws_cloudwatch_logs
    inputs: [demo_logs]
    group_name: /with-kms
    stream_name: demo-stream
    encoding:
      codec: json
    kms_key: $KMS_KEY
    tags:
      type: kms-key

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

  • Please read our Vector contributor resources.
    • make check-all is a good command to run locally. This check is
      defined here. Some of these
      checks might not be relevant to your PR. For Rust changes, at the very least you should run:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run dd-rust-license-tool write to regenerate the license inventory and commit the changes (if any). More details here.

References

@bits-bot
Copy link

bits-bot commented Jan 22, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added domain: sinks Anything related to the Vector's sinks domain: ci Anything related to Vector's CI environment labels Jan 22, 2025
@johannesfloriangeiger johannesfloriangeiger marked this pull request as ready for review January 23, 2025 14:57
@johannesfloriangeiger johannesfloriangeiger requested a review from a team as a code owner January 23, 2025 14:57
Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

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

Otherwise, this looks good and thank you for adding tests.

@@ -164,6 +165,14 @@ pub struct CloudwatchLogsSinkConfig {
skip_serializing_if = "crate::serde::is_default"
)]
pub acknowledgements: AcknowledgementsConfig,

#[configurable(derived)]
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @johannesfloriangeiger! Please add rustdocs and then make generate-components-docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: ci Anything related to Vector's CI environment domain: sinks Anything related to the Vector's sinks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting KMS key id and tags when creating a CloudWatch log group
3 participants