-
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
Conversation
Community NoteVoting for Prioritization
For Submitters
|
eb20081
to
915cb14
Compare
This datasource aims at getting all ECS clusters ARNs associated with an account.
915cb14
to
c53ff20
Compare
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
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 🎉 👏. |
This functionality has been released in v5.83.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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