cloudposse / terraform-aws-cloudwatch-flow-logs

Terraform module for enabling flow logs for vpc and subnets.

Home Page:https://cloudposse.com/accelerate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Must use splat syntax to access X, because it has "count" set

slmingol opened this issue · comments

With the following module setup I'm getting a failure:

Warning: output "log_group_arn": must use splat syntax to access aws_cloudwatch_log_group.default attribute "arn", because it has "count" set; use aws_cloudwatch_log_group.default.*.arn to obtain a list of the attributes across all instances

Warning: output "vpc_flow_id": must use splat syntax to access aws_flow_log.vpc attribute "id", because it has "count" set; use aws_flow_log.vpc.*.id to obtain a list of the attributes across all instances

Warning: output "kinesis_id": must use splat syntax to access aws_kinesis_stream.default attribute "id", because it has "count" set; use aws_kinesis_stream.default.*.id to obtain a list of the attributes across all instances

Warning: output "kinesis_name": must use splat syntax to access aws_kinesis_stream.default attribute "name", because it has "count" set; use aws_kinesis_stream.default.*.name to obtain a list of the attributes across all instances

Warning: output "kinesis_shard_count": must use splat syntax to access aws_kinesis_stream.default attribute "shard_count", because it has "count" set; use aws_kinesis_stream.default.*.shard_count to obtain a list of the attributes across all instances

Warning: output "kinesis_arn": must use splat syntax to access aws_kinesis_stream.default attribute "arn", because it has "count" set; use aws_kinesis_stream.default.*.arn to obtain a list of the attributes across all instances

If I follow the suggestions for the above it then seems to work.

Here's my flow_logs module:

module "flow_logs" {
  source    									= "git::https://github.com/cloudposse/terraform-aws-cloudwatch-flow-logs.git?ref=master"
  vpc_id    									= "${var.vpc_id}"
  namespace 									= "${var.ns}"
  stage     									= "${var.env}"
}

If I update the outputs.tf for flog_logs like so it then appears to work:

output "log_group_arn" {
  value       = "${aws_cloudwatch_log_group.default.*.arn}"
  description = "ARN of the log group"
}

output "vpc_flow_id" {
  value       = "${aws_flow_log.vpc.*.id}"
  description = "Flow Log IDs of VPCs"
}

output "subnet_flow_ids" {
  value       = "${aws_flow_log.subnets.*.id}"
  description = "Flow Log IDs of subnets"
}

output "eni_flow_ids" {
  value       = "${aws_flow_log.eni.*.id}"
  description = "Flow Log IDs of ENIs"
}

output "kinesis_id" {
  value       = "${aws_kinesis_stream.default.*.id}"
  description = "Stream ID"
}

output "kinesis_name" {
  value       = "${aws_kinesis_stream.default.*.name}"
  description = "Stream name"
}

output "kinesis_shard_count" {
  value       = "${aws_kinesis_stream.default.*.shard_count}"
  description = "Count of Shards for Stream"
}

output "kinesis_arn" {
  value       = "${aws_kinesis_stream.default.*.arn}"
  description = "ARN of Stream"
}

Also "log_group_name": [DEPRECATED] use 'log_destination' argument instead

Any update on this? This is affecting us as well.

@ChrisMcKee @nema-sigsci
that was addressed in #7, but waiting on @slmingol to address the comments.
If he could not get to it today, we'll open another PR with the fix tomorrow.

BTW, we should use splat+join pattern for all resources with counts.

So instead of
value = "${aws_kinesis_stream.default.*.name}"

we should use
value = "${join("", aws_kinesis_stream.default.*.name)}"

since when enabled=false, it should get an empty string (otherwise it could fail in some cases)

@nema-sigsci please ping me tomorrow so I don't forget to get to it

@nema-sigsci please ping me tomorrow so I don't forget to get to it

Ping :)