CfnGroup
- class aws_cdk.aws_resourcegroups.CfnGroup(scope, id, *, name, configuration=None, description=None, resource_query=None, resources=None, tags=None)
Bases:
CfnResourceCreates 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
- See:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-resourcegroups-group.html
- CloudformationResource:
AWS::ResourceGroups::Group
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import 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" )] )
- Parameters:
scope (
Construct) – Scope in which this resource is defined.id (
str) – Construct identifier for this resource (unique in its scope).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[IResolvable,ConfigurationItemProperty,Dict[str,Any]]],None]) –The service configuration currently associated with the resource group and in effect for the members of the resource group. A
Configurationconsists of one or moreConfigurationItementries. 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 aConfigurationor 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
ResourceQueryor aConfiguration, but not both. - You can specify the group’s membership either by using aResourceQueryor 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 ofResourcesor by using aResourceQuery, but not both. - You can include aResourcesproperty only if you also specify aConfigurationproperty.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_dependency(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_depends_on(target)
(deprecated) Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
- Parameters:
target (
CfnResource)- Deprecated:
use addDependency
- Stability:
deprecated
- 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
addPropertyOverrideor prefixpathwith “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
valueargument toaddOverridewill 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 intermediate 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). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:- 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 resource, please consult that specific resource’s documentation.
- See:
- Return type:
None
- get_att(attribute_name, type_hint=None)
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.type_hint (
Optional[ResolutionTypeHint])
- 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
- obtain_dependencies()
Retrieves an array of resources this resource depends on.
This assembles dependencies on resources across stacks (including nested stacks) automatically.
- Return type:
List[Union[Stack,CfnResource]]
- obtain_resource_dependencies()
Get a shallow copy of dependencies between this resource and other resources in the same stack.
- Return type:
List[CfnResource]
- 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
- remove_dependency(target)
Indicates that this resource no longer depends on another resource.
This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
- Parameters:
target (
CfnResource)- Return type:
None
- replace_dependency(target, new_target)
Replaces one dependency with another.
- Parameters:
target (
CfnResource) – The dependency to replace.new_target (
CfnResource) – The new dependency to add.
- 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.
- 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.
- group_ref
A reference to a Group resource.
- 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.
- node
The tree node.
- 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.
- resources
A list of the Amazon Resource Names (ARNs) of AWS resources that you want to add to the specified group.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- tags
Tag Manager which manages the tags for this resource.
- tags_raw
The tag key and value pairs that are attached to the resource group.
Static Methods
- classmethod from_group_arn(scope, id, arn)
Creates a new IGroupRef from an ARN.
- classmethod from_group_name(scope, id, group_name)
Creates a new IGroupRef from a groupName.
- classmethod is_cfn_element(x)
Returns
trueif a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceofto 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(x)
Check whether the given object is a CfnResource.
- Parameters:
x (
Any)- Return type:
bool
- classmethod is_construct(x)
Checks if
xis a construct.Use this method instead of
instanceofto properly detectConstructinstances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the classConstructin each copy of theconstructslibrary is seen as a different class, and an instance of one class will not test asinstanceofthe other class.npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructslibrary can be accidentally installed, andinstanceofwill behave unpredictably. It is safest to avoid usinginstanceof, and using this type-testing method instead.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsConstruct.
ConfigurationItemProperty
- class CfnGroup.ConfigurationItemProperty(*, parameters=None, type=None)
Bases:
objectOne 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 .
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import 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:
objectOne 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 .
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import 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:
objectSpecifies details within a
ResourceQuerystructure that determines the membership of the resource group.The contents required in the
Querystructure are determined by theTypeproperty of the containingResourceQuerystructure.- Parameters:
resource_type_filters (
Optional[Sequence[str]]) – Specifies limits to the types of resources that can be included in the resource group. For example, ifResourceTypeFiltersis["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 forStackIdentifieronly when theResourceQuery.Typeproperty 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.Typeproperty isTAG_FILTERS_1_0. A resource must have a tag that matches every filter that is provided in theTagFilterslist.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import 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
ResourceTypeFiltersis["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
StackIdentifieronly when theResourceQuery.Typeproperty 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.Typeproperty isTAG_FILTERS_1_0.A resource must have a tag that matches every filter that is provided in the
TagFilterslist.
ResourceQueryProperty
- class CfnGroup.ResourceQueryProperty(*, query=None, type=None)
Bases:
objectThe 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. TheQuerystructure must be included in the following scenarios: - When theTypeisTAG_FILTERS_1_0, you must specify aQuerystructure that contains aTagFilterslist of tags. Resources with tags that match those in theTagFilterlist become members of the resource group. - When theTypeisCLOUDFORMATION_STACK_1_0then this field is required only when you must specify a CloudFormation stack other than the one you are defining. To do this, theQuerystructure must contain theStackIdentifierproperty. If you don’t specify either aQuerystructure or aStackIdentifierwithin 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_0indicates that the group is a tag-based group. To complete the group membership, you must include theTagFiltersproperty 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 theStackIdentifierproperty 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.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import 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
Querystructure must be included in the following scenarios:When the
TypeisTAG_FILTERS_1_0, you must specify aQuerystructure that contains aTagFilterslist of tags. Resources with tags that match those in theTagFilterlist become members of the resource group.When the
TypeisCLOUDFORMATION_STACK_1_0then this field is required only when you must specify a CloudFormation stack other than the one you are defining. To do this, theQuerystructure must contain theStackIdentifierproperty. If you don’t specify either aQuerystructure or aStackIdentifierwithin thatQuery, then it defaults to the CloudFormation stack that you’re currently constructing.
- type
.
TAG_FILTERS_1_0indicates that the group is a tag-based group. To complete the group membership, you must include theTagFiltersproperty 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 theStackIdentifierproperty 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.
- See:
- 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:
objectSpecifies 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
TagFilterobject 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. TheValuesproperty ofTagFilteris optional, but specifying it narrows the query results.As an example, suppose the
TagFiltersstring is[{"Key": "Stage", "Values": ["Test", "Beta"]}, {"Key": "Storage"}]. In this case, only resources with all of the following tags are members of the group:Stagetag key with a value of eitherTestorBetaStoragetag 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 theResourceQuerystructure’sTypeproperty 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.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import 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
ResourceQuerystructure’sTypeproperty 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.