Module: AWSCDK::EC2::IVolume

Includes:
IResource, Interfaces::AWSEC2::IVolumeRef
Included in:
Volume
Defined in:
ec2/i_volume.rb

Overview

An EBS Volume in AWS EC2.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsii_overridable_methodsObject



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).

Parameters:



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_zoneString

The availability zone that the EBS Volume is contained within (ex: us-west-2a).

Returns:

  • (String)


48
49
50
# File 'ec2/i_volume.rb', line 48

def availability_zone()
  jsii_get_property("availabilityZone")
end

#encryption_keyAWSCDK::KMS::IKey?

The customer-managed encryption key that is used to encrypt the Volume.

Returns:



62
63
64
# File 'ec2/i_volume.rb', line 62

def encryption_key()
  jsii_get_property("encryptionKey")
end

#envAWSCDK::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.

Parameters:

Returns:



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.

Parameters:

  • grantee (AWSCDK::IAM::IGrantable)

    the principal being granted permission.

  • constructs (Array<Constructs::Construct>)

    The list of constructs that will have the generated resource tag applied to them.

  • tag_key_suffix (String, nil) (defaults to: nil)

    A suffix to use on the generated Tag key in place of the generated hash value.

Returns:



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.

Parameters:

Returns:



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.

Parameters:

  • grantee (AWSCDK::IAM::IGrantable)

    the principal being granted permission.

  • constructs (Array<Constructs::Construct>)

    The list of constructs that will have the generated resource tag applied to them.

  • tag_key_suffix (String, nil) (defaults to: nil)

    A suffix to use on the generated Tag key in place of the generated hash value.

Returns:



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

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


12
13
14
# File 'ec2/i_volume.rb', line 12

def node()
  jsii_get_property("node")
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



34
35
36
# File 'ec2/i_volume.rb', line 34

def stack()
  jsii_get_property("stack")
end

#volume_idString

The EBS Volume's ID.

Returns:

  • (String)


55
56
57
# File 'ec2/i_volume.rb', line 55

def volume_id()
  jsii_get_property("volumeId")
end

#volume_refAWSCDK::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.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



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