adding ec2 volume to instance with powershell

0

I got following script to add a new volume to instanceID. However I am unsure how to get the volume ID after volume creation. Also the DeviceID what should it be?

Param (
    [string][Parameter(Mandatory) = $True] $InstanceId
    [string][Parameter(Mandatory = $True)] $driveletter,
    [int][Parameter(Mandatory = $True)] $size,
    [string][Parameter(Mandatory) = $True)] $az,
    [string][Parameter(Mandatory = $True)] $Region,
    [string][Parameter(Mandatory) = $True] $volumetype
    

New-ec2volume -AvailabilityZone $az -VolumeType $volumetype -size $size -Region $Region

Add-EC2Volume -InstanceId $InstanceId 


)
3개 답변
0

Hi There

To get the VolumeId use

$volume = New-ec2volume -AvailabilityZone $az -VolumeType $volumetype -size $size -Region $Region

Add-EC2Volume -InstanceId $InstanceId -VolumeID = $volume.Id

For determining the DeviceId for a Windows EC2 instance, see this article: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/device_naming.html

For Linux instances, see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html

profile pictureAWS
전문가
Matt-B
답변함 일 년 전
0

Thank you. Is there a write-progrss indicator i can add or new-ec2volume. I noticed I had to do a start-sleep 5 before I can add the ec2volume otherwise i cannot see the volumeid

drago
답변함 일 년 전
0

Check the below link for the script on how to create and attach EBS volume to EC2 instance

Create and attach EBS volume to already running EC2 instance with powershell

Mayank
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠