-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
feat: new aws_ecs_clusters datasource #40638
Merged
Merged
+164
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Community NoteVoting for Prioritization
For Submitters
|
github-actions
bot
added
documentation
Introduces or discusses updates to documentation.
tests
PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
service/ecs
Issues and PRs that pertain to the ecs service.
generators
Relates to code generators.
needs-triage
Waiting for first response or review from a maintainer.
labels
Dec 19, 2024
taufort
force-pushed
the
f-aws_ecs_clusters
branch
3 times, most recently
from
December 20, 2024 09:06
eb20081
to
915cb14
Compare
This datasource aims at getting all ECS clusters ARNs associated with an account.
taufort
force-pushed
the
f-aws_ecs_clusters
branch
from
December 20, 2024 13:33
915cb14
to
c53ff20
Compare
ewbankkit
added
new-data-source
Introduces a new data source.
and removed
needs-triage
Waiting for first response or review from a maintainer.
labels
Dec 23, 2024
ewbankkit
approved these changes
Dec 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀.
% make testacc TESTARGS='-run=TestAccECSClustersDataSource_' PKG=ecs
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/ecs/... -v -count 1 -parallel 20 -run=TestAccECSClustersDataSource_ -timeout 360m
2024/12/23 12:14:32 Initializing Terraform AWS Provider...
=== RUN TestAccECSClustersDataSource_basic
=== PAUSE TestAccECSClustersDataSource_basic
=== CONT TestAccECSClustersDataSource_basic
--- PASS: TestAccECSClustersDataSource_basic (22.21s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ecs 27.765s
github-actions
bot
added
the
prioritized
Part of the maintainer teams immediate focus. To be addressed within the current quarter.
label
Dec 23, 2024
nam054
approved these changes
Dec 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@taufort Thanks for the contribution 🎉 👏. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
documentation
Introduces or discusses updates to documentation.
generators
Relates to code generators.
new-data-source
Introduces a new data source.
prioritized
Part of the maintainer teams immediate focus. To be addressed within the current quarter.
service/ecs
Issues and PRs that pertain to the ecs service.
tests
PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This datasource aims at getting all ECS clusters ARNs associated with an AWS account. It can be useful to get ECS clusters in case you don't know their names (in that case, the existing datasource aws_ecs_cluster won't be much help - see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecs_cluster).
I was trying to set up centralized VPC flow logs in an AWS organization to send all flow logs to one common S3 bucket. On some AWS accounts in this organization, ECS clusters may exist or not. In case ECS clusters exist, I wanted to have ECS flow logs fields sent to the bucket (the ECS fields can be found here: https://docs.aws.amazon.com/vpc/latest/userguide/flow-log-records.html#flow-logs-fields). But to have those ECS fields in the flow logs, at least one ECS cluster must exist on the AWS account, else the Flow log cannot be created.
So, I came up with a workaround using a
null_resource
and alocal-exec
provisioner (using AWS CLI commands in it to get the list of ECS Clusters in the account) in order to be able to switch between 2 VPC flow logs format in case an ECS cluster exists on an AWS account. This way, I'm able to have ECS fields added in the flow log with the same code base as when no ECS cluster exists on the AWS account.This new datasource will help me get rid of this workaround which is clearly not ideal.
Relations
I did not find a ticket related to the creation of this datasource.
Output from Acceptance Testing