Tags Class
Allows assertions on the tags associated with a synthesized CDK stack's manifest.
Stack tags are not part of the synthesized template, so can only be checked from the manifest in this manner.
| Source | assertions/lib/tags.ts |
|---|---|
| Type last changed |
Example
ts
const tags = Tags.fromStack(stack);
// using a default 'objectLike' Matcher
tags.hasValues({
'tag-name': 'tag-value',
});
// ... with Matchers embedded
tags.hasValues({
'tag-name': Match.stringLikeRegexp('value'),
});
// or another object Matcher at the top level
tags.hasValues(Match.objectEquals({
'tag-name': Match.anyValue(),
}));
python
tags = Tags.from_stack(stack)
# using a default 'objectLike' Matcher
tags.has_values({
"tag-name": "tag-value"
})
# ... with Matchers embedded
tags.has_values({
"tag-name": Match.string_like_regexp("value")
})
# or another object Matcher at the top level
tags.has_values(Match.object_equals({
"tag-name": Match.any_value()
}))
java
Tags tags = Tags.fromStack(stack);
// using a default 'objectLike' Matcher
tags.hasValues(Map.of(
"tag-name", "tag-value"));
// ... with Matchers embedded
tags.hasValues(Map.of(
"tag-name", Match.stringLikeRegexp("value")));
// or another object Matcher at the top level
tags.hasValues(Match.objectEquals(Map.of(
"tag-name", Match.anyValue())));
csharp
// Install: dotnet add package Amazon.CDK.Lib
var tags = Tags.FromStack(stack);
// using a default 'objectLike' Matcher
tags.HasValues(new Dictionary<string, string> {
{ "tag-name", "tag-value" }
});
// ... with Matchers embedded
tags.HasValues(new Dictionary<string, Matcher> {
{ "tag-name", Match.StringLikeRegexp("value") }
});
// or another object Matcher at the top level
tags.HasValues(Match.ObjectEquals(new Dictionary<string, object> {
{ "tag-name", Match.AnyValue() }
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
tags := awscdk.Tags_FromStack(stack)
// using a default 'objectLike' Matcher
tags.HasValues(map[string]*string{
"tag-name": jsii.String("tag-value"),
})
// ... with Matchers embedded
tags.HasValues(map[string]Matcher{
"tag-name": awscdk.Match_stringLikeRegexp(jsii.String("value")),
})
// or another object Matcher at the top level
tags.HasValues(awscdk.Match_ObjectEquals(map[string]interface{}{
"tag-name": awscdk.Match_anyValue(),
}))
Methods
all(): { [key: string]: string }def all(self, ) -> typing.Mapping[str, str]public Map<String, String> all()public IDictionary<string, string> All()func All() *map[string]*string #Get the tags associated with the manifest.
This will be an empty object if no tags were supplied.
returns
Returns: The tags associated with the stack's synthesized manifest.
fromStack(stack: Stack): Tags // chainable@staticmethod def from_stack(stack: Stack) -> Tagspublic static Tags fromStack(Stack stack)public static Tags FromStack(Stack stack)func FromStack(Stack Stack) Tags static #Find tags associated with a synthesized CDK `Stack`.
1 parameter
Parameters
stackstackstackstackStack— the CDK Stack to find tags on.
hasNone(): voiddef has_none(self, ) -> Nonepublic void hasNone()public void HasNone()func HasNone() #Assert that the there are no tags associated with the synthesized CDK Stack's manifest.
This is a convenience method over hasValues(Match.exact({})), and is present because the more obvious method of detecting no tags (Match.absent()) will not work. Manifests default the tag set to an empty object.
hasValues(tags: any): voiddef has_values(self, tags: Any) -> Nonepublic void hasValues(Object tags)public void HasValues(object tags)func HasValues(Tags interface{}) #Assert that the given Matcher or object matches the tags associated with the synthesized CDK Stack's manifest.
1 parameter
Parameters
tagstagstagstagsTags— the expected set of tags.