EBS 다이렉트 API의 AWS SDK 코드 예제 - Amazon EBS

EBS 다이렉트 API의 AWS SDK 코드 예제

다음 코드 예제는 AWS 소프트웨어 개발 키트(SDK)에서 EBS 다이렉트 API를 사용하는 방법을 보여줍니다.

AWS SDK 또는 CLI와 함께 StartSnapshot 사용

다음 코드 예시는 StartSnapshot의 사용 방법을 보여 줍니다.

Rust
SDK for Rust
참고

GitHub에 더 많은 내용이 있습니다. AWS코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

async fn start(client: &Client, description: &str) -> Result<String, Error> { let snapshot = client .start_snapshot() .description(description) .encrypted(false) .volume_size(1) .send() .await?; Ok(snapshot.snapshot_id.unwrap()) }
  • API 세부 정보는 AWS SDK for Rust API 참조StartSnapshot을 참조하세요.

AWS SDK 또는 CLI와 함께 PutSnapshotBlock 사용

다음 코드 예시는 PutSnapshotBlock의 사용 방법을 보여 줍니다.

Rust
SDK for Rust
참고

GitHub에 더 많은 내용이 있습니다. AWS코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

async fn add_block( client: &Client, id: &str, idx: usize, block: Vec<u8>, checksum: &str, ) -> Result<(), Error> { client .put_snapshot_block() .snapshot_id(id) .block_index(idx as i32) .block_data(ByteStream::from(block)) .checksum(checksum) .checksum_algorithm(ChecksumAlgorithm::ChecksumAlgorithmSha256) .data_length(EBS_BLOCK_SIZE as i32) .send() .await?; Ok(()) }
  • API 세부 정보는 AWS SDK for Rust API 참조PutSnapshotBlock을 참조하세요.

AWS SDK 또는 CLI와 함께 CompleteSnapshot 사용

다음 코드 예시는 CompleteSnapshot의 사용 방법을 보여 줍니다.

Rust
SDK for Rust
참고

GitHub에 더 많은 내용이 있습니다. AWS코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

async fn finish(client: &Client, id: &str) -> Result<(), Error> { client .complete_snapshot() .changed_blocks_count(2) .snapshot_id(id) .send() .await?; println!("Snapshot ID {}", id); println!("The state is 'completed' when all of the modified blocks have been transferred to Amazon S3."); println!("Use the get-snapshot-state code example to get the state of the snapshot."); Ok(()) }
  • API 세부 정보는 AWS SDK for Rust API 참조CompleteSnapshot을 참조하세요.