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

fix: Event bus data source count conditional #101

Conversation

magreenbaum
Copy link
Member

Description

In several examples (api-gateway-event-source, with-archive, with-api-destination), any example where bus_name is known after apply (generated randomly in this case), there is an invalid count argument error:

 Error: Invalid count argument
│ 
│   on ../../main.tf line 59, in data "aws_cloudwatch_event_bus" "this":
│   59:   count = (var.create && var.create_bus) || (var.bus_name == "") ? 0 : 1
│ 
│ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work
│ around this, use the -target argument to first apply only the resources that the count depends on.
╵

We can prevent this by removing the || (var.bus_name == "") in the count conditional.
bus_name defaults to default and I'm not seeing a use case where bus_name would be set to an empty string without producing errors for other reasons.

Motivation and Context

Remediate invalid count argument error.

Breaking Changes

No.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

Copy link

github-actions bot commented Jan 5, 2024

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Jan 5, 2024
@magreenbaum
Copy link
Member Author

Unstale

@github-actions github-actions bot removed the stale label Jan 6, 2024
@antonbabenko antonbabenko merged commit ebe5963 into terraform-aws-modules:master Jan 12, 2024
15 checks passed
antonbabenko pushed a commit that referenced this pull request Jan 12, 2024
### [3.0.1](v3.0.0...v3.0.1) (2024-01-12)

### Bug Fixes

* Event bus data source count conditional ([#101](#101)) ([ebe5963](ebe5963))
@antonbabenko
Copy link
Member

This PR is included in version 3.0.1 🎉

@magreenbaum magreenbaum deleted the fix/event_bus_data_source branch January 13, 2024 00:34
Copy link

github-actions bot commented Mar 9, 2024

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants