Ask Your Question
4

How to create a Cloudwatch Log Group in Terraform with a KMS key?

asked 2022-10-18 11:00:00 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-10-16 20:00:00 +0000

huitzilopochtli gravatar image

To create a Cloudwatch Log Group with a KMS key in Terraform, you can use the following code:

resource "aws_kms_key" "example" {
  description = "Example KMS Key"
}

resource "aws_cloudwatch_log_group" "example" {
  name = "example-log-group"
  kms_key_id = aws_kms_key.example.arn
}

In this code, we first create a KMS key using the aws_kms_key resource. We then use the ARN of this KMS key (aws_kms_key.example.arn) in the aws_cloudwatch_log_group resource to specify which KMS key to use for encrypting the log data.

The aws_cloudwatch_log_group resource also specifies the name of the log group as example-log-group. You can replace this value with any name that you prefer.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-10-18 11:00:00 +0000

Seen: 15 times

Last updated: Oct 16 '22