aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
129 lines (128 loc) • 4.42 kB
TypeScript
import { Construct, IConstruct } from 'constructs';
import { IAspect } from './aspect';
import { ITaggable, ITaggableV2 } from './tag-manager';
/**
* Properties for a tag
*/
export interface TagProps {
/**
* Whether the tag should be applied to instances in an AutoScalingGroup
*
* @default true
*/
readonly applyToLaunchedInstances?: boolean;
/**
* An array of Resource Types that will not receive this tag
*
* An empty array will allow this tag to be applied to all resources. A
* non-empty array will apply this tag only if the Resource type is not in
* this array.
*
* @default []
*/
readonly excludeResourceTypes?: string[];
/**
* An array of Resource Types that will receive this tag
*
* An empty array will match any Resource. A non-empty array will apply this
* tag only to Resource types that are included in this array.
* @default []
*/
readonly includeResourceTypes?: string[];
/**
* Priority of the tag operation
*
* Higher or equal priority tags will take precedence.
*
* Setting priority will enable the user to control tags when they need to not
* follow the default precedence pattern of last applied and closest to the
* construct in the tree.
*
* @default
*
* Default priorities:
*
* - 100 for `SetTag`
* - 200 for `RemoveTag`
* - 50 for tags added directly to CloudFormation resources
*
*/
readonly priority?: number;
}
/**
* The common functionality for Tag and Remove Tag Aspects
*/
declare abstract class TagBase implements IAspect {
/**
* The string key for the tag
*/
readonly key: string;
protected readonly props: TagProps;
constructor(key: string, props?: TagProps);
visit(construct: IConstruct): void;
protected abstract applyTag(resource: ITaggable): void;
protected abstract applyTagV2(resource: ITaggableV2): void;
}
/**
* The Tag Aspect will handle adding a tag to this node and cascading tags to children
*/
export declare class Tag extends TagBase {
/**
* The string value of the tag
*/
readonly value: string;
private readonly defaultPriority;
constructor(key: string, value: string, props?: TagProps);
protected applyTag(resource: ITaggable): void;
protected applyTagV2(resource: ITaggableV2): void;
private applyManager;
}
/**
* Manages AWS tags for all resources within a construct scope.
*/
export declare class Tags {
private readonly scope;
/**
* Returns the tags API for this scope.
* @param scope The scope
*/
static of(scope: IConstruct): Tags;
private readonly explicitStackTags;
private constructor();
/**
* Add tags to the node of a construct and all its the taggable children
*
* ## Tagging and CloudFormation Stacks
*
* If the feature flag `@aws-cdk/core:explicitStackTags` is set to `true`
* (recommended modern behavior), Stacks will not automatically be tagged.
* Stack tags should be configured on Stacks directly (preferred), or
* you must explicitly include the resource type `aws:cdk:stack` in the
* `includeResourceTypes` array.
*
* If the feature flag is set to `false` (legacy behavior) then both Stacks
* and resources in the indicated scope will both be tagged by default, which
* leads to tags being applied twice (once in the template, and then once
* again automatically by CloudFormation as part of the stack deployment).
* That behavior leads to loss of control as `excludeResourceTypes` will
* prevent tags from appearing in the template, but they will still be
* applied to the Stack and hence CloudFormation will still apply them
* to the resource.
*/
add(key: string, value: string, props?: TagProps): void;
/**
* remove tags to the node of a construct and all its the taggable children
*/
remove(key: string, props?: TagProps): void;
}
/**
* The RemoveTag Aspect will handle removing tags from this node and children
*/
export declare class RemoveTag extends TagBase {
private readonly defaultPriority;
constructor(key: string, props?: TagProps);
protected applyTag(resource: ITaggable): void;
protected applyTagV2(resource: ITaggableV2): void;
private applyManager;
}
export {};