Lab 21: CloudWatch Setup Using Terraform
The Nautilus DevOps team needs to set up CloudWatch logging for their application. They need to create a CloudWatch log group and log stream with the following specifications:
-
The log group name should be
datacenter-log-group. -
The log stream name should be
datacenter-log-stream.
Use Terraform to create the CloudWatch log group and log stream. The Terraform working directory is /home/bob/terraform. Create the main.tf file (do not create a different .tf file) to accomplish this task.
Note: Right-click under the EXPLORER section in VS Code and select Open in Integrated Terminal to launch the terminal.
Create main.tf
resource "aws_cloudwatch_log_group" "datacenter-log-group" {
name = "datacenter-log-group"
}
resource "aws_cloudwatch_log_stream" "datacenter-log-stream" {
name = "datacenter-log-stream"
log_group_name = aws_cloudwatch_log_group.datacenter-log-group.name
}
terraform init
terraform plan -out kke.plan && terraform apply kke.plan
# or apply forcefully without creating plan and applying it
terraform apply -auto-approve