1 | import { TagType } from './cfn-resource';
|
2 | import { IResolvable } from './resolvable';
|
3 | /**
|
4 | * Interface to implement tags.
|
5 | */
|
6 | export interface ITaggable {
|
7 | /**
|
8 | * TagManager to set, remove and format tags
|
9 | */
|
10 | readonly tags: TagManager;
|
11 | }
|
12 | /**
|
13 | * Options to configure TagManager behavior
|
14 | */
|
15 | export interface TagManagerOptions {
|
16 | /**
|
17 | * The name of the property in CloudFormation for these tags
|
18 | *
|
19 | * Normally this is `tags`, but Cognito UserPool uses UserPoolTags
|
20 | *
|
21 | * @default "tags"
|
22 | */
|
23 | readonly tagPropertyName?: string;
|
24 | }
|
25 | /**
|
26 | * TagManager facilitates a common implementation of tagging for Constructs
|
27 | *
|
28 | * Normally, you do not need to use this class, as the CloudFormation specification
|
29 | * will indicate which resources are taggable. However, sometimes you will need this
|
30 | * to make custom resources taggable. Used `tagManager.renderedTags` to obtain a
|
31 | * value that will resolve to the tags at synthesis time.
|
32 | *
|
33 | * @example
|
34 | * import * as cdk from '@aws-cdk/core';
|
35 | *
|
36 | * class MyConstruct extends cdk.Resource implements cdk.ITaggable {
|
37 | * public readonly tags = new cdk.TagManager(cdk.TagType.KEY_VALUE, 'Whatever::The::Type');
|
38 | *
|
39 | * constructor(scope: cdk.Construct, id: string) {
|
40 | * super(scope, id);
|
41 | *
|
42 | * new cdk.CfnResource(this, 'Resource', {
|
43 | * type: 'Whatever::The::Type',
|
44 | * properties: {
|
45 | * // ...
|
46 | * Tags: this.tags.renderedTags,
|
47 | * },
|
48 | * });
|
49 | * }
|
50 | * }
|
51 | *
|
52 | */
|
53 | export declare class TagManager {
|
54 | /**
|
55 | * Check whether the given construct is Taggable
|
56 | */
|
57 | static isTaggable(construct: any): construct is ITaggable;
|
58 | /**
|
59 | * The property name for tag values
|
60 | *
|
61 | * Normally this is `tags` but some resources choose a different name. Cognito
|
62 | * UserPool uses UserPoolTags
|
63 | */
|
64 | readonly tagPropertyName: string;
|
65 | /**
|
66 | * A lazy value that represents the rendered tags at synthesis time
|
67 | *
|
68 | * If you need to make a custom construct taggable, use the value of this
|
69 | * property to pass to the `tags` property of the underlying construct.
|
70 | */
|
71 | readonly renderedTags: IResolvable;
|
72 | private readonly tags;
|
73 | private readonly dynamicTags;
|
74 | private readonly priorities;
|
75 | private readonly tagFormatter;
|
76 | private readonly resourceTypeName;
|
77 | private readonly initialTagPriority;
|
78 | constructor(tagType: TagType, resourceTypeName: string, tagStructure?: any, options?: TagManagerOptions);
|
79 | /**
|
80 | * Adds the specified tag to the array of tags
|
81 | *
|
82 | */
|
83 | setTag(key: string, value: string, priority?: number, applyToLaunchedInstances?: boolean): void;
|
84 | /**
|
85 | * Removes the specified tag from the array if it exists
|
86 | *
|
87 | * @param key The tag to remove
|
88 | * @param priority The priority of the remove operation
|
89 | */
|
90 | removeTag(key: string, priority: number): void;
|
91 | /**
|
92 | * Renders tags into the proper format based on TagType
|
93 | *
|
94 | * This method will eagerly render the tags currently applied. In
|
95 | * most cases, you should be using `tagManager.renderedTags` instead,
|
96 | * which will return a `Lazy` value that will resolve to the correct
|
97 | * tags at synthesis time.
|
98 | */
|
99 | renderTags(): any;
|
100 | /**
|
101 | * Render the tags in a readable format
|
102 | */
|
103 | tagValues(): Record<string, string>;
|
104 | /**
|
105 | * Determine if the aspect applies here
|
106 | *
|
107 | * Looks at the include and exclude resourceTypeName arrays to determine if
|
108 | * the aspect applies here
|
109 | */
|
110 | applyTagAspectHere(include?: string[], exclude?: string[]): boolean;
|
111 | /**
|
112 | * Returns true if there are any tags defined
|
113 | */
|
114 | hasTags(): boolean;
|
115 | private _setTag;
|
116 | private get sortedTags();
|
117 | }
|