How to target all existing resources with a tag based filter

You want to select all existing resources at once with a tag based filter, for example to stop all EC2 instances nightly with the Amazon EC2 Instance task.

Step-by-step guide

You need to specify an appropriate tag based resource filter in JSON format (insert fragments from the inline Examples dialog to get started):

  1. Add an Amazon EC2 Instance task and select the Stop Instance(s) action.

  2. Select the desired AWS region and AWS security credentials as usual.

  3. Click on the Examples button and select the Tag (key only) example filter declaration.

  4. Replace the "Environment" sample filter value for the filter "tag-key" with "Name" so that the resulting filter declaration looks as follows:

    [ { "Name": "tag-key", "Values": ["Name"] } ]

    Alternatively, you can select the Tag (key and value) example filter declaration with a filter "tag:Name" and a wildcard value "*" as follows:

    [ { "Name": "tag:Name", "Values": ["*"] } ]
  5. Save the task.

  6. Due to "Name" being a default tag available for every resource, when you run the task, it will target all EC2 instances in this region, no matter what their actual name is.

Prevent failing builds in regions without resources

You can also check Don't fail for empty filter result to prevent the task failing if no matching resources are found.

Related articles



[  {    "Name": "tag:Name",    "Values": ["*"]  }]

Atlassian®, Atlassian Bamboo®, Bitbucket®, Atlassian Crowd®, Confluence®, Jira®, Jira Service Management™, Opsgenie®, and Statuspage™ are registered trademarks of Atlassian.
Amazon Web Services™, AWS™ and the “Powered by Amazon Web Services” logo are trademarks of Amazon.com, Inc. or its affiliates in the United States and/or other countries.

Utoolity® is a registered trademark of Utoolity GmbH.
© 2024 Utoolity GmbH. All rights reserved.