Struct rusoto_resource_groups::ResourceQuery
source · [−]Expand description
The query that is used to define a resource group or a search for resources. A query specifies both a query type and a query string as a JSON object. See the examples section for example JSON strings.
The examples that follow are shown as standard JSON strings. If you include such a string as a parameter to the AWS CLI or an SDK API, you might need to 'escape' the string into a single line. For example, see the Quoting strings in the AWS CLI User Guide.
Example 1
The following generic example shows a resource query JSON string that includes only resources that meet the following criteria:
-
The resource type must be either
resource_type1
orresource_type2
. -
The resource must have a tag
Key1
with a value of eitherValueA
orValueB
. -
The resource must have a tag
Key2
with a value of eitherValueC
orValueD
.
{ "Type": "TAG_FILTERS_1_0", "Query": { "ResourceTypeFilters": [ "resource_type1", "resource_type2"], "TagFilters": [ { "Key": "Key1", "Values": ["ValueA","ValueB"] }, { "Key":"Key2", "Values":["ValueC","ValueD"] } ] } }
This has the equivalent "shortcut" syntax of the following:
{ "Type": "TAG_FILTERS_1_0", "Query": { "ResourceTypeFilters": [ "resource_type1", "resource_type2"], "TagFilters": [ { "Key1": ["ValueA","ValueB"] }, { "Key2": ["ValueC","ValueD"] } ] } }
Example 2
The following example shows a resource query JSON string that includes only Amazon EC2 instances that are tagged Stage
with a value of Test
.
{ "Type": "TAG_FILTERS_1_0", "Query": "{ "ResourceTypeFilters": "AWS::EC2::Instance", "TagFilters": { "Stage": "Test" } } }
Example 3
The following example shows a resource query JSON string that includes resource of any supported type as long as it is tagged Stage
with a value of Prod
.
{ "Type": "TAG_FILTERS_1_0", "Query": { "ResourceTypeFilters": "AWS::AllSupported", "TagFilters": { "Stage": "Prod" } } }
Example 4
The following example shows a resource query JSON string that includes only Amazon EC2 instances and Amazon S3 buckets that are part of the specified AWS CloudFormation stack.
{ "Type": "CLOUDFORMATION_STACK_1_0", "Query": { "ResourceTypeFilters": [ "AWS::EC2::Instance", "AWS::S3::Bucket" ], "StackIdentifier": "arn:aws:cloudformation:us-west-2:123456789012:stack/AWStestuseraccount/fb0d5000-aba8-00e8-aa9e-50d5cEXAMPLE" } }
Fields
query: String
The query that defines a group or a search.
type_: String
The type of the query. You can use the following values:
-
CLOUDFORMATIONSTACK10:
Specifies that theQuery
contains an ARN for a CloudFormation stack. -
TAGFILTERS10:
Specifies that theQuery
parameter contains a JSON string that represents a collection of simple tag filters for resource types and tags. The JSON string uses a syntax similar to theGetResources
operation, but uses only theResourceTypeFilters
andTagFilters
fields. If you specify more than one tag key, only resources that match all tag keys, and at least one value of each specified tag key, are returned in your query. If you specify more than one value for a tag key, a resource matches the filter if it has a tag key value that matches any of the specified values.For example, consider the following sample query for resources that have two tags,
Stage
andVersion
, with two values each:[{"Stage":["Test","Deploy"]},{"Version":["1","2"]}]
The results of this query could include the following.
-
An EC2 instance that has the following two tags:
{"Stage":"Deploy"}
, and{"Version":"2"}
-
An S3 bucket that has the following two tags:
{"Stage":"Test"}
, and{"Version":"1"}
The query would not include the following items in the results, however.
-
An EC2 instance that has only the following tag:
{"Stage":"Deploy"}
.The instance does not have all of the tag keys specified in the filter, so it is excluded from the results.
-
An RDS database that has the following two tags:
{"Stage":"Archived"}
and{"Version":"4"}
The database has all of the tag keys, but none of those keys has an associated value that matches at least one of the specified values in the filter.
-
Trait Implementations
sourceimpl Clone for ResourceQuery
impl Clone for ResourceQuery
sourcefn clone(&self) -> ResourceQuery
fn clone(&self) -> ResourceQuery
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ResourceQuery
impl Debug for ResourceQuery
sourceimpl Default for ResourceQuery
impl Default for ResourceQuery
sourcefn default() -> ResourceQuery
fn default() -> ResourceQuery
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for ResourceQuery
impl<'de> Deserialize<'de> for ResourceQuery
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl PartialEq<ResourceQuery> for ResourceQuery
impl PartialEq<ResourceQuery> for ResourceQuery
sourcefn eq(&self, other: &ResourceQuery) -> bool
fn eq(&self, other: &ResourceQuery) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ResourceQuery) -> bool
fn ne(&self, other: &ResourceQuery) -> bool
This method tests for !=
.
sourceimpl Serialize for ResourceQuery
impl Serialize for ResourceQuery
impl StructuralPartialEq for ResourceQuery
Auto Trait Implementations
impl RefUnwindSafe for ResourceQuery
impl Send for ResourceQuery
impl Sync for ResourceQuery
impl Unpin for ResourceQuery
impl UnwindSafe for ResourceQuery
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more