Class: AWSCDK::Tags
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::Tags
- Defined in:
- tags.rb
Overview
Manages AWS tags for all resources within a construct scope.
Class Method Summary collapse
- .jsii_overridable_methods ⇒ Object
-
.of(scope) ⇒ AWSCDK::Tags
Returns the tags API for this scope.
Instance Method Summary collapse
-
#add(key, value, props = nil) ⇒ void
Add tags to the node of a construct and all its the taggable children.
-
#initialize(*args) ⇒ Tags
constructor
A new instance of Tags.
-
#remove(key, props = nil) ⇒ void
remove tags to the node of a construct and all its the taggable children.
Constructor Details
#initialize(*args) ⇒ Tags
Returns a new instance of Tags.
8 9 10 |
# File 'tags.rb', line 8 def initialize(*args) raise NoMethodError, "aws-cdk-lib.Tags does not have a visible constructor; use the provided factory methods" end |
Class Method Details
.jsii_overridable_methods ⇒ Object
12 13 14 15 16 17 |
# File 'tags.rb', line 12 def self.jsii_overridable_methods { :add => { kind: :method, name: "add", is_optional: false }, :remove => { kind: :method, name: "remove", is_optional: false }, } end |
.of(scope) ⇒ AWSCDK::Tags
Returns the tags API for this scope.
23 24 25 26 |
# File 'tags.rb', line 23 def self.of(scope) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "scope") Jsii::Kernel.instance.call_static("aws-cdk-lib.Tags", "of", [scope]) end |
Instance Method Details
#add(key, value, props = nil) ⇒ void
This method returns an undefined value.
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
include_resource_types 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 exclude_resource_types 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.
51 52 53 54 55 56 57 |
# File 'tags.rb', line 51 def add(key, value, props = nil) Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key") Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "value") props = props.is_a?(Hash) ? ::AWSCDK::TagProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UYWdQcm9wcyJ9")), "props") unless props.nil? jsii_call_method("add", [key, value, props]) end |
#remove(key, props = nil) ⇒ void
This method returns an undefined value.
remove tags to the node of a construct and all its the taggable children.
64 65 66 67 68 69 |
# File 'tags.rb', line 64 def remove(key, props = nil) Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key") props = props.is_a?(Hash) ? ::AWSCDK::TagProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5UYWdQcm9wcyJ9")), "props") unless props.nil? jsii_call_method("remove", [key, props]) end |