CfnGroup
- class aws_cdk.aws_resourcegroups.CfnGroup(scope, id, *, name, configuration=None, description=None, resource_query=None, resources=None, tags=None)
Bases:
CfnResource
A CloudFormation
AWS::ResourceGroups::Group
.Creates a resource group with the specified name and description. You can optionally include either a resource query or a service configuration. For more information about constructing a resource query, see Build queries and groups in AWS Resource Groups in the AWS Resource Groups User Guide . For more information about service-linked groups and service configurations, see Service configurations for Resource Groups .
Minimum permissions
To run this command, you must have the following permissions:
resource-groups:CreateGroup
- CloudformationResource:
AWS::ResourceGroups::Group
- Link:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-resourcegroups-group.html
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_resourcegroups as resourcegroups cfn_group = resourcegroups.CfnGroup(self, "MyCfnGroup", name="name", # the properties below are optional configuration=[resourcegroups.CfnGroup.ConfigurationItemProperty( parameters=[resourcegroups.CfnGroup.ConfigurationParameterProperty( name="name", values=["values"] )], type="type" )], description="description", resource_query=resourcegroups.CfnGroup.ResourceQueryProperty( query=resourcegroups.CfnGroup.QueryProperty( resource_type_filters=["resourceTypeFilters"], stack_identifier="stackIdentifier", tag_filters=[resourcegroups.CfnGroup.TagFilterProperty( key="key", values=["values"] )] ), type="type" ), resources=["resources"], tags=[CfnTag( key="key", value="value" )] )
Create a new
AWS::ResourceGroups::Group
.- Parameters:
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
name (
str
) – The name of a resource group. The name must be unique within the AWS Region in which you create the resource. To create multiple resource groups based on the same CloudFormation stack, you must generate unique names for each.configuration (
Union
[IResolvable
,Sequence
[Union
[ConfigurationItemProperty
,Dict
[str
,Any
],IResolvable
]],None
]) –The service configuration currently associated with the resource group and in effect for the members of the resource group. A
Configuration
consists of one or moreConfigurationItem
entries. For information about service configurations for resource groups and how to construct them, see Service configurations for resource groups in the AWS Resource Groups User Guide . .. epigraph:: You can include either aConfiguration
or aResourceQuery
, but not both.description (
Optional
[str
]) – The description of the resource group.resource_query (
Union
[IResolvable
,ResourceQueryProperty
,Dict
[str
,Any
],None
]) –The resource query structure that is used to dynamically determine which AWS resources are members of the associated resource group. For more information about queries and how to construct them, see Build queries and groups in AWS Resource Groups in the AWS Resource Groups User Guide .. epigraph:: - You can include either a
ResourceQuery
or aConfiguration
, but not both. - You can specify the group’s membership either by using aResourceQuery
or by using a list ofResources
, but not both.resources (
Optional
[Sequence
[str
]]) – A list of the Amazon Resource Names (ARNs) of AWS resources that you want to add to the specified group. .. epigraph:: - You can specify the group membership either by using a list ofResources
or by using aResourceQuery
, but not both. - You can include aResources
property only if you also specify aConfiguration
property.tags (
Optional
[Sequence
[Union
[CfnTag
,Dict
[str
,Any
]]]]) – The tag key and value pairs that are attached to the resource group.
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined)
.- Parameters:
path (
str
) – The path of the value to delete.- Return type:
None
- add_depends_on(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource
) –- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –value (
Any
) –
- See:
- Return type:
None
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
with “Properties.” (i.e.Properties.TopicName
).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.
in the property name, prefix with a\
. In most programming languages you will need to write this as"\\."
because the\
itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str
) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters:
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
Optional
[RemovalPolicy
]) –apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type:
None
- get_att(attribute_name)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn
), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str
) – The name of the attribute.- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –- See:
- Return type:
Any
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector
) –tree inspector to collect and process attributes.
- Return type:
None
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::ResourceGroups::Group'
- attr_arn
The ARN of the new resource group.
- CloudformationAttribute:
Arn
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- configuration
The service configuration currently associated with the resource group and in effect for the members of the resource group.
A
Configuration
consists of one or moreConfigurationItem
entries. For information about service configurations for resource groups and how to construct them, see Service configurations for resource groups in the AWS Resource Groups User Guide . .. epigraph:You can include either a ``Configuration`` or a ``ResourceQuery`` , but not both.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- description
The description of the resource group.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- name
The name of a resource group.
The name must be unique within the AWS Region in which you create the resource. To create multiple resource groups based on the same CloudFormation stack, you must generate unique names for each.
- node
The construct tree node associated with this construct.
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }
for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref })
.
- resource_query
The resource query structure that is used to dynamically determine which AWS resources are members of the associated resource group.
For more information about queries and how to construct them, see Build queries and groups in AWS Resource Groups in the AWS Resource Groups User Guide .. epigraph:
- You can include either a ``ResourceQuery`` or a ``Configuration`` , but not both. - You can specify the group's membership either by using a ``ResourceQuery`` or by using a list of ``Resources`` , but not both.
- resources
A list of the Amazon Resource Names (ARNs) of AWS resources that you want to add to the specified group.
You can specify the group membership either by using a list of
Resources
or by using aResourceQuery
, but not both.You can include a
Resources
property only if you also specify aConfiguration
property.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- tags
The tag key and value pairs that are attached to the resource group.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(construct)
Check whether the given construct is a CfnResource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool
ConfigurationItemProperty
- class CfnGroup.ConfigurationItemProperty(*, parameters=None, type=None)
Bases:
object
One of the items in the service configuration assigned to a resource group.
A service configuration can consist of one or more items. For details service configurations and how to construct them, see Service configurations for resource groups in the AWS Resource Groups User Guide .
- Parameters:
parameters (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,ConfigurationParameterProperty
,Dict
[str
,Any
]]],None
]) – A collection of parameters for this configuration item. For the list of parameters that you can use with each configuration itemType
, see Supported resource types and parameters in the AWS Resource Groups User Guide .type (
Optional
[str
]) –Specifies the type of configuration item. Each item must have a unique value for type. For the list of the types that you can specify for a configuration item, see Supported resource types and parameters in the AWS Resource Groups User Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_resourcegroups as resourcegroups configuration_item_property = resourcegroups.CfnGroup.ConfigurationItemProperty( parameters=[resourcegroups.CfnGroup.ConfigurationParameterProperty( name="name", values=["values"] )], type="type" )
Attributes
- parameters
A collection of parameters for this configuration item.
For the list of parameters that you can use with each configuration item
Type
, see Supported resource types and parameters in the AWS Resource Groups User Guide .
- type
Specifies the type of configuration item.
Each item must have a unique value for type. For the list of the types that you can specify for a configuration item, see Supported resource types and parameters in the AWS Resource Groups User Guide .
ConfigurationParameterProperty
- class CfnGroup.ConfigurationParameterProperty(*, name=None, values=None)
Bases:
object
One parameter for a group configuration item.
For details about service configurations and how to construct them, see Service configurations for resource groups in the AWS Resource Groups User Guide .
- Parameters:
name (
Optional
[str
]) –The name of the group configuration parameter. For the list of parameters that you can use with each configuration item type, see Supported resource types and parameters in the AWS Resource Groups User Guide .
values (
Optional
[Sequence
[str
]]) –The value or values to be used for the specified parameter. For the list of values you can use with each parameter, see Supported resource types and parameters .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_resourcegroups as resourcegroups configuration_parameter_property = resourcegroups.CfnGroup.ConfigurationParameterProperty( name="name", values=["values"] )
Attributes
- name
The name of the group configuration parameter.
For the list of parameters that you can use with each configuration item type, see Supported resource types and parameters in the AWS Resource Groups User Guide .
- values
The value or values to be used for the specified parameter.
For the list of values you can use with each parameter, see Supported resource types and parameters .
QueryProperty
- class CfnGroup.QueryProperty(*, resource_type_filters=None, stack_identifier=None, tag_filters=None)
Bases:
object
Specifies details within a
ResourceQuery
structure that determines the membership of the resource group.The contents required in the
Query
structure are determined by theType
property of the containingResourceQuery
structure.- Parameters:
resource_type_filters (
Optional
[Sequence
[str
]]) – Specifies limits to the types of resources that can be included in the resource group. For example, ifResourceTypeFilters
is["AWS::EC2::Instance", "AWS::DynamoDB::Table"]
, only EC2 instances or DynamoDB tables can be members of this resource group. The default value is["AWS::AllSupported"]
.stack_identifier (
Optional
[str
]) – Specifies the ARN of a CloudFormation stack. All supported resources of the CloudFormation stack are members of the resource group. If you don’t specify an ARN, this parameter defaults to the current stack that you are defining, which means that all the resources of the current stack are grouped. You can specify a value forStackIdentifier
only when theResourceQuery.Type
property isCLOUDFORMATION_STACK_1_0.
tag_filters (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,TagFilterProperty
,Dict
[str
,Any
]]],None
]) – A list of key-value pair objects that limit which resources can be members of the resource group. This property is required when theResourceQuery.Type
property isTAG_FILTERS_1_0
. A resource must have a tag that matches every filter that is provided in theTagFilters
list.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_resourcegroups as resourcegroups query_property = resourcegroups.CfnGroup.QueryProperty( resource_type_filters=["resourceTypeFilters"], stack_identifier="stackIdentifier", tag_filters=[resourcegroups.CfnGroup.TagFilterProperty( key="key", values=["values"] )] )
Attributes
- resource_type_filters
Specifies limits to the types of resources that can be included in the resource group.
For example, if
ResourceTypeFilters
is["AWS::EC2::Instance", "AWS::DynamoDB::Table"]
, only EC2 instances or DynamoDB tables can be members of this resource group. The default value is["AWS::AllSupported"]
.
- stack_identifier
Specifies the ARN of a CloudFormation stack.
All supported resources of the CloudFormation stack are members of the resource group. If you don’t specify an ARN, this parameter defaults to the current stack that you are defining, which means that all the resources of the current stack are grouped.
You can specify a value for
StackIdentifier
only when theResourceQuery.Type
property isCLOUDFORMATION_STACK_1_0.
- tag_filters
A list of key-value pair objects that limit which resources can be members of the resource group.
This property is required when the
ResourceQuery.Type
property isTAG_FILTERS_1_0
.A resource must have a tag that matches every filter that is provided in the
TagFilters
list.
ResourceQueryProperty
- class CfnGroup.ResourceQueryProperty(*, query=None, type=None)
Bases:
object
The query used to dynamically define the members of a group.
For more information about how to construct a query, see Build queries and groups in AWS Resource Groups .
- Parameters:
query (
Union
[IResolvable
,QueryProperty
,Dict
[str
,Any
],None
]) – The query that defines the membership of the group. This is a structure with properties that depend on theType
. TheQuery
structure must be included in the following scenarios: - When theType
isTAG_FILTERS_1_0
, you must specify aQuery
structure that contains aTagFilters
list of tags. Resources with tags that match those in theTagFilter
list become members of the resource group. - When theType
isCLOUDFORMATION_STACK_1_0
then this field is required only when you must specify a CloudFormation stack other than the one you are defining. To do this, theQuery
structure must contain theStackIdentifier
property. If you don’t specify either aQuery
structure or aStackIdentifier
within thatQuery
, then it defaults to the CloudFormation stack that you’re currently constructing.type (
Optional
[str
]) – Specifies the type of resource query that determines this group’s membership. There are two valid query types:. -TAG_FILTERS_1_0
indicates that the group is a tag-based group. To complete the group membership, you must include theTagFilters
property to specify the tag filters to use in the query. -CLOUDFORMATION_STACK_1_0
, the default, indicates that the group is a CloudFormation stack-based group. Group membership is based on the CloudFormation stack. You must specify theStackIdentifier
property in the query to define which stack to associate the group with, or leave it empty to default to the stack where the group is defined.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_resourcegroups as resourcegroups resource_query_property = resourcegroups.CfnGroup.ResourceQueryProperty( query=resourcegroups.CfnGroup.QueryProperty( resource_type_filters=["resourceTypeFilters"], stack_identifier="stackIdentifier", tag_filters=[resourcegroups.CfnGroup.TagFilterProperty( key="key", values=["values"] )] ), type="type" )
Attributes
- query
The query that defines the membership of the group.
This is a structure with properties that depend on the
Type
.The
Query
structure must be included in the following scenarios:When the
Type
isTAG_FILTERS_1_0
, you must specify aQuery
structure that contains aTagFilters
list of tags. Resources with tags that match those in theTagFilter
list become members of the resource group.When the
Type
isCLOUDFORMATION_STACK_1_0
then this field is required only when you must specify a CloudFormation stack other than the one you are defining. To do this, theQuery
structure must contain theStackIdentifier
property. If you don’t specify either aQuery
structure or aStackIdentifier
within thatQuery
, then it defaults to the CloudFormation stack that you’re currently constructing.
- type
.
TAG_FILTERS_1_0
indicates that the group is a tag-based group. To complete the group membership, you must include theTagFilters
property to specify the tag filters to use in the query.CLOUDFORMATION_STACK_1_0
, the default, indicates that the group is a CloudFormation stack-based group. Group membership is based on the CloudFormation stack. You must specify theStackIdentifier
property in the query to define which stack to associate the group with, or leave it empty to default to the stack where the group is defined.
- Link:
- Type:
Specifies the type of resource query that determines this group’s membership. There are two valid query types
TagFilterProperty
- class CfnGroup.TagFilterProperty(*, key=None, values=None)
Bases:
object
Specifies a single tag key and optional values that you can use to specify membership in a tag-based group.
An AWS resource that doesn’t have a matching tag key and value is rejected as a member of the group.
A
TagFilter
object includes two properties:Key
(a string) andValues
(a list of strings). Only resources in the account that are tagged with a matching key-value pair are members of the group. TheValues
property ofTagFilter
is optional, but specifying it narrows the query results.As an example, suppose the
TagFilters
string is[{"Key": "Stage", "Values": ["Test", "Beta"]}, {"Key": "Storage"}]
. In this case, only resources with all of the following tags are members of the group:Stage
tag key with a value of eitherTest
orBeta
Storage
tag key with any value
- Parameters:
key (
Optional
[str
]) – A string that defines a tag key. Only resources in the account that are tagged with a specified tag key are members of the tag-based resource group. This field is required when theResourceQuery
structure’sType
property isTAG_FILTERS_1_0
. You must specify at least one tag key.values (
Optional
[Sequence
[str
]]) – A list of tag values that can be included in the tag-based resource group. This is optional. If you don’t specify a value or values for a key, then an AWS resource with any value for that key is a member.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_resourcegroups as resourcegroups tag_filter_property = resourcegroups.CfnGroup.TagFilterProperty( key="key", values=["values"] )
Attributes
- key
A string that defines a tag key.
Only resources in the account that are tagged with a specified tag key are members of the tag-based resource group.
This field is required when the
ResourceQuery
structure’sType
property isTAG_FILTERS_1_0
. You must specify at least one tag key.
- values
A list of tag values that can be included in the tag-based resource group.
This is optional. If you don’t specify a value or values for a key, then an AWS resource with any value for that key is a member.