Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
slmingol opened this issue Feb 16, 2019 · 5 comments
Open

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

slmingol opened this issue Feb 16, 2019 · 5 comments

Comments

@slmingol
Copy link
Contributor

slmingol commented Feb 16, 2019

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"
}
@ChrisMcKee
Copy link

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

@ghost
Copy link

ghost commented Apr 3, 2019

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

@aknysh
Copy link
Member

aknysh commented Apr 3, 2019

@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)

@aknysh
Copy link
Member

aknysh commented Apr 3, 2019

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

@Prophecy67
Copy link

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

Ping :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants