UNPKG

3.66 kBTypeScriptView Raw
1import { IAspect } from './aspect';
2import { Construct, IConstruct } from './construct-compat';
3import { ITaggable } from './tag-manager';
4/**
5 * Properties for a tag
6 */
7export interface TagProps {
8 /**
9 * Whether the tag should be applied to instances in an AutoScalingGroup
10 *
11 * @default true
12 */
13 readonly applyToLaunchedInstances?: boolean;
14 /**
15 * An array of Resource Types that will not receive this tag
16 *
17 * An empty array will allow this tag to be applied to all resources. A
18 * non-empty array will apply this tag only if the Resource type is not in
19 * this array.
20 * @default []
21 */
22 readonly excludeResourceTypes?: string[];
23 /**
24 * An array of Resource Types that will receive this tag
25 *
26 * An empty array will match any Resource. A non-empty array will apply this
27 * tag only to Resource types that are included in this array.
28 * @default []
29 */
30 readonly includeResourceTypes?: string[];
31 /**
32 * Priority of the tag operation
33 *
34 * Higher or equal priority tags will take precedence.
35 *
36 * Setting priority will enable the user to control tags when they need to not
37 * follow the default precedence pattern of last applied and closest to the
38 * construct in the tree.
39 *
40 * @default
41 *
42 * Default priorities:
43 *
44 * - 100 for {@link SetTag}
45 * - 200 for {@link RemoveTag}
46 * - 50 for tags added directly to CloudFormation resources
47 *
48 */
49 readonly priority?: number;
50}
51/**
52 * The common functionality for Tag and Remove Tag Aspects
53 */
54declare abstract class TagBase implements IAspect {
55 /**
56 * The string key for the tag
57 */
58 readonly key: string;
59 protected readonly props: TagProps;
60 constructor(key: string, props?: TagProps);
61 visit(construct: IConstruct): void;
62 protected abstract applyTag(resource: ITaggable): void;
63}
64/**
65 * The Tag Aspect will handle adding a tag to this node and cascading tags to children
66 */
67export declare class Tag extends TagBase {
68 /**
69 * DEPRECATED: add tags to the node of a construct and all its the taggable children
70 *
71 * @deprecated use `Tags.of(scope).add()`
72 */
73 static add(scope: Construct, key: string, value: string, props?: TagProps): void;
74 /**
75 * DEPRECATED: remove tags to the node of a construct and all its the taggable children
76 *
77 * @deprecated use `Tags.of(scope).remove()`
78 */
79 static remove(scope: Construct, key: string, props?: TagProps): void;
80 /**
81 * The string value of the tag
82 */
83 readonly value: string;
84 private readonly defaultPriority;
85 constructor(key: string, value: string, props?: TagProps);
86 protected applyTag(resource: ITaggable): void;
87}
88/**
89 * Manages AWS tags for all resources within a construct scope.
90 */
91export declare class Tags {
92 private readonly scope;
93 /**
94 * Returns the tags API for this scope.
95 * @param scope The scope
96 */
97 static of(scope: IConstruct): Tags;
98 private constructor();
99 /**
100 * add tags to the node of a construct and all its the taggable children
101 */
102 add(key: string, value: string, props?: TagProps): void;
103 /**
104 * remove tags to the node of a construct and all its the taggable children
105 */
106 remove(key: string, props?: TagProps): void;
107}
108/**
109 * The RemoveTag Aspect will handle removing tags from this node and children
110 */
111export declare class RemoveTag extends TagBase {
112 private readonly defaultPriority;
113 constructor(key: string, props?: TagProps);
114 protected applyTag(resource: ITaggable): void;
115}
116export {};