0
0
AWScloud~10 mins

Log groups and log streams in AWS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a CloudWatch log group named 'MyAppLogs'.

AWS
resource "aws_cloudwatch_log_group" "example" {
  name = [1]
}
Drag options to blanks, or click blank then click option'
A"MyAppStream"
B"MyAppLogs"
C"AppLogGroup"
D"LogGroup1"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a log stream name instead of a log group name.
Forgetting to put quotes around the name.
2fill in blank
medium

Complete the code to create a CloudWatch log stream named 'AppStream' inside the log group 'MyAppLogs'.

AWS
resource "aws_cloudwatch_log_stream" "example" {
  name           = [1]
  log_group_name = "MyAppLogs"
}
Drag options to blanks, or click blank then click option'
A"LogStream"
B"Stream1"
C"MyAppLogs"
D"AppStream"
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing log group name with log stream name.
Using the wrong quotes or missing quotes.
3fill in blank
hard

Fix the error in the code to correctly reference the log group name in the log stream resource.

AWS
resource "aws_cloudwatch_log_stream" "example" {
  name           = "AppStream"
  log_group_name = [1]
}
Drag options to blanks, or click blank then click option'
Aaws_cloudwatch_log_group.example.name
B"aws_cloudwatch_log_group.example.name"
Caws_cloudwatch_log_group.example
D"MyAppLogs"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the resource reference, making it a string literal.
Referencing the whole resource instead of its name attribute.
4fill in blank
hard

Fill both blanks to create a log group and a log stream with correct names.

AWS
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
}
Drag options to blanks, or click blank then click option'
A"AppLogGroup"
B"AppStream1"
C"StreamMain"
D"LogGroupMain"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same name for both log group and log stream.
Forgetting quotes around the names.
5fill in blank
hard

Fill all three blanks to define a log group, a log stream, and assign the log stream to the group correctly.

AWS
resource "aws_cloudwatch_log_group" "main_logs" {
  name = [1]
}

resource "aws_cloudwatch_log_stream" "main_stream" {
  name           = [2]
  log_group_name = [3]
}
Drag options to blanks, or click blank then click option'
A"MainLogGroup"
B"MainStream"
Caws_cloudwatch_log_group.main_logs.name
D"MainLogStream"
Attempts:
3 left
💡 Hint
Common Mistakes
Quoting the resource reference for log_group_name.
Mixing up log stream and log group names.