Module: AWSCDK::EC2::IVolume
Overview
An EBS Volume in AWS EC2.
Class Method Summary collapse
Instance Method Summary collapse
-
#apply_removal_policy(policy) ⇒ void
Apply the given removal policy to this resource.
-
#availability_zone ⇒ String
The availability zone that the EBS Volume is contained within (ex: us-west-2a).
-
#encryption_key ⇒ AWSCDK::KMS::IKey?
The customer-managed encryption key that is used to encrypt the Volume.
-
#env ⇒ AWSCDK::Interfaces::ResourceEnvironment
The environment this resource belongs to.
-
#grant_attach_volume(grantee, instances = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to attach this Volume to an instance.
-
#grant_attach_volume_by_resource_tag(grantee, constructs, tag_key_suffix = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to attach the Volume by a ResourceTag condition.
-
#grant_detach_volume(grantee, instances = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.
-
#grant_detach_volume_by_resource_tag(grantee, constructs, tag_key_suffix = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to detach the Volume by a ResourceTag condition.
-
#node ⇒ Constructs::Node
The tree node.
-
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
-
#volume_id ⇒ String
The EBS Volume's ID.
-
#volume_ref ⇒ AWSCDK::Interfaces::AWSEC2::VolumeReference
A reference to a Volume resource.
-
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Class Method Details
.jsii_overridable_methods ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'ec2/i_volume.rb', line 165 def self.jsii_overridable_methods { :node => { kind: :property, name: "node", is_optional: false }, :env => { kind: :property, name: "env", is_optional: false }, :stack => { kind: :property, name: "stack", is_optional: false }, :volume_ref => { kind: :property, name: "volumeRef", is_optional: false }, :availability_zone => { kind: :property, name: "availabilityZone", is_optional: false }, :volume_id => { kind: :property, name: "volumeId", is_optional: false }, :encryption_key => { kind: :property, name: "encryptionKey", is_optional: true }, :with => { kind: :method, name: "with", is_optional: false }, :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false }, :grant_attach_volume => { kind: :method, name: "grantAttachVolume", is_optional: false }, :grant_attach_volume_by_resource_tag => { kind: :method, name: "grantAttachVolumeByResourceTag", is_optional: false }, :grant_detach_volume => { kind: :method, name: "grantDetachVolume", is_optional: false }, :grant_detach_volume_by_resource_tag => { kind: :method, name: "grantDetachVolumeByResourceTag", is_optional: false }, } end |
Instance Method Details
#apply_removal_policy(policy) ⇒ void
This method returns an undefined value.
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
92 93 94 95 |
# File 'ec2/i_volume.rb', line 92 def apply_removal_policy(policy) Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy") jsii_call_method("applyRemovalPolicy", [policy]) end |
#availability_zone ⇒ String
The availability zone that the EBS Volume is contained within (ex: us-west-2a).
48 49 50 |
# File 'ec2/i_volume.rb', line 48 def availability_zone() jsii_get_property("availabilityZone") end |
#encryption_key ⇒ AWSCDK::KMS::IKey?
The customer-managed encryption key that is used to encrypt the Volume.
62 63 64 |
# File 'ec2/i_volume.rb', line 62 def encryption_key() jsii_get_property("encryptionKey") end |
#env ⇒ AWSCDK::Interfaces::ResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
27 28 29 |
# File 'ec2/i_volume.rb', line 27 def env() jsii_get_property("env") end |
#grant_attach_volume(grantee, instances = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to attach this Volume to an instance.
CAUTION: Granting an instance permission to attach to itself using this method will lead to
an unresolvable circular reference between the instance role and the instance.
Use IVolume.grantAttachVolumeToSelf to grant an instance permission to attach this
volume to itself.
107 108 109 110 111 |
# File 'ec2/i_volume.rb', line 107 def grant_attach_volume(grantee, instances = nil) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") Jsii::Type.check_type(instances, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmludGVyZmFjZXMuYXdzX2VjMi5JSW5zdGFuY2VSZWYifSwia2luZCI6ImFycmF5In19")), "instances") unless instances.nil? jsii_call_method("grantAttachVolume", [grantee, instances]) end |
#grant_attach_volume_by_resource_tag(grantee, constructs, tag_key_suffix = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to attach the Volume by a ResourceTag condition.
If you are looking to grant an Instance, AutoScalingGroup, EC2-Fleet, SpotFleet, ECS host, etc the ability to attach this volume to itself then this is the method you want to use.
This is implemented by adding a Tag with key VolumeGrantAttach-<suffix> to the given
constructs and this Volume, and then conditioning the Grant such that the grantee is only
given the ability to AttachVolume if both the Volume and the destination Instance have that
tag applied to them.
128 129 130 131 132 133 |
# File 'ec2/i_volume.rb', line 128 def grant_attach_volume_by_resource_tag(grantee, constructs, tag_key_suffix = nil) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") Jsii::Type.check_type(constructs, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImNvbnN0cnVjdHMuQ29uc3RydWN0In0sImtpbmQiOiJhcnJheSJ9fQ==")), "constructs") Jsii::Type.check_type(tag_key_suffix, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "tagKeySuffix") unless tag_key_suffix.nil? jsii_call_method("grantAttachVolumeByResourceTag", [grantee, constructs, tag_key_suffix]) end |
#grant_detach_volume(grantee, instances = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to detach this Volume from an instance CAUTION: Granting an instance permission to detach from itself using this method will lead to an unresolvable circular reference between the instance role and the instance.
Use IVolume.grantDetachVolumeFromSelf to grant an instance permission to detach this
volume from itself.
143 144 145 146 147 |
# File 'ec2/i_volume.rb', line 143 def grant_detach_volume(grantee, instances = nil) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") Jsii::Type.check_type(instances, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmludGVyZmFjZXMuYXdzX2VjMi5JSW5zdGFuY2VSZWYifSwia2luZCI6ImFycmF5In19")), "instances") unless instances.nil? jsii_call_method("grantDetachVolume", [grantee, instances]) end |
#grant_detach_volume_by_resource_tag(grantee, constructs, tag_key_suffix = nil) ⇒ AWSCDK::IAM::Grant
Grants permission to detach the Volume by a ResourceTag condition.
This is implemented via the same mechanism as IVolume.grantAttachVolumeByResourceTag,
and is subject to the same conditions.
158 159 160 161 162 163 |
# File 'ec2/i_volume.rb', line 158 def grant_detach_volume_by_resource_tag(grantee, constructs, tag_key_suffix = nil) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") Jsii::Type.check_type(constructs, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImNvbnN0cnVjdHMuQ29uc3RydWN0In0sImtpbmQiOiJhcnJheSJ9fQ==")), "constructs") Jsii::Type.check_type(tag_key_suffix, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "tagKeySuffix") unless tag_key_suffix.nil? jsii_call_method("grantDetachVolumeByResourceTag", [grantee, constructs, tag_key_suffix]) end |
#node ⇒ Constructs::Node
The tree node.
12 13 14 |
# File 'ec2/i_volume.rb', line 12 def node() jsii_get_property("node") end |
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
34 35 36 |
# File 'ec2/i_volume.rb', line 34 def stack() jsii_get_property("stack") end |
#volume_id ⇒ String
The EBS Volume's ID.
55 56 57 |
# File 'ec2/i_volume.rb', line 55 def volume_id() jsii_get_property("volumeId") end |
#volume_ref ⇒ AWSCDK::Interfaces::AWSEC2::VolumeReference
A reference to a Volume resource.
41 42 43 |
# File 'ec2/i_volume.rb', line 41 def volume_ref() jsii_get_property("volumeRef") end |
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.
73 74 75 76 77 78 |
# File 'ec2/i_volume.rb', line 73 def with(*mixins) mixins.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]") end jsii_call_method("with", [*mixins]) end |