我想在 terraform 中访问我的 AWS 账户 ID。aws_caller_identity我可以根据文档找到它。那么我如何使用我创建的变量呢?在下面的情况下,我尝试在 S3 存储桶名称中使用它:
data "aws_caller_identity" "current" {}
output "account_id" {
value = data.aws_caller_identity.current.account_id
}
resource "aws_s3_bucket" "test-bucket" {
bucket = "test-bucket-${account_id}"
}
Run Code Online (Sandbox Code Playgroud)
尝试以这种方式使用account_id变量会给我带来错误,A reference to a resource type must be followed by at least one attribute access, specifying the resource name.我希望我没有正确调用它?
我想在 AWS CloudWatch Logs Insights 中创建包含两行的折线图。一条线代表移动用户和其他桌面用户,显示每组用户的成功率。
这是我正在使用的代码:
| fields
properties.device as device,
properties.success as success
| stats avg(success) by device, bin(1hour)
Run Code Online (Sandbox Code Playgroud)
这个查询的结果看起来很有希望。如您所见,结果包括设备类型、时间戳和要绘制在折线图上的浮点数:
# device bin(1hour) avg(success)
1 desktop 2023-02-01T10:00:00.000 0.6129
2 mobile 2023-02-01T10:00:00.000 0.7453
3 desktop 2023-02-01T09:00:00.000 0.5578
4 mobile 2023-02-01T09:00:00.000 0.6082
Run Code Online (Sandbox Code Playgroud)
但是,“可视化”选项卡向我显示了此错误:
The data is not suitable for a line chart.
Try a bar chart, or group your result by bin function.
Run Code Online (Sandbox Code Playgroud)
我认为 Logs Insights 对我重叠的时间戳感到困惑。它不知道我想要一个移动数据的时间序列和另一个桌面数据的时间序列。要按字段分组并按时间分组,我似乎正在使用带有两个参数的单个操作来执行标准操作by。但它还不足以创建折线图。
有没有更好的方法来构建我的查询以使 CloudWatch 相信我正在尝试做的事情?
visualization group-by amazon-cloudwatch amazon-cloudwatchlogs aws-cloudwatch-log-insights