Complete the code to create a CloudWatch log group named 'MyAppLogs'.
resource "aws_cloudwatch_log_group" "example" { name = [1] }
The name property sets the name of the log group. Here, it should be "MyAppLogs".
Complete the code to create a CloudWatch log stream named 'AppStream' inside the log group 'MyAppLogs'.
resource "aws_cloudwatch_log_stream" "example" { name = [1] log_group_name = "MyAppLogs" }
The name property sets the log stream name. It should be "AppStream" to match the requirement.
Fix the error in the code to correctly reference the log group name in the log stream resource.
resource "aws_cloudwatch_log_stream" "example" { name = "AppStream" log_group_name = [1] }
The log_group_name expects the name string. Using aws_cloudwatch_log_group.example.name correctly references the log group resource's name attribute.
Fill both blanks to create a log group and a log stream with correct names.
resource "aws_cloudwatch_log_group" "app_logs" { name = [1] } resource "aws_cloudwatch_log_stream" "app_stream" { name = [2] log_group_name = aws_cloudwatch_log_group.app_logs.name }
The log group is named "AppLogGroup" and the log stream is named "AppStream1" to match the requirement.
Fill all three blanks to define a log group, a log stream, and assign the log stream to the group correctly.
resource "aws_cloudwatch_log_group" "main_logs" { name = [1] } resource "aws_cloudwatch_log_stream" "main_stream" { name = [2] log_group_name = [3] }
The log group is named "MainLogGroup". The log stream is named "MainStream" and correctly references the log group's name attribute.