Class Volume

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.ec2.Volume
All Implemented Interfaces:
IVolumeRef, IEnvironmentAware, IResource, IVolume, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.126.0 (build 206d44b)", date="2026-02-09T14:39:09.953Z") @Stability(Stable) public class Volume extends Resource implements IVolume
Creates a new EBS Volume in AWS EC2.

Example:

 Volume.Builder.create(this, "Volume")
         .availabilityZone("us-east-1a")
         .size(Size.gibibytes(125))
         .volumeType(EbsDeviceVolumeType.GP3)
         .throughput(125)
         .build();
 
  • Field Details

    • PROPERTY_INJECTION_ID

      @Stability(Stable) public static final String PROPERTY_INJECTION_ID
      Uniquely identifies this class.
  • Constructor Details

    • Volume

      protected Volume(software.amazon.jsii.JsiiObjectRef objRef)
    • Volume

      protected Volume(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Volume

      @Stability(Stable) public Volume(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull VolumeProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromVolumeAttributes

      @Stability(Stable) @NotNull public static IVolume fromVolumeAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull VolumeAttributes attrs)
      Import an existing EBS Volume into the Stack.

      Parameters:
      scope - the scope of the import. This parameter is required.
      id - the ID of the imported Volume in the construct tree. This parameter is required.
      attrs - the attributes of the imported Volume. This parameter is required.
    • grantAttachVolume

      @Stability(Stable) @NotNull public Grant grantAttachVolume(@NotNull IGrantable grantee, @Nullable List<IInstanceRef> instances)
      [disable-awslint:no-grants].

      Specified by:
      grantAttachVolume in interface IVolume
      Parameters:
      grantee - This parameter is required.
      instances -
    • grantAttachVolume

      @Stability(Stable) @NotNull public Grant grantAttachVolume(@NotNull IGrantable grantee)
      [disable-awslint:no-grants].

      Specified by:
      grantAttachVolume in interface IVolume
      Parameters:
      grantee - This parameter is required.
    • grantAttachVolumeByResourceTag

      @Stability(Stable) @NotNull public Grant grantAttachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs, @Nullable String tagKeySuffix)
      [disable-awslint:no-grants].

      Specified by:
      grantAttachVolumeByResourceTag in interface IVolume
      Parameters:
      grantee - This parameter is required.
      constructs - This parameter is required.
      tagKeySuffix -
    • grantAttachVolumeByResourceTag

      @Stability(Stable) @NotNull public Grant grantAttachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs)
      [disable-awslint:no-grants].

      Specified by:
      grantAttachVolumeByResourceTag in interface IVolume
      Parameters:
      grantee - This parameter is required.
      constructs - This parameter is required.
    • grantDetachVolume

      @Stability(Stable) @NotNull public Grant grantDetachVolume(@NotNull IGrantable grantee, @Nullable List<IInstanceRef> instances)
      [disable-awslint:no-grants].

      Specified by:
      grantDetachVolume in interface IVolume
      Parameters:
      grantee - This parameter is required.
      instances -
    • grantDetachVolume

      @Stability(Stable) @NotNull public Grant grantDetachVolume(@NotNull IGrantable grantee)
      [disable-awslint:no-grants].

      Specified by:
      grantDetachVolume in interface IVolume
      Parameters:
      grantee - This parameter is required.
    • grantDetachVolumeByResourceTag

      @Stability(Stable) @NotNull public Grant grantDetachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs, @Nullable String tagKeySuffix)
      [disable-awslint:no-grants].

      Specified by:
      grantDetachVolumeByResourceTag in interface IVolume
      Parameters:
      grantee - This parameter is required.
      constructs - This parameter is required.
      tagKeySuffix -
    • grantDetachVolumeByResourceTag

      @Stability(Stable) @NotNull public Grant grantDetachVolumeByResourceTag(@NotNull IGrantable grantee, @NotNull List<software.constructs.Construct> constructs)
      [disable-awslint:no-grants].

      Specified by:
      grantDetachVolumeByResourceTag in interface IVolume
      Parameters:
      grantee - This parameter is required.
      constructs - This parameter is required.
    • validateProps

      @Stability(Stable) protected void validateProps(@NotNull VolumeProps props)
      Parameters:
      props - This parameter is required.
    • getAvailabilityZone

      @Stability(Stable) @NotNull public String getAvailabilityZone()
      The availability zone that the EBS Volume is contained within (ex: us-west-2a).
      Specified by:
      getAvailabilityZone in interface IVolume
    • getVolumeId

      @Stability(Stable) @NotNull public String getVolumeId()
      The EBS Volume's ID.
      Specified by:
      getVolumeId in interface IVolume
    • getVolumeRef

      @Stability(Stable) @NotNull public VolumeReference getVolumeRef()
      A reference to a Volume resource.
      Specified by:
      getVolumeRef in interface IVolumeRef
    • getEncryptionKey

      @Stability(Stable) @Nullable public IKey getEncryptionKey()
      The customer-managed encryption key that is used to encrypt the Volume.
      Specified by:
      getEncryptionKey in interface IVolume