Versi 5 (V5) Alat AWS untuk PowerShell telah dirilis!
Untuk informasi tentang mengubah perubahan dan memigrasikan aplikasi Anda, lihat topik https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html migrasi.
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Contoh Amazon EC2 menggunakan Alat untuk V5 PowerShell
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan Alat AWS untuk PowerShell V5 dengan Amazon EC2.
Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanAdd-EC2CapacityReservation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat Reservasi Kapasitas baru dengan atribut yang ditentukan
Add-EC2CapacityReservation -InstanceType m4.xlarge -InstanceCount 2 -AvailabilityZone eu-west-1b -EbsOptimized True -InstancePlatform WindowsOutput:
AvailabilityZone : eu-west-1b AvailableInstanceCount : 2 CapacityReservationId : cr-0c1f2345db6f7cdba CreateDate : 3/28/2019 9:29:41 AM EbsOptimized : True EndDate : 1/1/0001 12:00:00 AM EndDateType : unlimited EphemeralStorage : False InstanceMatchCriteria : open InstancePlatform : Windows InstanceType : m4.xlarge State : active Tags : {} Tenancy : default TotalInstanceCount : 2-
Untuk detail API, lihat CreateCapacityReservation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanAdd-EC2InternetGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melampirkan gateway Internet yang ditentukan ke VPC yang ditentukan.
Add-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678Contoh 2: Contoh ini membuat VPC dan gateway Internet, dan kemudian melampirkan gateway Internet ke VPC.
$vpc = New-EC2Vpc -CidrBlock 10.0.0.0/16 New-EC2InternetGateway | Add-EC2InternetGateway -VpcId $vpc.VpcId-
Untuk detail API, lihat AttachInternetGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanAdd-EC2NetworkInterface.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melampirkan antarmuka jaringan yang ditentukan ke instance yang ditentukan.
Add-EC2NetworkInterface -NetworkInterfaceId eni-12345678 -InstanceId i-1a2b3c4d -DeviceIndex 1Output:
eni-attach-1a2b3c4d-
Untuk detail API, lihat AttachNetworkInterface di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanAdd-EC2Volume.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melampirkan volume yang ditentukan ke instance yang ditentukan dan mengeksposnya dengan nama perangkat yang ditentukan.
Add-EC2Volume -VolumeId vol-12345678 -InstanceId i-1a2b3c4d -Device /dev/sdhOutput:
AttachTime : 12/22/2015 1:53:58 AM DeleteOnTermination : False Device : /dev/sdh InstanceId : i-1a2b3c4d State : attaching VolumeId : vol-12345678-
Untuk detail API, lihat AttachVolume di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanAdd-EC2VpnGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melampirkan gateway pribadi virtual yang ditentukan ke VPC yang ditentukan.
Add-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4d -VpcId vpc-12345678Output:
State VpcId ----- ----- attaching vpc-12345678-
Untuk detail API, lihat AttachVpnGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanApprove-EC2VpcPeeringConnection.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menyetujui pcx-1dfad234b56ff78be yang diminta VpcPeeringConnectionId
Approve-EC2VpcPeeringConnection -VpcPeeringConnectionId pcx-1dfad234b56ff78beOutput:
AccepterVpcInfo : Amazon.EC2.Model.VpcPeeringConnectionVpcInfo ExpirationTime : 1/1/0001 12:00:00 AM RequesterVpcInfo : Amazon.EC2.Model.VpcPeeringConnectionVpcInfo Status : Amazon.EC2.Model.VpcPeeringConnectionStateReason Tags : {} VpcPeeringConnectionId : pcx-1dfad234b56ff78be-
Untuk detail API, lihat AcceptVpcPeeringConnection di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanConfirm-EC2ProductInstance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menentukan apakah kode produk yang ditentukan dikaitkan dengan instance yang ditentukan.
Confirm-EC2ProductInstance -ProductCode 774F4FF8 -InstanceId i-12345678-
Untuk detail API, lihat ConfirmProductInstance di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanCopy-EC2Image.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menyalin AMI yang ditentukan di wilayah 'UE (Irlandia) 'ke wilayah 'AS Barat (Oregon)'. Jika -Region tidak ditentukan, wilayah default saat ini digunakan sebagai wilayah tujuan.
Copy-EC2Image -SourceRegion eu-west-1 -SourceImageId ami-12345678 -Region us-west-2 -Name "Copy of ami-12345678"Output:
ami-87654321-
Untuk detail API, lihat CopyImage di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanCopy-EC2Snapshot.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menyalin snapshot yang ditentukan dari wilayah UE (Irlandia) ke wilayah AS Barat (Oregon).
Copy-EC2Snapshot -SourceRegion eu-west-1 -SourceSnapshotId snap-12345678 -Region us-west-2Contoh 2: Jika Anda menetapkan wilayah default dan menghilangkan parameter Region, wilayah tujuan default adalah wilayah default.
Set-DefaultAWSRegion us-west-2 Copy-EC2Snapshot -SourceRegion eu-west-1 -SourceSnapshotId snap-12345678-
Untuk detail API, lihat CopySnapshot di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDeny-EC2VpcPeeringConnection.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh di atas menolak VpcPeering permintaan id pcx-01a2b3ce45fe67eb8
Deny-EC2VpcPeeringConnection -VpcPeeringConnectionId pcx-01a2b3ce45fe67eb8-
Untuk detail API, lihat RejectVpcPeeringConnection di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDisable-EC2VgwRoutePropagation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menonaktifkan VGW dari menyebarkan rute secara otomatis ke tabel routing yang ditentukan.
Disable-EC2VgwRoutePropagation -RouteTableId rtb-12345678 -GatewayId vgw-1a2b3c4d-
Untuk detail API, lihat DisableVgwRoutePropagation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDisable-EC2VpcClassicLink.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini dinonaktifkan untuk vpc-01e23c4a5 EC2VpcClassicLink d6db78e9. Ini mengembalikan Benar atau Salah
Disable-EC2VpcClassicLink -VpcId vpc-01e23c4a5d6db78e9-
Untuk detail API, lihat DisableVpcClassicLink di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDisable-EC2VpcClassicLinkDnsSupport.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menonaktifkan dukungan ClassicLink DNS untuk vpc-0b12d3456a7e8910d
Disable-EC2VpcClassicLinkDnsSupport -VpcId vpc-0b12d3456a7e8910d-
Untuk detail API, lihat DisableVpcClassicLinkDnsSupport di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDismount-EC2InternetGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melepaskan gateway Internet yang ditentukan dari VPC yang ditentukan.
Dismount-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678-
Untuk detail API, lihat DetachInternetGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDismount-EC2NetworkInterface.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus lampiran yang ditentukan antara antarmuka jaringan dan instance.
Dismount-EC2NetworkInterface -AttachmentId eni-attach-1a2b3c4d -Force-
Untuk detail API, lihat DetachNetworkInterface di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDismount-EC2Volume.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melepaskan volume yang ditentukan.
Dismount-EC2Volume -VolumeId vol-12345678Output:
AttachTime : 12/22/2015 1:53:58 AM DeleteOnTermination : False Device : /dev/sdh InstanceId : i-1a2b3c4d State : detaching VolumeId : vol-12345678Contoh 2: Anda juga dapat menentukan ID instance dan nama perangkat untuk memastikan bahwa Anda melepaskan volume yang benar.
Dismount-EC2Volume -VolumeId vol-12345678 -InstanceId i-1a2b3c4d -Device /dev/sdh-
Untuk detail API, lihat DetachVolume di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanDismount-EC2VpnGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melepaskan gateway pribadi virtual yang ditentukan dari VPC yang ditentukan.
Dismount-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4d -VpcId vpc-12345678-
Untuk detail API, lihat DetachVpnGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2CapacityReservation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memodifikasi CapacityReservationId cr-0c1f2345db6f7cdba dengan mengubah jumlah instane menjadi 1
Edit-EC2CapacityReservation -CapacityReservationId cr-0c1f2345db6f7cdba -InstanceCount 1Output:
True-
Untuk detail API, lihat ModifyCapacityReservation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2Host.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengubah AutoPlacement pengaturan menjadi off untuk host khusus h-01e23f4cd567890f3
Edit-EC2Host -HostId h-03e09f8cd681609f3 -AutoPlacement offOutput:
Successful Unsuccessful ---------- ------------ {h-01e23f4cd567890f3} {}-
Untuk detail API, lihat ModifyHosts di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2IdFormat.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan format ID yang lebih panjang untuk jenis sumber daya yang ditentukan.
Edit-EC2IdFormat -Resource instance -UseLongId $trueContoh 2: Contoh ini menonaktifkan format ID yang lebih panjang untuk jenis sumber daya yang ditentukan.
Edit-EC2IdFormat -Resource instance -UseLongId $false-
Untuk detail API, lihat ModifyIdFormat di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2ImageAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memperbarui deskripsi untuk AMI yang ditentukan.
Edit-EC2ImageAttribute -ImageId ami-12345678 -Description "New description"Contoh 2: Contoh ini membuat AMI menjadi publik (misalnya, sehingga siapa pun Akun AWS dapat menggunakannya).
Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType add -UserGroup allContoh 3: Contoh ini membuat AMI pribadi (misalnya, sehingga hanya Anda sebagai pemilik yang dapat menggunakannya).
Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType remove -UserGroup allContoh 4: Contoh ini memberikan izin peluncuran ke yang ditentukan Akun AWS.
Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType add -UserId 111122223333Contoh 5: Contoh ini menghapus izin peluncuran dari yang ditentukan Akun AWS.
Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType remove -UserId 111122223333-
Untuk detail API, lihat ModifyImageAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2InstanceAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memodifikasi jenis instance dari instance yang ditentukan.
Edit-EC2InstanceAttribute -InstanceId i-12345678 -InstanceType m3.mediumContoh 2: Contoh ini memungkinkan peningkatan jaringan untuk instance yang ditentukan, dengan menentukan “simple” sebagai nilai parameter dukungan jaringan I/O virtual root tunggal (SR-IOV), -SriovNetSupport..
Edit-EC2InstanceAttribute -InstanceId i-12345678 -SriovNetSupport "simple"Contoh 3: Contoh ini memodifikasi grup keamanan untuk instance yang ditentukan. Instance harus dalam VPC. Anda harus menentukan ID setiap grup keamanan, bukan namanya.
Edit-EC2InstanceAttribute -InstanceId i-12345678 -Group @( "sg-12345678", "sg-45678901" )Contoh 4: Contoh ini mengaktifkan peng I/O optimalan EBS untuk instance yang ditentukan. Fitur ini tidak tersedia dengan semua jenis instans. Biaya penggunaan tambahan berlaku saat menggunakan EBS-optimized instance.
Edit-EC2InstanceAttribute -InstanceId i-12345678 -EbsOptimized $trueContoh 5: Contoh ini memungkinkan source/destination pemeriksaan untuk instance yang ditentukan. Agar instance NAT dapat melakukan NAT, nilainya harus 'palsu'.
Edit-EC2InstanceAttribute -InstanceId i-12345678 -SourceDestCheck $trueContoh 6: Contoh ini menonaktifkan penghentian untuk instance yang ditentukan.
Edit-EC2InstanceAttribute -InstanceId i-12345678 -DisableApiTermination $trueContoh 7: Contoh ini mengubah instance yang ditentukan sehingga berakhir ketika shutdown dimulai dari instance.
Edit-EC2InstanceAttribute -InstanceId i-12345678 -InstanceInitiatedShutdownBehavior terminate-
Untuk detail API, lihat ModifyInstanceAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2InstanceCreditSpecification.
- Alat untuk PowerShell V5
-
Contoh 1: Ini memungkinkan kredit T2 tak terbatas misalnya i-01234567890abcdef.
$Credit = New-Object -TypeName Amazon.EC2.Model.InstanceCreditSpecificationRequest $Credit.InstanceId = "i-01234567890abcdef" $Credit.CpuCredits = "unlimited" Edit-EC2InstanceCreditSpecification -InstanceCreditSpecification $Credit-
Untuk detail API, lihat ModifyInstanceCreditSpecification di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2NetworkInterfaceAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memodifikasi antarmuka jaringan yang ditentukan sehingga lampiran yang ditentukan dihapus pada penghentian.
Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -Attachment_AttachmentId eni-attach-1a2b3c4d -Attachment_DeleteOnTermination $trueContoh 2: Contoh ini memodifikasi deskripsi antarmuka jaringan yang ditentukan.
Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -Description "my description"Contoh 3: Contoh ini memodifikasi grup keamanan untuk antarmuka jaringan yang ditentukan.
Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -Groups sg-1a2b3c4dContoh 4: Contoh ini menonaktifkan source/destination pemeriksaan untuk antarmuka jaringan yang ditentukan.
Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -SourceDestCheck $false-
Untuk detail API, lihat ModifyNetworkInterfaceAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2ReservedInstance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengubah Zona Ketersediaan, jumlah instans, dan platform untuk instans Cadangan yang ditentukan.
$config = New-Object Amazon.EC2.Model.ReservedInstancesConfiguration $config.AvailabilityZone = "us-west-2a" $config.InstanceCount = 1 $config.Platform = "EC2-VPC" Edit-EC2ReservedInstance ` -ReservedInstancesId @("FE32132D-70D5-4795-B400-AE435EXAMPLE", "0CC556F3-7AB8-4C00-B0E5-98666EXAMPLE") ` -TargetConfiguration $config-
Untuk detail API, lihat ModifyReservedInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2SnapshotAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat snapshot yang ditentukan menjadi publik dengan mengatur CreateVolumePermission atributnya.
Edit-EC2SnapshotAttribute -SnapshotId snap-12345678 -Attribute CreateVolumePermission -OperationType Add -GroupName all-
Untuk detail API, lihat ModifySnapshotAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2SpotFleetRequest.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memperbarui kapasitas target permintaan armada Spot yang ditentukan.
Edit-EC2SpotFleetRequest -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE -TargetCapacity 10Output:
True-
Untuk detail API, lihat ModifySpotFleetRequest di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2SubnetAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan pengalamatan IP publik untuk subnet yang ditentukan.
Edit-EC2SubnetAttribute -SubnetId subnet-1a2b3c4d -MapPublicIpOnLaunch $trueContoh 2: Contoh ini menonaktifkan pengalamatan IP publik untuk subnet yang ditentukan.
Edit-EC2SubnetAttribute -SubnetId subnet-1a2b3c4d -MapPublicIpOnLaunch $false-
Untuk detail API, lihat ModifySubnetAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2VolumeAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memodifikasi atribut yang ditentukan dari volume yang ditentukan. I/O operasi untuk volume dilanjutkan secara otomatis setelah ditangguhkan karena data yang berpotensi tidak konsisten.
Edit-EC2VolumeAttribute -VolumeId vol-12345678 -AutoEnableIO $true-
Untuk detail API, lihat ModifyVolumeAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-EC2VpcAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan dukungan untuk nama host DNS untuk VPC yang ditentukan.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $trueContoh 2: Contoh ini menonaktifkan dukungan untuk nama host DNS untuk VPC yang ditentukan.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $falseContoh 3: Contoh ini mengaktifkan dukungan untuk resolusi DNS untuk VPC yang ditentukan.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $trueContoh 4: Contoh ini menonaktifkan dukungan untuk resolusi DNS untuk VPC yang ditentukan.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $false-
Untuk detail API, lihat ModifyVpcAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEnable-EC2VgwRoutePropagation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memungkinkan VGW yang ditentukan untuk menyebarkan rute secara otomatis ke tabel routing yang ditentukan.
Enable-EC2VgwRoutePropagation -RouteTableId rtb-12345678 -GatewayId vgw-1a2b3c4d-
Untuk detail API, lihat EnableVgwRoutePropagation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEnable-EC2VolumeIO.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan I/O operasi untuk volume yang ditentukan, jika I/O operasi dinonaktifkan.
Enable-EC2VolumeIO -VolumeId vol-12345678-
Untuk detail API, lihat EnableVolumeIo di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEnable-EC2VpcClassicLink.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan VPC vpc-0123456b789b0d12f untuk ClassicLink
Enable-EC2VpcClassicLink -VpcId vpc-0123456b789b0d12fOutput:
True-
Untuk detail API, lihat EnableVpcClassicLink di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEnable-EC2VpcClassicLinkDnsSupport.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan vpc-0b12d3456a7e8910d untuk mendukung resolusi nama host DNS untuk ClassicLink
Enable-EC2VpcClassicLinkDnsSupport -VpcId vpc-0b12d3456a7e8910d -Region eu-west-1-
Untuk detail API, lihat EnableVpcClassicLinkDnsSupport di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2AccountAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan apakah Anda dapat meluncurkan instance ke EC2-Classic dan EC2-VPC di wilayah tersebut, atau hanya ke EC2-VPC.
(Get-EC2AccountAttribute -AttributeName supported-platforms).AttributeValuesOutput:
AttributeValue -------------- EC2 VPCContoh 2: Contoh ini menjelaskan VPC default Anda, atau 'tidak ada' jika Anda tidak memiliki VPC default di wilayah tersebut.
(Get-EC2AccountAttribute -AttributeName default-vpc).AttributeValuesOutput:
AttributeValue -------------- vpc-12345678Contoh 3: Contoh ini menjelaskan jumlah maksimum On-Demand instance yang dapat Anda jalankan.
(Get-EC2AccountAttribute -AttributeName max-instances).AttributeValuesOutput:
AttributeValue -------------- 20-
Untuk detail API, lihat DescribeAccountAttributes di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Address.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan alamat IP Elastic yang ditentukan untuk instance di EC2-Classic.
Get-EC2Address -AllocationId eipalloc-12345678Output:
AllocationId : eipalloc-12345678 AssociationId : eipassoc-12345678 Domain : vpc InstanceId : i-87654321 NetworkInterfaceId : eni-12345678 NetworkInterfaceOwnerId : 12345678 PrivateIpAddress : 10.0.2.172 PublicIp : 198.51.100.2Contoh 2: Contoh ini menjelaskan alamat IP Elastic Anda untuk instance dalam VPC. Sintaks ini membutuhkan PowerShell versi 3 atau yang lebih baru.
Get-EC2Address -Filter @{ Name="domain";Values="vpc" }Contoh 3: Contoh ini menjelaskan alamat IP Elastic yang ditentukan untuk instance di EC2-Classic.
Get-EC2Address -PublicIp 203.0.113.17Output:
AllocationId : AssociationId : Domain : standard InstanceId : i-12345678 NetworkInterfaceId : NetworkInterfaceOwnerId : PrivateIpAddress : PublicIp : 203.0.113.17Contoh 4: Contoh ini menjelaskan alamat IP Elastic Anda untuk instance di EC2-Classic. Sintaks ini membutuhkan PowerShell versi 3 atau yang lebih baru.
Get-EC2Address -Filter @{ Name="domain";Values="standard" }Contoh 5: Contoh ini menjelaskan semua alamat IP Elastic Anda.
Get-EC2AddressContoh 6: Contoh ini mengembalikan IP publik dan pribadi untuk id instance yang disediakan dalam filter
Get-EC2Address -Region eu-west-1 -Filter @{Name="instance-id";Values="i-0c12d3f4f567ffb89"} | Select-Object PrivateIpAddress, PublicIpOutput:
PrivateIpAddress PublicIp ---------------- -------- 10.0.0.99 63.36.5.227Contoh 7: Contoh ini mengambil semua IP Elastic dengan id alokasi, id asosiasi, dan id instance
Get-EC2Address -Region eu-west-1 | Select-Object InstanceId, AssociationId, AllocationId, PublicIpOutput:
InstanceId AssociationId AllocationId PublicIp ---------- ------------- ------------ -------- eipalloc-012e3b456789e1fad 17.212.120.178 i-0c123dfd3415bac67 eipassoc-0e123456bb7890bdb eipalloc-01cd23ebf45f7890c 17.212.124.77 eipalloc-012345678eeabcfad 17.212.225.7 i-0123d405c67e89a0c eipassoc-0c123b456783966ba eipalloc-0123cdd456a8f7892 37.216.52.173 i-0f1bf2f34c5678d09 eipassoc-0e12934568a952d96 eipalloc-0e1c23e4d5e6789e4 37.218.222.278 i-012e3cb4df567e8aa eipassoc-0d1b2fa4d67d03810 eipalloc-0123f456f78a01b58 37.210.82.27 i-0123bcf4b567890e1 eipassoc-01d2345f678903fb1 eipalloc-0e1db23cfef5c45c7 37.215.222.270Contoh 8: Contoh ini mengambil daftar alamat IP EC2 yang cocok dengan kunci tag 'Kategori' dengan nilai 'Prod'
Get-EC2Address -Filter @{Name="tag:Category";Values="Prod"}Output:
AllocationId : eipalloc-0123f456f81a01b58 AssociationId : eipassoc-0d1b23a456d103810 CustomerOwnedIp : CustomerOwnedIpv4Pool : Domain : vpc InstanceId : i-012e3cb4df567e1aa NetworkBorderGroup : eu-west-1 NetworkInterfaceId : eni-0123f41d5a60d5f40 NetworkInterfaceOwnerId : 123456789012 PrivateIpAddress : 192.168.1.84 PublicIp : 34.250.81.29 PublicIpv4Pool : amazon Tags : {Category, Name}-
Untuk detail API, lihat DescribeAddresses di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2AvailabilityZone.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan Zona Ketersediaan untuk wilayah saat ini yang tersedia untuk Anda.
Get-EC2AvailabilityZoneOutput:
Messages RegionName State ZoneName -------- ---------- ----- -------- {} us-west-2 available us-west-2a {} us-west-2 available us-west-2b {} us-west-2 available us-west-2cContoh 2: Contoh ini menjelaskan setiap Zona Ketersediaan yang berada dalam keadaan terganggu. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
Get-EC2AvailabilityZone -Filter @{ Name="state";Values="impaired" }Contoh 3: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat filter.
$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = "impaired" Get-EC2AvailabilityZone -Filter $filter-
Untuk detail API, lihat DescribeAvailabilityZones di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2BundleTask.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan tugas bundel yang ditentukan.
Get-EC2BundleTask -BundleId bun-12345678Contoh 2: Contoh ini menjelaskan tugas bundel yang statusnya 'selesai' atau 'gagal'.
$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = @( "complete", "failed" ) Get-EC2BundleTask -Filter $filter-
Untuk detail API, lihat DescribeBundleTasks di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2CapacityReservation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan satu atau lebih Reservasi Kapasitas Anda untuk wilayah
Get-EC2CapacityReservation -Region eu-west-1Output:
AvailabilityZone : eu-west-1b AvailableInstanceCount : 2 CapacityReservationId : cr-0c1f2345db6f7cdba CreateDate : 3/28/2019 9:29:41 AM EbsOptimized : True EndDate : 1/1/0001 12:00:00 AM EndDateType : unlimited EphemeralStorage : False InstanceMatchCriteria : open InstancePlatform : Windows InstanceType : m4.xlarge State : active Tags : {} Tenancy : default TotalInstanceCount : 2-
Untuk detail API, lihat DescribeCapacityReservations di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2ConsoleOutput.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mendapatkan output konsol untuk instance Linux yang ditentukan. Output konsol dikodekan.
Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456Output:
InstanceId Output ---------- ------ i-0e194d3c47c123637 WyAgICAwLjAwMDAwMF0gQ29tbW...bGU9dHR5UzAgc2VsContoh 2: Contoh ini menyimpan output konsol yang dikodekan dalam variabel dan kemudian menerjemahkannya.
$Output_encoded = (Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456).Output [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Output_encoded))-
Untuk detail API, lihat GetConsoleOutput di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2CustomerGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan gateway pelanggan yang ditentukan.
Get-EC2CustomerGateway -CustomerGatewayId cgw-1a2b3c4dOutput:
BgpAsn : 65534 CustomerGatewayId : cgw-1a2b3c4d IpAddress : 203.0.113.12 State : available Tags : {} Type : ipsec.1Contoh 2: Contoh ini menjelaskan setiap gateway pelanggan yang statusnya tertunda atau tersedia.
$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = @( "pending", "available" ) Get-EC2CustomerGateway -Filter $filterContoh 3: Contoh ini menjelaskan semua gateway pelanggan Anda.
Get-EC2CustomerGateway-
Untuk detail API, lihat DescribeCustomerGateways di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2DhcpOption.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mencantumkan set opsi DHCP Anda.
Get-EC2DhcpOptionOutput:
DhcpConfigurations DhcpOptionsId Tag ------------------ ------------- --- {domain-name, domain-name-servers} dopt-1a2b3c4d {} {domain-name, domain-name-servers} dopt-2a3b4c5d {} {domain-name-servers} dopt-3a4b5c6d {}Contoh 2: Contoh ini mendapatkan detail konfigurasi untuk set opsi DHCP yang ditentukan.
(Get-EC2DhcpOption -DhcpOptionsId dopt-1a2b3c4d).DhcpConfigurationsOutput:
Key Values --- ------ domain-name {abc.local} domain-name-servers {10.0.0.101, 10.0.0.102}-
Untuk detail API, lihat DescribeDhcpOptions di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2FlowLog.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan satu atau lebih log aliran dengan tipe tujuan log 's3'
Get-EC2FlowLog -Filter @{Name="log-destination-type";Values="s3"}Output:
CreationTime : 2/25/2019 9:07:36 PM DeliverLogsErrorMessage : DeliverLogsPermissionArn : DeliverLogsStatus : SUCCESS FlowLogId : fl-01b2e3d45f67f8901 FlowLogStatus : ACTIVE LogDestination : arn:aws:s3:::amzn-s3-demo-bucket-dd-tata LogDestinationType : s3 LogGroupName : ResourceId : eni-01d2dda3456b7e890 TrafficType : ALL-
Untuk detail API, lihat DescribeFlowLogs di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Host.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengembalikan detail host EC2
Get-EC2HostOutput:
AllocationTime : 3/23/2019 4:55:22 PM AutoPlacement : off AvailabilityZone : eu-west-1b AvailableCapacity : Amazon.EC2.Model.AvailableCapacity ClientToken : HostId : h-01e23f4cd567890f1 HostProperties : Amazon.EC2.Model.HostProperties HostReservationId : Instances : {} ReleaseTime : 1/1/0001 12:00:00 AM State : available Tags : {}Contoh 2: Contoh ini menanyakan AvailableInstanceCapacity untuk host h-01e23f4cd567899f1
Get-EC2Host -HostId h-01e23f4cd567899f1 | Select-Object -ExpandProperty AvailableCapacity | Select-Object -expand AvailableInstanceCapacityOutput:
AvailableCapacity InstanceType TotalCapacity ----------------- ------------ ------------- 11 m4.xlarge 11-
Untuk detail API, lihat DescribeHosts di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2HostReservationOffering.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan reservasi Host Khusus yang tersedia untuk dibeli untuk filter 'instance-family' yang PaymentOption diberikan dimana '' NoUpfront
Get-EC2HostReservationOffering -Filter @{Name="instance-family";Values="m4"} | Where-Object PaymentOption -eq NoUpfrontOutput:
CurrencyCode : Duration : 94608000 HourlyPrice : 1.307 InstanceFamily : m4 OfferingId : hro-0c1f234567890d9ab PaymentOption : NoUpfront UpfrontPrice : 0.000 CurrencyCode : Duration : 31536000 HourlyPrice : 1.830 InstanceFamily : m4 OfferingId : hro-04ad12aaaf34b5a67 PaymentOption : NoUpfront UpfrontPrice : 0.000-
Untuk detail API, lihat DescribeHostReservationOfferings di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2HostReservationPurchasePreview.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menampilkan pratinjau pembelian reservasi dengan konfigurasi yang sesuai dengan Dedicated Host h-01e23f4cd567890f1
Get-EC2HostReservationPurchasePreview -OfferingId hro-0c1f23456789d0ab -HostIdSet h-01e23f4cd567890f1Output:
CurrencyCode Purchase TotalHourlyPrice TotalUpfrontPrice ------------ -------- ---------------- ----------------- {} 1.307 0.000-
Untuk detail API, lihat GetHostReservationPurchasePreview di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2IdFormat.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan format ID untuk jenis sumber daya yang ditentukan.
Get-EC2IdFormat -Resource instanceOutput:
Resource UseLongIds -------- ---------- instance FalseContoh 2: Contoh ini menjelaskan format ID untuk semua jenis sumber daya yang mendukung ID yang lebih panjang.
Get-EC2IdFormatOutput:
Resource UseLongIds -------- ---------- reservation False instance False-
Untuk detail API, lihat DescribeIdFormat di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2IdentityIdFormat.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengembalikan format ID untuk 'gambar' resouce untuk peran yang diberikan
Get-EC2IdentityIdFormat -PrincipalArn arn:aws:iam::123456789511:role/JDBC -Resource imageOutput:
Deadline Resource UseLongIds -------- -------- ---------- 8/2/2018 11:30:00 PM image True-
Untuk detail API, lihat DescribeIdentityIdFormat di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Image.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan AMI yang ditentukan.
Get-EC2Image -ImageId ami-12345678Output:
Architecture : x86_64 BlockDeviceMappings : {/dev/xvda} CreationDate : 2014-10-20T00:56:28.000Z Description : My image Hypervisor : xen ImageId : ami-12345678 ImageLocation : 123456789012/my-image ImageOwnerAlias : ImageType : machine KernelId : Name : my-image OwnerId : 123456789012 Platform : ProductCodes : {} Public : False RamdiskId : RootDeviceName : /dev/xvda RootDeviceType : ebs SriovNetSupport : simple State : available StateReason : Tags : {Name} VirtualizationType : hvmContoh 2: Contoh ini menjelaskan AMI yang Anda miliki.
Get-EC2Image -owner selfContoh 3: Contoh ini menjelaskan AMI publik yang menjalankan Microsoft Windows Server.
Get-EC2Image -Filter @{ Name="platform"; Values="windows" }Contoh 4: Contoh ini menjelaskan semua AMI publik di wilayah 'us-west-2'.
Get-EC2Image -Region us-west-2-
Untuk detail API, lihat DescribeImages di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2ImageAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mendapatkan deskripsi untuk AMI yang ditentukan.
Get-EC2ImageAttribute -ImageId ami-12345678 -Attribute descriptionOutput:
BlockDeviceMappings : {} Description : My image description ImageId : ami-12345678 KernelId : LaunchPermissions : {} ProductCodes : {} RamdiskId : SriovNetSupport :Contoh 2: Contoh ini mendapatkan izin peluncuran untuk AMI yang ditentukan.
Get-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermissionOutput:
BlockDeviceMappings : {} Description : ImageId : ami-12345678 KernelId : LaunchPermissions : {all} ProductCodes : {} RamdiskId : SriovNetSupport :Contoh 3: Contoh ini menguji apakah jaringan yang disempurnakan diaktifkan.
Get-EC2ImageAttribute -ImageId ami-12345678 -Attribute sriovNetSupportOutput:
BlockDeviceMappings : {} Description : ImageId : ami-12345678 KernelId : LaunchPermissions : {} ProductCodes : {} RamdiskId : SriovNetSupport : simple-
Untuk detail API, lihat DescribeImageAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2ImportImageTask.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan tugas impor gambar yang ditentukan.
Get-EC2ImportImageTask -ImportTaskId import-ami-hgfedcbaOutput:
Architecture : x86_64 Description : Windows Image 2 Hypervisor : ImageId : ami-1a2b3c4d ImportTaskId : import-ami-hgfedcba LicenseType : AWS Platform : Windows Progress : SnapshotDetails : {/dev/sda1} Status : completed StatusMessage :Contoh 2: Contoh ini menjelaskan semua tugas impor gambar Anda.
Get-EC2ImportImageTaskOutput:
Architecture : Description : Windows Image 1 Hypervisor : ImageId : ImportTaskId : import-ami-abcdefgh LicenseType : AWS Platform : Windows Progress : SnapshotDetails : {} Status : deleted StatusMessage : User initiated task cancelation Architecture : x86_64 Description : Windows Image 2 Hypervisor : ImageId : ami-1a2b3c4d ImportTaskId : import-ami-hgfedcba LicenseType : AWS Platform : Windows Progress : SnapshotDetails : {/dev/sda1} Status : completed StatusMessage :-
Untuk detail API, lihat DescribeImportImageTasks di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2ImportSnapshotTask.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan tugas impor snapshot yang ditentukan.
Get-EC2ImportSnapshotTask -ImportTaskId import-snap-abcdefghOutput:
Description ImportTaskId SnapshotTaskDetail ----------------- -------------------- ------------------ Disk Image Import 1 import-snap-abcdefgh Amazon.EC2.Model.SnapshotTaskDetailContoh 2: Contoh ini menjelaskan semua tugas impor snapshot Anda.
Get-EC2ImportSnapshotTaskOutput:
Description ImportTaskId SnapshotTaskDetail ----------------- -------------------- ------------------ Disk Image Import 1 import-snap-abcdefgh Amazon.EC2.Model.SnapshotTaskDetail Disk Image Import 2 import-snap-hgfedcba Amazon.EC2.Model.SnapshotTaskDetail-
Untuk detail API, lihat DescribeImportSnapshotTasks di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Instance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan instance yang ditentukan.
(Get-EC2Instance -InstanceId i-12345678).InstancesOutput:
AmiLaunchIndex : 0 Architecture : x86_64 BlockDeviceMappings : {/dev/sda1} ClientToken : TleEy1448154045270 EbsOptimized : False Hypervisor : xen IamInstanceProfile : Amazon.EC2.Model.IamInstanceProfile ImageId : ami-12345678 InstanceId : i-12345678 InstanceLifecycle : InstanceType : t2.micro KernelId : KeyName : my-key-pair LaunchTime : 12/4/2015 4:44:40 PM Monitoring : Amazon.EC2.Model.Monitoring NetworkInterfaces : {ip-10-0-2-172.us-west-2.compute.internal} Placement : Amazon.EC2.Model.Placement Platform : Windows PrivateDnsName : ip-10-0-2-172.us-west-2.compute.internal PrivateIpAddress : 10.0.2.172 ProductCodes : {} PublicDnsName : PublicIpAddress : RamdiskId : RootDeviceName : /dev/sda1 RootDeviceType : ebs SecurityGroups : {default} SourceDestCheck : True SpotInstanceRequestId : SriovNetSupport : State : Amazon.EC2.Model.InstanceState StateReason : StateTransitionReason : SubnetId : subnet-12345678 Tags : {Name} VirtualizationType : hvm VpcId : vpc-12345678Contoh 2: Contoh ini menjelaskan semua instance Anda di wilayah saat ini, dikelompokkan berdasarkan reservasi. Untuk melihat detail instance, perluas koleksi Instans dalam setiap objek reservasi.
Get-EC2InstanceOutput:
GroupNames : {} Groups : {} Instances : {} OwnerId : 123456789012 RequesterId : 226008221399 ReservationId : r-c5df370c GroupNames : {} Groups : {} Instances : {} OwnerId : 123456789012 RequesterId : 854251627541 ReservationId : r-63e65bab ...Contoh 3: Contoh ini menggambarkan penggunaan filter untuk menanyakan instans EC2 di subnet tertentu dari VPC.
(Get-EC2Instance -Filter @{Name="vpc-id";Values="vpc-1a2bc34d"},@{Name="subnet-id";Values="subnet-1a2b3c4d"}).InstancesOutput:
InstanceId InstanceType Platform PrivateIpAddress PublicIpAddress SecurityGroups SubnetId VpcId ---------- ------------ -------- ---------------- --------------- -------------- -------- ----- i-01af...82cf180e19 t2.medium Windows 10.0.0.98 ... subnet-1a2b3c4d vpc-1a2b3c4d i-0374...7e9d5b0c45 t2.xlarge Windows 10.0.0.53 ... subnet-1a2b3c4d vpc-1a2b3c4dContoh 4: Contoh ini menggambarkan penggunaan filter dengan beberapa nilai untuk menanyakan instans EC2 yang sedang berjalan dan dihentikan
$InstanceParams = @{ Filter = @( @{'Name' = 'instance-state-name';'Values' = @("running","stopped")} ) } (Get-EC2Instance @InstanceParams).InstancesOutput:
InstanceId InstanceType Platform PrivateIpAddress PublicIpAddress SecurityGroups SubnetId VpcId ---------- ------------ -------- ---------------- --------------- -------------- -------- ----- i-05a9...f6c5f46e18 t3.medium 10.0.1.7 ... subnet-1a2b3c4d vpc-1a2b3c4d i-02cf...945c4fdd07 t3.medium Windows 10.0.1.8 ... subnet-1a2b3c4d vpc-1a2b3c4d i-0ac0...c037f9f3a1 t3.xlarge Windows 10.0.1.10 ... subnet-1a2b3c4d vpc-1a2b3c4d i-066b...57b7b08888 t3.medium Windows 10.0.1.11 ... subnet-1a2b3c4d vpc-1a2b3c4d i-0fee...82e83ccd72 t3.medium Windows 10.0.1.5 ... subnet-1a2b3c4d vpc-1a2b3c4d i-0a68...274cc5043b t3.medium Windows 10.0.1.6 ... subnet-1a2b3c4d vpc-1a2b3c4dContoh 5: Contoh ini menggambarkan penggunaan filter dengan beberapa nilai untuk menanyakan instans EC2 yang sedang berjalan dan dihentikan dan menggunakan Select-Object cmdlet untuk memilih nilai tertentu untuk dikeluarkan.
$InstanceParams = @{ Filter = @( @{'Name' = 'instance-state-name';'Values' = @("running","stopped")} ) } $SelectParams = @{ Property = @( "InstanceID", "InstanceType", "Platform", "PrivateIpAddress", @{Name="Name";Expression={$_.Tags[$_.Tags.Key.IndexOf("Name")].Value}}, @{Name="State";Expression={$_.State.Name}} ) } $result = Get-EC2Instance @InstanceParams $result.Instances | Select-Object @SelectParams | Format-Table -AutoSizeOutput:
InstanceId InstanceType Platform PrivateIpAddress Name State ---------- ------------ -------- ---------------- ---- ----- i-05a9...f6c5f46e18 t3.medium 10.0.1.7 ec2-name-01 running i-02cf...945c4fdd07 t3.medium Windows 10.0.1.8 ec2-name-02 stopped i-0ac0...c037f9f3a1 t3.xlarge Windows 10.0.1.10 ec2-name-03 running i-066b...57b7b08888 t3.medium Windows 10.0.1.11 ec2-name-04 stopped i-0fee...82e83ccd72 t3.medium Windows 10.0.1.5 ec2-name-05 running i-0a68...274cc5043b t3.medium Windows 10.0.1.6 ec2-name-06 stoppedContoh 6: Contoh ini memvalidasi izin untuk mendapatkan instans EC2 menggunakan DryRun parameter tanpa benar-benar mengambilnya. Catatan: Ini menimbulkan pengecualian jika berhasil yang merupakan perilaku yang diharapkan.
Get-EC2Tag -DryRun $trueOutput:
Get-EC2Instance: Request would have succeeded, but DryRun flag is set.-
Untuk detail API, lihat DescribeInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2InstanceAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan jenis instance dari instance yang ditentukan.
Get-EC2InstanceAttribute -InstanceId i-12345678 -Attribute instanceTypeOutput:
InstanceType : t2.microContoh 2: Contoh ini menjelaskan apakah jaringan yang disempurnakan diaktifkan untuk instance yang ditentukan.
Get-EC2InstanceAttribute -InstanceId i-12345678 -Attribute sriovNetSupportOutput:
SriovNetSupport : simpleContoh 3: Contoh ini menjelaskan grup keamanan untuk instance yang ditentukan.
(Get-EC2InstanceAttribute -InstanceId i-12345678 -Attribute groupSet).GroupsOutput:
GroupId ------- sg-12345678 sg-45678901Contoh 4: Contoh ini menjelaskan apakah optimasi EBS diaktifkan untuk instance yang ditentukan.
Get-EC2InstanceAttribute -InstanceId i-12345678 -Attribute ebsOptimizedOutput:
EbsOptimized : FalseContoh 5: Contoh ini menjelaskan atribut 'menonaktif ApiTermination kan' dari instance yang ditentukan.
Get-EC2InstanceAttribute -InstanceId i-12345678 -Attribute disableApiTerminationOutput:
DisableApiTermination : FalseContoh 6: Contoh ini menjelaskan atribut 'instanceInitiatedShutdownBehavior' dari instance yang ditentukan.
Get-EC2InstanceAttribute -InstanceId i-12345678 -Attribute instanceInitiatedShutdownBehaviorOutput:
InstanceInitiatedShutdownBehavior : stop-
Untuk detail API, lihat DescribeInstanceAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2InstanceMetadata.
- Alat untuk PowerShell V5
-
Contoh 1: Mencantumkan kategori metadata instance yang tersedia yang dapat ditanyakan.
Get-EC2InstanceMetadata -ListCategoryOutput:
AmiId LaunchIndex ManifestPath AncestorAmiId BlockDeviceMapping InstanceId InstanceType LocalHostname LocalIpv4 KernelId AvailabilityZone ProductCode PublicHostname PublicIpv4 PublicKey RamdiskId Region ReservationId SecurityGroup UserData InstanceMonitoring IdentityDocument IdentitySignature IdentityPkcs7Contoh 2: Mengembalikan id Amazon Machine Image (AMI) yang digunakan untuk meluncurkan instance.
Get-EC2InstanceMetadata -Category AmiIdOutput:
ami-b2e756caContoh 3: Contoh ini men JSON-formatted anyakan dokumen identitas untuk instance.
Get-EC2InstanceMetadata -Category IdentityDocument { "availabilityZone" : "us-west-2a", "devpayProductCodes" : null, "marketplaceProductCodes" : null, "version" : "2017-09-30", "instanceId" : "i-01ed50f7e2607f09e", "billingProducts" : [ "bp-6ba54002" ], "instanceType" : "t2.small", "pendingTime" : "2018-03-07T16:26:04Z", "imageId" : "ami-b2e756ca", "privateIp" : "10.0.0.171", "accountId" : "111122223333", "architecture" : "x86_64", "kernelId" : null, "ramdiskId" : null, "region" : "us-west-2" }Contoh 4: Contoh ini menggunakan kueri jalur untuk mendapatkan antarmuka jaringan mac untuk instance.
Get-EC2InstanceMetadata -Path "/network/interfaces/macs"Output:
02:80:7f:ef:4c:e0/Contoh 5: Jika ada peran IAM yang terkait dengan instance, mengembalikan informasi tentang terakhir kali profil instance diperbarui, termasuk LastUpdated tanggal instans, InstanceProfileArn, dan InstanceProfileId.
Get-EC2InstanceMetadata -Path "/iam/info"Output:
{ "Code" : "Success", "LastUpdated" : "2018-03-08T03:38:40Z", "InstanceProfileArn" : "arn:aws:iam::111122223333:instance-profile/MyLaunchRole_Profile", "InstanceProfileId" : "AIPAI4...WVK2RW" }-
Untuk detail API, lihat Get-EC2InstanceMetadata di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2InstanceStatus.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan status instance yang ditentukan.
Get-EC2InstanceStatus -InstanceId i-12345678Output:
AvailabilityZone : us-west-2a Events : {} InstanceId : i-12345678 InstanceState : Amazon.EC2.Model.InstanceState Status : Amazon.EC2.Model.InstanceStatusSummary SystemStatus : Amazon.EC2.Model.InstanceStatusSummary$status = Get-EC2InstanceStatus -InstanceId i-12345678 $status.InstanceStateOutput:
Code Name ---- ---- 16 running$status.StatusOutput:
Details Status ------- ------ {reachability} ok$status.SystemStatusOutput:
Details Status ------- ------ {reachability} ok-
Untuk detail API, lihat DescribeInstanceStatus di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2InternetGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan gateway Internet yang ditentukan.
Get-EC2InternetGateway -InternetGatewayId igw-1a2b3c4dOutput:
Attachments InternetGatewayId Tags ----------- ----------------- ---- {vpc-1a2b3c4d} igw-1a2b3c4d {}Contoh 2: Contoh ini menjelaskan semua gateway Internet Anda.
Get-EC2InternetGatewayOutput:
Attachments InternetGatewayId Tags ----------- ----------------- ---- {vpc-1a2b3c4d} igw-1a2b3c4d {} {} igw-2a3b4c5d {}-
Untuk detail API, lihat DescribeInternetGateways di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2KeyPair.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan pasangan kunci yang ditentukan.
Get-EC2KeyPair -KeyName my-key-pairOutput:
KeyFingerprint KeyName -------------- ------- 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f my-key-pairContoh 2: Contoh ini menjelaskan semua pasangan kunci Anda.
Get-EC2KeyPair-
Untuk detail API, lihat DescribeKeyPairs di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2NetworkAcl.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan ACL jaringan yang ditentukan.
Get-EC2NetworkAcl -NetworkAclId acl-12345678Output:
Associations : {aclassoc-1a2b3c4d} Entries : {Amazon.EC2.Model.NetworkAclEntry, Amazon.EC2.Model.NetworkAclEntry} IsDefault : False NetworkAclId : acl-12345678 Tags : {Name} VpcId : vpc-12345678Contoh 2: Contoh ini menjelaskan aturan untuk ACL jaringan tertentu.
(Get-EC2NetworkAcl -NetworkAclId acl-12345678).EntriesOutput:
CidrBlock : 0.0.0.0/0 Egress : True IcmpTypeCode : PortRange : Protocol : -1 RuleAction : deny RuleNumber : 32767 CidrBlock : 0.0.0.0/0 Egress : False IcmpTypeCode : PortRange : Protocol : -1 RuleAction : deny RuleNumber : 32767Contoh 3: Contoh ini menjelaskan semua ACL jaringan Anda.
Get-EC2NetworkAcl-
Untuk detail API, lihat DescribeNetworkAcls di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2NetworkInterface.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan antarmuka jaringan yang ditentukan.
Get-EC2NetworkInterface -NetworkInterfaceId eni-12345678Output:
Association : Attachment : Amazon.EC2.Model.NetworkInterfaceAttachment AvailabilityZone : us-west-2c Description : Groups : {my-security-group} MacAddress : 0a:e9:a6:19:4c:7f NetworkInterfaceId : eni-12345678 OwnerId : 123456789012 PrivateDnsName : ip-10-0-0-107.us-west-2.compute.internal PrivateIpAddress : 10.0.0.107 PrivateIpAddresses : {ip-10-0-0-107.us-west-2.compute.internal} RequesterId : RequesterManaged : False SourceDestCheck : True Status : in-use SubnetId : subnet-1a2b3c4d TagSet : {} VpcId : vpc-12345678Contoh 2: Contoh ini menjelaskan semua antarmuka jaringan Anda.
Get-EC2NetworkInterface-
Untuk detail API, lihat DescribeNetworkInterfaces di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2NetworkInterfaceAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan antarmuka jaringan yang ditentukan.
Get-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-12345678 -Attribute AttachmentOutput:
Attachment : Amazon.EC2.Model.NetworkInterfaceAttachmentContoh 2: Contoh ini menjelaskan antarmuka jaringan yang ditentukan.
Get-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-12345678 -Attribute DescriptionOutput:
Description : My descriptionContoh 3: Contoh ini menjelaskan antarmuka jaringan yang ditentukan.
Get-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-12345678 -Attribute GroupSetOutput:
Groups : {my-security-group}Contoh 4: Contoh ini menjelaskan antarmuka jaringan yang ditentukan.
Get-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-12345678 -Attribute SourceDestCheckOutput:
SourceDestCheck : True-
Untuk detail API, lihat DescribeNetworkInterfaceAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2PasswordData.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mendekripsi kata sandi yang ditetapkan Amazon EC2 ke akun Administrator untuk instans Windows yang ditentukan. Saat file pem ditentukan, pengaturan sakelar -Decrypt secara otomatis diasumsikan.
Get-EC2PasswordData -InstanceId i-12345678 -PemFile C:\path\my-key-pair.pemOutput:
mYZ(PA9?C)QContoh 2: ( PowerShell Hanya Windows) Memeriksa instance untuk menentukan nama pasangan kunci yang digunakan untuk meluncurkan instance dan kemudian mencoba untuk menemukan data pasangan kunci yang sesuai di penyimpanan konfigurasi AWS Toolkit untuk Visual Studio. Jika data keypair ditemukan kata sandi didekripsi.
Get-EC2PasswordData -InstanceId i-12345678 -DecryptOutput:
mYZ(PA9?C)QContoh 3: Mengembalikan data kata sandi terenkripsi untuk instance.
Get-EC2PasswordData -InstanceId i-12345678Output:
iVz3BAK/WAXV.....dqt8WeMA==-
Untuk detail API, lihat GetPasswordData di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2PlacementGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan grup penempatan yang ditentukan.
Get-EC2PlacementGroup -GroupName my-placement-groupOutput:
GroupName State Strategy --------- ----- -------- my-placement-group available cluster-
Untuk detail API, lihat DescribePlacementGroups di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2PrefixList.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengambil yang tersedia Layanan AWS dalam format daftar awalan untuk wilayah
Get-EC2PrefixListOutput:
Cidrs PrefixListId PrefixListName ----- ------------ -------------- {52.94.5.0/24, 52.119.240.0/21, 52.94.24.0/23} pl-6fa54006 com.amazonaws.eu-west-1.dynamodb {52.218.0.0/17, 54.231.128.0/19} pl-6da54004 com.amazonaws.eu-west-1.s3-
Untuk detail API, lihat DescribePrefixLists di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Region.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan wilayah yang tersedia untuk Anda.
Get-EC2RegionOutput:
Endpoint RegionName -------- ---------- ec2.eu-west-1.amazonaws.com eu-west-1 ec2.ap-southeast-1.amazonaws.com ap-southeast-1 ec2.ap-southeast-2.amazonaws.com ap-southeast-2 ec2.eu-central-1.amazonaws.com eu-central-1 ec2.ap-northeast-1.amazonaws.com ap-northeast-1 ec2.us-east-1.amazonaws.com us-east-1 ec2.sa-east-1.amazonaws.com sa-east-1 ec2.us-west-1.amazonaws.com us-west-1 ec2.us-west-2.amazonaws.com us-west-2-
Untuk detail API, lihat DescribeRegions di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2RouteTable.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan semua tabel rute Anda.
Get-EC2RouteTableOutput:
DestinationCidrBlock : 10.0.0.0/16 DestinationPrefixListId : GatewayId : local InstanceId : InstanceOwnerId : NetworkInterfaceId : Origin : CreateRouteTable State : active VpcPeeringConnectionId : DestinationCidrBlock : 0.0.0.0/0 DestinationPrefixListId : GatewayId : igw-1a2b3c4d InstanceId : InstanceOwnerId : NetworkInterfaceId : Origin : CreateRoute State : active VpcPeeringConnectionId :Contoh 2: Contoh ini mengembalikan detail untuk tabel rute yang ditentukan.
Get-EC2RouteTable -RouteTableId rtb-1a2b3c4dContoh 3: Contoh ini menjelaskan tabel rute untuk VPC yang ditentukan.
Get-EC2RouteTable -Filter @{ Name="vpc-id"; Values="vpc-1a2b3c4d" }Output:
Associations : {rtbassoc-12345678} PropagatingVgws : {} Routes : {, } RouteTableId : rtb-1a2b3c4d Tags : {} VpcId : vpc-1a2b3c4d-
Untuk detail API, lihat DescribeRouteTables di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2ScheduledInstance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan Instance Terjadwal yang ditentukan.
Get-EC2ScheduledInstance -ScheduledInstanceId sci-1234-1234-1234-1234-123456789012Output:
AvailabilityZone : us-west-2b CreateDate : 1/25/2016 1:43:38 PM HourlyPrice : 0.095 InstanceCount : 1 InstanceType : c4.large NetworkPlatform : EC2-VPC NextSlotStartTime : 1/31/2016 1:00:00 AM Platform : Linux/UNIX PreviousSlotEndTime : Recurrence : Amazon.EC2.Model.ScheduledInstanceRecurrence ScheduledInstanceId : sci-1234-1234-1234-1234-123456789012 SlotDurationInHours : 32 TermEndDate : 1/31/2017 1:00:00 AM TermStartDate : 1/31/2016 1:00:00 AM TotalScheduledInstanceHours : 1696Contoh 2: Contoh ini menjelaskan semua Instans Terjadwal Anda.
Get-EC2ScheduledInstance-
Untuk detail API, lihat DescribeScheduledInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2ScheduledInstanceAvailability.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan jadwal yang terjadi setiap minggu pada hari Minggu, dimulai pada tanggal yang ditentukan.
Get-EC2ScheduledInstanceAvailability -Recurrence_Frequency Weekly -Recurrence_Interval 1 -Recurrence_OccurrenceDay 1 -FirstSlotStartTimeRange_EarliestTime 2016-01-31T00:00:00Z -FirstSlotStartTimeRange_LatestTime 2016-01-31T04:00:00ZOutput:
AvailabilityZone : us-west-2b AvailableInstanceCount : 20 FirstSlotStartTime : 1/31/2016 8:00:00 AM HourlyPrice : 0.095 InstanceType : c4.large MaxTermDurationInDays : 366 MinTermDurationInDays : 366 NetworkPlatform : EC2-VPC Platform : Linux/UNIX PurchaseToken : eyJ2IjoiMSIsInMiOjEsImMiOi... Recurrence : Amazon.EC2.Model.ScheduledInstanceRecurrence SlotDurationInHours : 23 TotalScheduledInstanceHours : 1219 ...Contoh 2: Untuk mempersempit hasil, Anda dapat menambahkan filter untuk kriteria seperti sistem operasi, jaringan, dan jenis instance.
-Filter @{ Name="platform";Values="Linux/UNIX" },@{ Name="network-platform";Values="EC2-VPC" },@{ Name="instance-type";Values="c4.large" }-
Untuk detail API, lihat DescribeScheduledInstanceAvailability di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SecurityGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan grup keamanan yang ditentukan untuk VPC. Saat bekerja dengan grup keamanan milik VPC Anda harus menggunakan ID grup keamanan (- GroupId parameter), bukan nama (- GroupName parameter), untuk mereferensikan grup.
Get-EC2SecurityGroup -GroupId sg-12345678Output:
Description : default VPC security group GroupId : sg-12345678 GroupName : default IpPermissions : {Amazon.EC2.Model.IpPermission} IpPermissionsEgress : {Amazon.EC2.Model.IpPermission} OwnerId : 123456789012 Tags : {} VpcId : vpc-12345678Contoh 2: Contoh ini menjelaskan grup keamanan yang ditentukan untuk EC2-Classic. Saat bekerja dengan grup keamanan untuk EC2-Classic Anda dapat menggunakan nama grup (- GroupName parameter) atau ID grup (- GroupId parameter) untuk mereferensikan grup keamanan.
Get-EC2SecurityGroup -GroupName my-security-groupOutput:
Description : my security group GroupId : sg-45678901 GroupName : my-security-group IpPermissions : {Amazon.EC2.Model.IpPermission, Amazon.EC2.Model.IpPermission} IpPermissionsEgress : {} OwnerId : 123456789012 Tags : {} VpcId :Contoh 3: Contoh ini mengambil semua grup keamanan untuk vpc-0fc1ff23456b789eb
Get-EC2SecurityGroup -Filter @{Name="vpc-id";Values="vpc-0fc1ff23456b789eb"}-
Untuk detail API, lihat DescribeSecurityGroups di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Snapshot.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan snapshot yang ditentukan.
Get-EC2Snapshot -SnapshotId snap-12345678Output:
DataEncryptionKeyId : Description : Created by CreateImage(i-1a2b3c4d) for ami-12345678 from vol-12345678 Encrypted : False KmsKeyId : OwnerAlias : OwnerId : 123456789012 Progress : 100% SnapshotId : snap-12345678 StartTime : 10/23/2014 6:01:28 AM State : completed StateMessage : Tags : {} VolumeId : vol-12345678 VolumeSize : 8Contoh 2: Contoh ini menjelaskan snapshot yang memiliki tag 'Nama'.
Get-EC2Snapshot | ? { $_.Tags.Count -gt 0 -and $_.Tags.Key -eq "Name" }Contoh 3: Contoh ini menjelaskan snapshot yang memiliki tag 'Nama' dengan nilai 'TestValue'.
Get-EC2Snapshot | ? { $_.Tags.Count -gt 0 -and $_.Tags.Key -eq "Name" -and $_.Tags.Value -eq "TestValue" }Contoh 4: Contoh ini menjelaskan semua snapshot Anda.
Get-EC2Snapshot -Owner self-
Untuk detail API, lihat DescribeSnapshots di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SnapshotAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan atribut tertentu dari snapshot yang ditentukan.
Get-EC2SnapshotAttribute -SnapshotId snap-12345678 -Attribute ProductCodesOutput:
CreateVolumePermissions ProductCodes SnapshotId ----------------------- ------------ ---------- {} {} snap-12345678Contoh 2: Contoh ini menjelaskan atribut tertentu dari snapshot yang ditentukan.
(Get-EC2SnapshotAttribute -SnapshotId snap-12345678 -Attribute CreateVolumePermission).CreateVolumePermissionsOutput:
Group UserId ----- ------ all-
Untuk detail API, lihat DescribeSnapshotAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SpotDatafeedSubscription.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan umpan data instans Spot Anda.
Get-EC2SpotDatafeedSubscriptionOutput:
Bucket : amzn-s3-demo-bucket Fault : OwnerId : 123456789012 Prefix : spotdata State : Active-
Untuk detail API, lihat DescribeSpotDatafeedSubscription di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SpotFleetInstance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan instance yang terkait dengan permintaan armada Spot yang ditentukan.
Get-EC2SpotFleetInstance -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLEOutput:
InstanceId InstanceType SpotInstanceRequestId ---------- ------------ --------------------- i-f089262a c3.large sir-12345678 i-7e8b24a4 c3.large sir-87654321-
Untuk detail API, lihat DescribeSpotFleetInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SpotFleetRequest.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan permintaan armada Spot yang ditentukan.
Get-EC2SpotFleetRequest -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE | format-listOutput:
ConfigData : Amazon.EC2.Model.SpotFleetRequestConfigData CreateTime : 12/26/2015 8:23:33 AM SpotFleetRequestId : sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE SpotFleetRequestState : activeContoh 2: Contoh ini menjelaskan semua permintaan armada Spot Anda.
Get-EC2SpotFleetRequest-
Untuk detail API, lihat DescribeSpotFleetRequests di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SpotFleetRequestHistory.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan riwayat permintaan armada Spot yang ditentukan.
Get-EC2SpotFleetRequestHistory -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE -StartTime 2015-12-26T00:00:00ZOutput:
HistoryRecords : {Amazon.EC2.Model.HistoryRecord, Amazon.EC2.Model.HistoryRecord...} LastEvaluatedTime : 12/26/2015 8:29:11 AM NextToken : SpotFleetRequestId : sfr-088bc5f1-7e7b-451a-bd13-757f10672b93 StartTime : 12/25/2015 8:00:00 AM(Get-EC2SpotFleetRequestHistory -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE -StartTime 2015-12-26T00:00:00Z).HistoryRecordsOutput:
EventInformation EventType Timestamp ---------------- --------- --------- Amazon.EC2.Model.EventInformation fleetRequestChange 12/26/2015 8:23:33 AM Amazon.EC2.Model.EventInformation fleetRequestChange 12/26/2015 8:23:33 AM Amazon.EC2.Model.EventInformation fleetRequestChange 12/26/2015 8:23:33 AM Amazon.EC2.Model.EventInformation launched 12/26/2015 8:25:34 AM Amazon.EC2.Model.EventInformation launched 12/26/2015 8:25:05 AM-
Untuk detail API, lihat DescribeSpotFleetRequestHistory di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SpotInstanceRequest.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan permintaan instance Spot yang ditentukan.
Get-EC2SpotInstanceRequest -SpotInstanceRequestId sir-12345678Output:
ActualBlockHourlyPrice : AvailabilityZoneGroup : BlockDurationMinutes : 0 CreateTime : 4/8/2015 2:51:33 PM Fault : InstanceId : i-12345678 LaunchedAvailabilityZone : us-west-2b LaunchGroup : LaunchSpecification : Amazon.EC2.Model.LaunchSpecification ProductDescription : Linux/UNIX SpotInstanceRequestId : sir-12345678 SpotPrice : 0.020000 State : active Status : Amazon.EC2.Model.SpotInstanceStatus Tags : {Name} Type : one-timeContoh 2: Contoh ini menjelaskan semua permintaan instans Spot Anda.
Get-EC2SpotInstanceRequest-
Untuk detail API, lihat DescribeSpotInstanceRequests di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2SpotPriceHistory.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mendapatkan 10 entri terakhir dalam riwayat harga Spot untuk jenis instans dan Zona Ketersediaan yang ditentukan. Perhatikan bahwa nilai yang ditentukan untuk AvailabilityZone parameter - harus valid untuk nilai wilayah yang diberikan ke parameter -Region cmdlet (tidak ditampilkan dalam contoh) atau ditetapkan sebagai default di shell. Perintah contoh ini mengasumsikan wilayah default 'us-west-2' telah ditetapkan di lingkungan.
Get-EC2SpotPriceHistory -InstanceType c3.large -AvailabilityZone us-west-2a -MaxResult 10Output:
AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017300 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 7:39:49 AM AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017200 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 7:38:29 AM AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017300 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 6:57:13 AM ...-
Untuk detail API, lihat DescribeSpotPriceHistory di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Subnet.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan subnet yang ditentukan.
Get-EC2Subnet -SubnetId subnet-1a2b3c4dOutput:
AvailabilityZone : us-west-2c AvailableIpAddressCount : 251 CidrBlock : 10.0.0.0/24 DefaultForAz : False MapPublicIpOnLaunch : False State : available SubnetId : subnet-1a2b3c4d Tags : {} VpcId : vpc-12345678Contoh 2: Contoh ini menjelaskan semua subnet Anda.
Get-EC2Subnet-
Untuk detail API, lihat DescribeSubnets di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Tag.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengambil tag untuk tipe sumber daya 'gambar'
Get-EC2Tag -Filter @{Name="resource-type";Values="image"}Output:
Key ResourceId ResourceType Value --- ---------- ------------ ----- Name ami-0a123b4ccb567a8ea image Win7-Imported auto-delete ami-0a123b4ccb567a8ea image neverContoh 2: Contoh ini mengambil semua tag untuk semua sumber daya dan mengelompokkannya berdasarkan jenis sumber daya
Get-EC2Tag | Group-Object resourcetypeOutput:
Count Name Group ----- ---- ----- 9 subnet {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription...} 53 instance {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription...} 3 route-table {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription} 5 security-group {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription...} 30 volume {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription...} 1 internet-gateway {Amazon.EC2.Model.TagDescription} 3 network-interface {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription} 4 elastic-ip {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription} 1 dhcp-options {Amazon.EC2.Model.TagDescription} 2 image {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription} 3 vpc {Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription, Amazon.EC2.Model.TagDescription}Contoh 3: Contoh ini menampilkan semua sumber daya dengan tag 'auto-delete' dengan nilai 'tidak' untuk wilayah yang diberikan
Get-EC2Tag -Region eu-west-1 -Filter @{Name="tag:auto-delete";Values="no"}Output:
Key ResourceId ResourceType Value --- ---------- ------------ ----- auto-delete i-0f1bce234d5dd678b instance no auto-delete vol-01d234aa5678901a2 volume no auto-delete vol-01234bfb5def6f7b8 volume no auto-delete vol-01ccb23f4c5e67890 volume noContoh 4: Contoh ini memperoleh semua sumber daya dengan tag 'auto-delete' dengan nilai 'tidak' dan filter lebih lanjut di pipa berikutnya untuk mengurai hanya jenis sumber daya 'instance' dan akhirnya membuat tag 'ThisInstance' untuk setiap sumber daya instance dengan nilai sebagai id instance itu sendiri
Get-EC2Tag -Region eu-west-1 -Filter @{Name="tag:auto-delete";Values="no"} | Where-Object ResourceType -eq "instance" | ForEach-Object {New-EC2Tag -ResourceId $_.ResourceId -Tag @{Key="ThisInstance";Value=$_.ResourceId}}Contoh 5: Contoh ini mengambil tag untuk semua sumber daya instance serta kunci 'Nama' dan menampilkannya dalam format tabel
Get-EC2Tag -Filter @{Name="resource-type";Values="instance"},@{Name="key";Values="Name"} | Select-Object ResourceId, @{Name="Name-Tag";Expression={$PSItem.Value}} | Format-Table -AutoSizeOutput:
ResourceId Name-Tag ---------- -------- i-012e3cb4df567e1aa jump1 i-01c23a45d6fc7a89f repro-3Contoh 6: Contoh ini memvalidasi izin untuk mendapatkan Tag EC2 menggunakan DryRun parameter tanpa benar-benar mengambilnya. Catatan: Ini menimbulkan pengecualian jika berhasil yang merupakan perilaku yang diharapkan.
Get-EC2Tag -DryRun $trueOutput:
Get-EC2Tag: Request would have succeeded, but DryRun flag is set.-
Untuk detail API, lihat DescribeTags di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Volume.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan volume EBS yang ditentukan.
Get-EC2Volume -VolumeId vol-12345678Output:
Attachments : {} AvailabilityZone : us-west-2c CreateTime : 7/17/2015 4:35:19 PM Encrypted : False Iops : 90 KmsKeyId : Size : 30 SnapshotId : snap-12345678 State : in-use Tags : {} VolumeId : vol-12345678 VolumeType : standardContoh 2: Contoh ini menjelaskan volume EBS Anda yang memiliki status 'tersedia'.
Get-EC2Volume -Filter @{ Name="status"; Values="available" }Output:
Attachments : {} AvailabilityZone : us-west-2c CreateTime : 12/21/2015 2:31:29 PM Encrypted : False Iops : 60 KmsKeyId : Size : 20 SnapshotId : snap-12345678 State : available Tags : {} VolumeId : vol-12345678 VolumeType : gp2 ...Contoh 3: Contoh ini menjelaskan semua volume EBS Anda.
Get-EC2Volume-
Untuk detail API, lihat DescribeVolumes di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VolumeAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan atribut yang ditentukan dari volume yang ditentukan.
Get-EC2VolumeAttribute -VolumeId vol-12345678 -Attribute AutoEnableIOOutput:
AutoEnableIO ProductCodes VolumeId ------------ ------------ -------- False {} vol-12345678-
Untuk detail API, lihat DescribeVolumeAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VolumeStatus.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan status volume yang ditentukan.
Get-EC2VolumeStatus -VolumeId vol-12345678Output:
Actions : {} AvailabilityZone : us-west-2a Events : {} VolumeId : vol-12345678 VolumeStatus : Amazon.EC2.Model.VolumeStatusInfo(Get-EC2VolumeStatus -VolumeId vol-12345678).VolumeStatusOutput:
Details Status ------- ------ {io-enabled, io-performance} ok(Get-EC2VolumeStatus -VolumeId vol-12345678).VolumeStatus.DetailsOutput:
Name Status ---- ------ io-enabled passed io-performance not-applicable-
Untuk detail API, lihat DescribeVolumeStatus di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2Vpc.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan VPC yang ditentukan.
Get-EC2Vpc -VpcId vpc-12345678Output:
CidrBlock : 10.0.0.0/16 DhcpOptionsId : dopt-1a2b3c4d InstanceTenancy : default IsDefault : False State : available Tags : {Name} VpcId : vpc-12345678Contoh 2: Contoh ini menjelaskan VPC default (hanya bisa ada satu per wilayah). Jika akun Anda mendukung EC2-Classic di wilayah ini, tidak ada VPC default.
Get-EC2Vpc -Filter @{Name="isDefault"; Values="true"}Output:
CidrBlock : 172.31.0.0/16 DhcpOptionsId : dopt-12345678 InstanceTenancy : default IsDefault : True State : available Tags : {} VpcId : vpc-45678901Contoh 3: Contoh ini menjelaskan VPC yang cocok dengan filter yang ditentukan (yaitu, memiliki CIDR yang cocok dengan nilai '10.0.0. 0/16'dan berada dalam keadaan' tersedia ').
Get-EC2Vpc -Filter @{Name="cidr"; Values="10.0.0.0/16"},@{Name="state";Values="available"}Contoh 4: Contoh ini menjelaskan semua VPC Anda.
Get-EC2Vpc-
Untuk detail API, lihat DescribeVpcs di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VpcAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan atribut 'aktifkan DnsSupport '.
Get-EC2VpcAttribute -VpcId vpc-12345678 -Attribute enableDnsSupportOutput:
EnableDnsSupport ---------------- TrueContoh 2: Contoh ini menjelaskan atribut 'aktifkan DnsHostnames '.
Get-EC2VpcAttribute -VpcId vpc-12345678 -Attribute enableDnsHostnamesOutput:
EnableDnsHostnames ------------------ True-
Untuk detail API, lihat DescribeVpcAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VpcClassicLink.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh di atas mengembalikan semua VPC dengan ClassicLinkEnabled statusnya untuk wilayah
Get-EC2VpcClassicLink -Region eu-west-1Output:
ClassicLinkEnabled Tags VpcId ------------------ ---- ----- False {Name} vpc-0fc1ff23f45b678eb False {} vpc-01e23c4a5d6db78e9 False {Name} vpc-0123456b078b9d01f False {} vpc-12cf3b4f False {Name} vpc-0b12d3456a7e8901d-
Untuk detail API, lihat DescribeVpcClassicLink di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VpcClassicLinkDnsSupport.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan status dukungan ClassicLink DNS VPC untuk wilayah eu-west-1
Get-EC2VpcClassicLinkDnsSupport -VpcId vpc-0b12d3456a7e8910d -Region eu-west-1Output:
ClassicLinkDnsSupported VpcId ----------------------- ----- False vpc-0b12d3456a7e8910d False vpc-12cf3b4f-
Untuk detail API, lihat DescribeVpcClassicLinkDnsSupport di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VpcEndpoint.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan satu atau lebih titik akhir VPC Anda untuk wilayah eu-west-1. Kemudian menyalurkan output ke perintah berikutnya, yang memilih VpcEndpointId properti dan mengembalikan array VPC ID sebagai array string
Get-EC2VpcEndpoint -Region eu-west-1 | Select-Object -ExpandProperty VpcEndpointIdOutput:
vpce-01a2ab3f4f5cc6f7d vpce-01d2b345a6787890b vpce-0012e34d567890e12 vpce-0c123db4567890123Contoh 2: Contoh ini menjelaskan semua titik akhir vpc untuk wilayah eu-west-1 dan memilih VpcEndpointId, VpcId, ServiceName dan PrivateDnsEnabled properti untuk menyajikannya dalam format tabular
Get-EC2VpcEndpoint -Region eu-west-1 | Select-Object VpcEndpointId, VpcId, ServiceName, PrivateDnsEnabled | Format-Table -AutoSizeOutput:
VpcEndpointId VpcId ServiceName PrivateDnsEnabled ------------- ----- ----------- ----------------- vpce-02a2ab2f2f2cc2f2d vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ssm True vpce-01d1b111a1114561b vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ec2 True vpce-0011e23d45167e838 vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ec2messages True vpce-0c123db4567890123 vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ssmmessages TrueContoh 3: Contoh ini mengekspor dokumen kebijakan untuk VPC Endpoint vpce-01a2ab3f4f5cc6f7d ke dalam file json
Get-EC2VpcEndpoint -Region eu-west-1 -VpcEndpointId vpce-01a2ab3f4f5cc6f7d | Select-Object -expand PolicyDocument | Out-File vpce_policyDocument.json-
Untuk detail API, lihat DescribeVpcEndpoints di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VpcEndpointService.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan layanan titik akhir VPC EC2 dengan filter yang diberikan, dalam hal ini com.amazonaws.eu-west-1.ecs. Selanjutnya, itu juga memperluas ServiceDetails properti dan menampilkan detailnya
Get-EC2VpcEndpointService -Region eu-west-1 -MaxResult 5 -Filter @{Name="service-name";Values="com.amazonaws.eu-west-1.ecs"} | Select-Object -ExpandProperty ServiceDetailsOutput:
AcceptanceRequired : False AvailabilityZones : {eu-west-1a, eu-west-1b, eu-west-1c} BaseEndpointDnsNames : {ecs.eu-west-1.vpce.amazonaws.com} Owner : amazon PrivateDnsName : ecs.eu-west-1.amazonaws.com ServiceName : com.amazonaws.eu-west-1.ecs ServiceType : {Amazon.EC2.Model.ServiceTypeDetail} VpcEndpointPolicySupported : FalseContoh 2: Contoh ini mengambil semua layanan EC2 VPC Endpoint dan mengembalikan “ssm” yang ServiceNames cocok
Get-EC2VpcEndpointService -Region eu-west-1 | Select-Object -ExpandProperty Servicenames | Where-Object { -match "ssm"}Output:
com.amazonaws.eu-west-1.ssm com.amazonaws.eu-west-1.ssmmessages-
Untuk detail API, lihat DescribeVpcEndpointServices di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VpnConnection.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan koneksi VPN yang ditentukan.
Get-EC2VpnConnection -VpnConnectionId vpn-12345678Output:
CustomerGatewayConfiguration : [XML document] CustomerGatewayId : cgw-1a2b3c4d Options : Amazon.EC2.Model.VpnConnectionOptions Routes : {Amazon.EC2.Model.VpnStaticRoute} State : available Tags : {} Type : ipsec.1 VgwTelemetry : {Amazon.EC2.Model.VgwTelemetry, Amazon.EC2.Model.VgwTelemetry} VpnConnectionId : vpn-12345678 VpnGatewayId : vgw-1a2b3c4dContoh 2: Contoh ini menjelaskan setiap koneksi VPN yang statusnya tertunda atau tersedia.
$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = @( "pending", "available" ) Get-EC2VpnConnection -Filter $filterContoh 3: Contoh ini menjelaskan semua koneksi VPN Anda.
Get-EC2VpnConnection-
Untuk detail API, lihat DescribeVpnConnections di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-EC2VpnGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menjelaskan gateway pribadi virtual yang ditentukan.
Get-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4dOutput:
AvailabilityZone : State : available Tags : {} Type : ipsec.1 VpcAttachments : {vpc-12345678} VpnGatewayId : vgw-1a2b3c4dContoh 2: Contoh ini menjelaskan gateway pribadi virtual yang statusnya tertunda atau tersedia.
$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = @( "pending", "available" ) Get-EC2VpnGateway -Filter $filterContoh 3: Contoh ini menjelaskan semua gateway pribadi virtual Anda.
Get-EC2VpnGateway-
Untuk detail API, lihat DescribeVpnGateways di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGrant-EC2SecurityGroupEgress.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mendefinisikan aturan keluar untuk grup keamanan yang ditentukan untuk EC2-VPC. Aturan memberikan akses ke rentang alamat IP yang ditentukan pada port TCP 80. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
$ip = @{ IpProtocol="tcp"; FromPort="80"; ToPort="80"; IpRanges="203.0.113.0/24" } Grant-EC2SecurityGroupEgress -GroupId sg-12345678 -IpPermission $ipContoh 2: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat IpPermission objek.
$ip = New-Object Amazon.EC2.Model.IpPermission $ip.IpProtocol = "tcp" $ip.FromPort = 80 $ip.ToPort = 80 $ip.IpRanges.Add("203.0.113.0/24") Grant-EC2SecurityGroupEgress -GroupId sg-12345678 -IpPermission $ipContoh 3: Contoh ini memberikan akses ke grup keamanan sumber yang ditentukan pada port TCP 80.
$ug = New-Object Amazon.EC2.Model.UserIdGroupPair $ug.GroupId = "sg-1a2b3c4d" $ug.UserId = "123456789012" Grant-EC2SecurityGroupEgress -GroupId sg-12345678 -IpPermission @( @{ IpProtocol="tcp"; FromPort="80"; ToPort="80"; UserIdGroupPairs=$ug } )-
Untuk detail API, lihat AuthorizeSecurityGroupEgress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGrant-EC2SecurityGroupIngress.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mendefinisikan aturan masuk untuk grup keamanan untuk EC2-VPC. Aturan ini memberikan akses ke alamat IP tertentu untuk SSH (port 22) dan RDC (port 3389). Perhatikan bahwa Anda harus mengidentifikasi grup keamanan untuk EC2-VPC menggunakan ID grup keamanan bukan nama grup keamanan. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
$ip1 = @{ IpProtocol="tcp"; FromPort="22"; ToPort="22"; IpRanges="203.0.113.25/32" } $ip2 = @{ IpProtocol="tcp"; FromPort="3389"; ToPort="3389"; IpRanges="203.0.113.25/32" } Grant-EC2SecurityGroupIngress -GroupId sg-12345678 -IpPermission @( $ip1, $ip2 )Contoh 2: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat IpPermission objek.
$ip1 = New-Object Amazon.EC2.Model.IpPermission $ip1.IpProtocol = "tcp" $ip1.FromPort = 22 $ip1.ToPort = 22 $ip1.IpRanges.Add("203.0.113.25/32") $ip2 = new-object Amazon.EC2.Model.IpPermission $ip2.IpProtocol = "tcp" $ip2.FromPort = 3389 $ip2.ToPort = 3389 $ip2.IpRanges.Add("203.0.113.25/32") Grant-EC2SecurityGroupIngress -GroupId sg-12345678 -IpPermission @( $ip1, $ip2 )Contoh 3: Contoh ini mendefinisikan aturan masuk untuk grup keamanan untuk EC2-Classic. Aturan ini memberikan akses ke alamat IP tertentu untuk SSH (port 22) dan RDC (port 3389). Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
$ip1 = @{ IpProtocol="tcp"; FromPort="22"; ToPort="22"; IpRanges="203.0.113.25/32" } $ip2 = @{ IpProtocol="tcp"; FromPort="3389"; ToPort="3389"; IpRanges="203.0.113.25/32" } Grant-EC2SecurityGroupIngress -GroupName "my-security-group" -IpPermission @( $ip1, $ip2 )Contoh 4: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat IpPermission objek.
$ip1 = New-Object Amazon.EC2.Model.IpPermission $ip1.IpProtocol = "tcp" $ip1.FromPort = 22 $ip1.ToPort = 22 $ip1.IpRanges.Add("203.0.113.25/32") $ip2 = new-object Amazon.EC2.Model.IpPermission $ip2.IpProtocol = "tcp" $ip2.FromPort = 3389 $ip2.ToPort = 3389 $ip2.IpRanges.Add("203.0.113.25/32") Grant-EC2SecurityGroupIngress -GroupName "my-security-group" -IpPermission @( $ip1, $ip2 )Contoh 5: Contoh ini memberikan akses port TCP 8081 dari grup keamanan sumber yang ditentukan (sg-1a2b3c4d) ke grup keamanan yang ditentukan (sg-12345678).
$ug = New-Object Amazon.EC2.Model.UserIdGroupPair $ug.GroupId = "sg-1a2b3c4d" $ug.UserId = "123456789012" Grant-EC2SecurityGroupIngress -GroupId sg-12345678 -IpPermission @( @{ IpProtocol="tcp"; FromPort="8081"; ToPort="8081"; UserIdGroupPairs=$ug } )Contoh 6: Contoh ini menambahkan CIDR 5.5.5. 5/32 ke aturan Ingress keamanan Grup sg-1234abcd untuk lalu lintas port TCP 22 dengan deskripsi.
$IpRange = New-Object -TypeName Amazon.EC2.Model.IpRange $IpRange.CidrIp = "5.5.5.5/32" $IpRange.Description = "SSH from Office" $IpPermission = New-Object Amazon.EC2.Model.IpPermission $IpPermission.IpProtocol = "tcp" $IpPermission.ToPort = 22 $IpPermission.FromPort = 22 $IpPermission.Ipv4Ranges = $IpRange Grant-EC2SecurityGroupIngress -GroupId sg-1234abcd -IpPermission $IpPermission-
Untuk detail API, lihat AuthorizeSecurityGroupIngress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanImport-EC2Image.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengimpor gambar mesin virtual disk tunggal dari bucket Amazon S3 yang ditentukan ke Amazon EC2 dengan token idempotensi. Contoh ini mengharuskan Peran Layanan Impor VM dengan nama default 'vmimport' ada, dengan kebijakan yang mengizinkan akses Amazon EC2 ke bucket yang ditentukan, seperti yang dijelaskan dalam topik VM Impor Prequisite. Untuk menggunakan peran khusus, tentukan nama peran menggunakan
-RoleNameparameter.$container = New-Object Amazon.EC2.Model.ImageDiskContainer $container.Format="VMDK" $container.UserBucket = New-Object Amazon.EC2.Model.UserBucket $container.UserBucket.S3Bucket = "amzn-s3-demo-bucket" $container.UserBucket.S3Key = "Win_2008_Server_Standard_SP2_64-bit-disk1.vmdk" $parms = @{ "ClientToken"="idempotencyToken" "Description"="Windows 2008 Standard Image Import" "Platform"="Windows" "LicenseType"="AWS" } Import-EC2Image -DiskContainer $container @parmsOutput:
Architecture : Description : Windows 2008 Standard Image Hypervisor : ImageId : ImportTaskId : import-ami-abcdefgh LicenseType : AWS Platform : Windows Progress : 2 SnapshotDetails : {} Status : active StatusMessage : pending-
Untuk detail API, lihat ImportImage di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanImport-EC2KeyPair.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengimpor kunci publik ke EC2. Baris pertama menyimpan isi file kunci publik (*.pub) dalam variabel
$publickey. Selanjutnya, contoh mengonversi format UTF8 dari file kunci publik ke Base64-encoded string, dan menyimpan string yang dikonversi dalam variabel.$pkbase64Di baris terakhir, kunci publik yang dikonversi diimpor ke EC2. Cmdlet mengembalikan sidik jari kunci dan nama sebagai hasil.$publickey=[Io.File]::ReadAllText("C:\Users\TestUser\.ssh\id_rsa.pub") $pkbase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($publickey)) Import-EC2KeyPair -KeyName Example-user-key -PublicKey $pkbase64Output:
KeyFingerprint KeyName -------------- ------- do:d0:15:8f:79:97:12:be:00:fd:df:31:z3:b1:42:z1 Example-user-key-
Untuk detail API, lihat ImportKeyPair di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanImport-EC2Snapshot.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengimpor gambar disk VM format 'VMDK' ke snapshot Amazon EBS. Contoh ini memerlukan Peran Layanan Impor VM dengan nama default 'vmimport', dengan kebijakan yang mengizinkan akses Amazon EC2 ke bucket yang ditentukan, seperti yang dijelaskan dalam
VM Import Prequisitestopik di http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/VMImportPrerequisites.html. Untuk menggunakan peran khusus, tentukan nama peran menggunakan parameter.-RoleName$parms = @{ "ClientToken"="idempotencyToken" "Description"="Disk Image Import" "DiskContainer_Description" = "Data disk" "DiskContainer_Format" = "VMDK" "DiskContainer_S3Bucket" = "amzn-s3-demo-bucket" "DiskContainer_S3Key" = "datadiskimage.vmdk" } Import-EC2Snapshot @parmsOutput:
Description ImportTaskId SnapshotTaskDetail ----------------- -------------------- ------------------ Disk Image Import import-snap-abcdefgh Amazon.EC2.Model.SnapshotTaskDetail-
Untuk detail API, lihat ImportSnapshot di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanMove-EC2AddressToVpc.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memindahkan instance EC2 dengan alamat IP publik 12.345.67.89 ke EC2-VPC platform di wilayah AS Timur (Virginia Utara).
Move-EC2AddressToVpc -PublicIp 12.345.67.89 -Region us-east-1Contoh 2: Contoh ini menyalurkan hasil Get-EC2Instance perintah ke Move-EC2AddressToVpc cmdlet. Per Get-EC2Instance intah mendapatkan instance yang ditentukan oleh ID instance, kemudian mengembalikan properti alamat IP publik dari instance tersebut.
(Get-EC2Instance -Instance i-12345678).Instances.PublicIpAddress | Move-EC2AddressToVpc-
Untuk detail API, lihat MoveAddressToVpc di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Address.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengalokasikan alamat IP Elastic untuk digunakan dengan instance di VPC.
New-EC2Address -Domain VpcOutput:
AllocationId Domain PublicIp ------------ ------ -------- eipalloc-12345678 vpc 198.51.100.2Contoh 2: Contoh ini mengalokasikan alamat IP Elastic untuk digunakan dengan instance di. EC2-Classic
New-EC2AddressOutput:
AllocationId Domain PublicIp ------------ ------ -------- standard 203.0.113.17-
Untuk detail API, lihat AllocateAddress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2CustomerGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat gateway pelanggan yang ditentukan.
New-EC2CustomerGateway -Type ipsec.1 -PublicIp 203.0.113.12 -BgpAsn 65534Output:
BgpAsn : 65534 CustomerGatewayId : cgw-1a2b3c4d IpAddress : 203.0.113.12 State : available Tags : {} Type : ipsec.1-
Untuk detail API, lihat CreateCustomerGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2DhcpOption.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat set opsi DHCP yang ditentukan. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau yang lebih baru.
$options = @( @{Key="domain-name";Values=@("abc.local")}, @{Key="domain-name-servers";Values=@("10.0.0.101","10.0.0.102")}) New-EC2DhcpOption -DhcpConfiguration $optionsOutput:
DhcpConfigurations DhcpOptionsId Tags ------------------ ------------- ---- {domain-name, domain-name-servers} dopt-1a2b3c4d {}Contoh 2: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat setiap opsi DHCP.
$option1 = New-Object Amazon.EC2.Model.DhcpConfiguration $option1.Key = "domain-name" $option1.Values = "abc.local" $option2 = New-Object Amazon.EC2.Model.DhcpConfiguration $option2.Key = "domain-name-servers" $option2.Values = @("10.0.0.101","10.0.0.102") New-EC2DhcpOption -DhcpConfiguration @($option1, $option2)Output:
DhcpConfigurations DhcpOptionsId Tags ------------------ ------------- ---- {domain-name, domain-name-servers} dopt-2a3b4c5d {}-
Untuk detail API, lihat CreateDhcpOptions di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2FlowLog.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat log aliran EC2 untuk subnet subnet-1d234567 ke cloud-watch-log bernama 'subnet1-log' untuk semua lalu lintas 'REJECT' menggunakan perimsi peran 'Admin'
New-EC2FlowLog -ResourceId "subnet-1d234567" -LogDestinationType cloud-watch-logs -LogGroupName subnet1-log -TrafficType "REJECT" -ResourceType Subnet -DeliverLogsPermissionArn "arn:aws:iam::98765432109:role/Admin"Output:
ClientToken FlowLogIds Unsuccessful ----------- ---------- ------------ m1VN2cxP3iB4qo//VUKl5EU6cF7gQLOxcqNefvjeTGw= {fl-012fc34eed5678c9d} {}-
Untuk detail API, lihat CreateFlowLogs di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Host.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengalokasikan Host Khusus ke akun Anda untuk jenis instans dan zona ketersediaan tertentu
New-EC2Host -AutoPlacement on -AvailabilityZone eu-west-1b -InstanceType m4.xlarge -Quantity 1Output:
h-01e23f4cd567890f3-
Untuk detail API, lihat AllocateHosts di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2HostReservation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membeli penawaran reservasi hro-0c1f23456789d0ab dengan konfigurasi yang sesuai dengan Dedicated Host h-01e23f4cd567890f1
New-EC2HostReservation -OfferingId hro-0c1f23456789d0ab HostIdSet h-01e23f4cd567890f1Output:
ClientToken : CurrencyCode : Purchase : {hr-0123f4b5d67bedc89} TotalHourlyPrice : 1.307 TotalUpfrontPrice : 0.000-
Untuk detail API, lihat PurchaseHostReservation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Image.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat AMI dengan nama dan deskripsi yang ditentukan, dari instance yang ditentukan. Amazon EC2 mencoba mematikan instans dengan bersih sebelum membuat gambar, dan memulai ulang instans setelah selesai.
New-EC2Image -InstanceId i-12345678 -Name "my-web-server" -Description "My web server AMI"Contoh 2: Contoh ini membuat AMI dengan nama dan deskripsi yang ditentukan, dari instance yang ditentukan. Amazon EC2 membuat gambar tanpa mematikan dan memulai ulang instance; oleh karena itu, integritas sistem file pada gambar yang dibuat tidak dapat dijamin.
New-EC2Image -InstanceId i-12345678 -Name "my-web-server" -Description "My web server AMI" -NoReboot $trueContoh 3: Contoh ini membuat AMI dengan tiga volume. Volume pertama didasarkan pada snapshot Amazon EBS. Volume kedua adalah volume Amazon EBS 100 GiB kosong. Volume ketiga adalah volume penyimpanan instance. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
$ebsBlock1 = @{SnapshotId="snap-1a2b3c4d"} $ebsBlock2 = @{VolumeSize=100} New-EC2Image -InstanceId i-12345678 -Name "my-web-server" -Description "My web server AMI" -BlockDeviceMapping @( @{DeviceName="/dev/sdf";Ebs=$ebsBlock1}, @{DeviceName="/dev/sdg";Ebs=$ebsBlock2}, @{DeviceName="/dev/sdc";VirtualName="ephemeral0"})-
Untuk detail API, lihat CreateImage di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Instance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini meluncurkan satu instance AMI yang ditentukan dalam EC2-Classic atau VPC default.
New-EC2Instance -ImageId ami-12345678 -MinCount 1 -MaxCount 1 -InstanceType m3.medium -KeyName my-key-pair -SecurityGroup my-security-groupContoh 2: Contoh ini meluncurkan satu instance dari AMI yang ditentukan dalam VPC.
New-EC2Instance -ImageId ami-12345678 -MinCount 1 -MaxCount 1 -SubnetId subnet-12345678 -InstanceType t2.micro -KeyName my-key-pair -SecurityGroupId sg-12345678Contoh 3: Untuk menambahkan volume EBS atau volume penyimpanan instans, tentukan pemetaan perangkat blok dan tambahkan ke perintah. Contoh ini menambahkan volume penyimpanan instance.
$bdm = New-Object Amazon.EC2.Model.BlockDeviceMapping $bdm.VirtualName = "ephemeral0" $bdm.DeviceName = "/dev/sdf" New-EC2Instance -ImageId ami-12345678 -BlockDeviceMapping $bdm ...Contoh 4: Untuk menentukan salah satu AMI Windows saat ini, dapatkan ID AMI menggunakan Get-SSMLatestEC2Image. Contoh ini meluncurkan instance dari AMI dasar saat ini untuk Windows Server 2016.
$ami = (Get-SSMLatestEC2Image -Path 'ami-windows-latest' -ImageName 'WINDOWS*2016*English*Core*BASE').Value New-EC2Instance -ImageId $ami ...Contoh 5: Meluncurkan instance ke lingkungan host khusus yang ditentukan.
New-EC2Instance -ImageId ami-1a2b3c4d -InstanceType m4.large -KeyName my-key-pair -SecurityGroupId sg-1a2b3c4d -AvailabilityZone us-west-1a -Tenancy host -HostID h-1a2b3c4d5e6f1a2b3Contoh 6: Permintaan ini meluncurkan dua instance dan menerapkan tag dengan kunci server web dan nilai produksi ke instance. Permintaan juga menerapkan tag dengan kunci cost-center dan nilai cc123 ke volume yang dibuat (dalam hal ini, volume root untuk setiap instance).
$tag1 = @{ Key="webserver"; Value="production" } $tag2 = @{ Key="cost-center"; Value="cc123" } $tagspec1 = new-object Amazon.EC2.Model.TagSpecification $tagspec1.ResourceType = "instance" $tagspec1.Tags.Add($tag1) $tagspec2 = new-object Amazon.EC2.Model.TagSpecification $tagspec2.ResourceType = "volume" $tagspec2.Tags.Add($tag2) New-EC2Instance -ImageId "ami-1a2b3c4d" -KeyName "my-key-pair" -MaxCount 2 -InstanceType "t2.large" -SubnetId "subnet-1a2b3c4d" -TagSpecification $tagspec1,$tagspec2Contoh 7: Contoh ini memvalidasi izin untuk meluncurkan instance EC2 menggunakan DryRun parameter tanpa benar-benar membuat instance. Catatan: Ini menimbulkan pengecualian jika berhasil yang merupakan perilaku yang diharapkan.
New-EC2Instance -ImageId 'ami-12345678' -InstanceType 't2.micro' -KeyName 'my-key-pair' -Region 'us-west-2' -DryRun $true-
Untuk detail API, lihat RunInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2InstanceExportTask.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengekspor instance yang dihentikan
i-0800b00a00EXAMPLE,, sebagai hard disk virtual (VHD) ke buckettestbucket-export-instances-2019S3. Lingkungan target adalahMicrosoft, dan parameter wilayah ditambahkan karena instance berada dius-east-1wilayah, sedangkan Wil AWS ayah default pengguna bukan us-east-1. Untuk mendapatkan status tugas ekspor, salinExportTaskIdnilai dari hasil perintah ini, lalu jalankanGet-EC2ExportTask -ExportTaskId export_task_ID_from_results.New-EC2InstanceExportTask -InstanceId i-0800b00a00EXAMPLE -ExportToS3Task_DiskImageFormat VHD -ExportToS3Task_S3Bucket "amzn-s3-demo-bucket" -TargetEnvironment Microsoft -Region us-east-1Output:
Description : ExportTaskId : export-i-077c73108aEXAMPLE ExportToS3Task : Amazon.EC2.Model.ExportToS3Task InstanceExportDetails : Amazon.EC2.Model.InstanceExportDetails State : active StatusMessage :-
Untuk detail API, lihat CreateInstanceExportTask di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2InternetGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat gateway Internet.
New-EC2InternetGatewayOutput:
Attachments InternetGatewayId Tags ----------- ----------------- ---- {} igw-1a2b3c4d {}-
Untuk detail API, lihat CreateInternetGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2KeyPair.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat pasangan kunci dan menangkap kunci pribadi PEM-encoded RSA dalam file dengan nama yang ditentukan. Saat Anda menggunakan PowerShell, pengkodean harus diatur ke ascii untuk menghasilkan kunci yang valid. Untuk informasi selengkapnya, lihat Membuat, Menampilkan, dan Menghapus Pasangan Kunci Amazon EC2 (https://docs.aws.amazon.com/cli/latest/userguide/cli-services-ec2-keypairs.html) di Panduan Pengguna AWS Antarmuka Baris Perintah.
(New-EC2KeyPair -KeyName "my-key-pair").KeyMaterial | Out-File -Encoding ascii -FilePath C:\path\my-key-pair.pem-
Untuk detail API, lihat CreateKeyPair di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2NetworkAcl.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat ACL jaringan untuk VPC yang ditentukan.
New-EC2NetworkAcl -VpcId vpc-12345678Output:
Associations : {} Entries : {Amazon.EC2.Model.NetworkAclEntry, Amazon.EC2.Model.NetworkAclEntry} IsDefault : False NetworkAclId : acl-12345678 Tags : {} VpcId : vpc-12345678-
Untuk detail API, lihat CreateNetworkAcl di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2NetworkAclEntry.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat entri untuk ACL jaringan yang ditentukan. Aturan ini memungkinkan lalu lintas masuk dari mana saja (0.0.0. 0/0) pada port UDP 53 (DNS) ke subnet terkait.
New-EC2NetworkAclEntry -NetworkAclId acl-12345678 -Egress $false -RuleNumber 100 -Protocol 17 -PortRange_From 53 -PortRange_To 53 -CidrBlock 0.0.0.0/0 -RuleAction allow-
Untuk detail API, lihat CreateNetworkAclEntry di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2NetworkInterface.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat antarmuka jaringan yang ditentukan.
New-EC2NetworkInterface -SubnetId subnet-1a2b3c4d -Description "my network interface" -Group sg-12345678 -PrivateIpAddress 10.0.0.17Output:
Association : Attachment : AvailabilityZone : us-west-2c Description : my network interface Groups : {my-security-group} MacAddress : 0a:72:bc:1a:cd:7f NetworkInterfaceId : eni-12345678 OwnerId : 123456789012 PrivateDnsName : ip-10-0-0-17.us-west-2.compute.internal PrivateIpAddress : 10.0.0.17 PrivateIpAddresses : {} RequesterId : RequesterManaged : False SourceDestCheck : True Status : pending SubnetId : subnet-1a2b3c4d TagSet : {} VpcId : vpc-12345678-
Untuk detail API, lihat CreateNetworkInterface di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2PlacementGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat grup penempatan dengan nama yang ditentukan.
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster-
Untuk detail API, lihat CreatePlacementGroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Route.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat rute yang ditentukan untuk tabel rute yang ditentukan. Rute cocok dengan semua lalu lintas dan mengirimkannya ke gateway Internet yang ditentukan.
New-EC2Route -RouteTableId rtb-1a2b3c4d -DestinationCidrBlock 0.0.0.0/0 -GatewayId igw-1a2b3c4dOutput:
True-
Untuk detail API, lihat CreateRoute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2RouteTable.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat tabel rute untuk VPC yang ditentukan.
New-EC2RouteTable -VpcId vpc-12345678Output:
Associations : {} PropagatingVgws : {} Routes : {} RouteTableId : rtb-1a2b3c4d Tags : {} VpcId : vpc-12345678-
Untuk detail API, lihat CreateRouteTable di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2ScheduledInstance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini meluncurkan Instans Terjadwal yang ditentukan.
New-EC2ScheduledInstance -ScheduledInstanceId sci-1234-1234-1234-1234-123456789012 -InstanceCount 1 ` -IamInstanceProfile_Name my-iam-role ` -LaunchSpecification_ImageId ami-12345678 ` -LaunchSpecification_InstanceType c4.large ` -LaunchSpecification_SubnetId subnet-12345678` -LaunchSpecification_SecurityGroupId sg-12345678-
Untuk detail API, lihat RunScheduledInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2ScheduledInstancePurchase.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membeli Instans Terjadwal.
$request = New-Object Amazon.EC2.Model.PurchaseRequest $request.InstanceCount = 1 $request.PurchaseToken = "eyJ2IjoiMSIsInMiOjEsImMiOi..." New-EC2ScheduledInstancePurchase -PurchaseRequest $requestOutput:
AvailabilityZone : us-west-2b CreateDate : 1/25/2016 1:43:38 PM HourlyPrice : 0.095 InstanceCount : 1 InstanceType : c4.large NetworkPlatform : EC2-VPC NextSlotStartTime : 1/31/2016 1:00:00 AM Platform : Linux/UNIX PreviousSlotEndTime : Recurrence : Amazon.EC2.Model.ScheduledInstanceRecurrence ScheduledInstanceId : sci-1234-1234-1234-1234-123456789012 SlotDurationInHours : 32 TermEndDate : 1/31/2017 1:00:00 AM TermStartDate : 1/31/2016 1:00:00 AM TotalScheduledInstanceHours : 1696-
Untuk detail API, lihat PurchaseScheduledInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2SecurityGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat grup keamanan untuk VPC yang ditentukan.
New-EC2SecurityGroup -GroupName my-security-group -Description "my security group" -VpcId vpc-12345678Output:
sg-12345678Contoh 2: Contoh ini membuat grup keamanan untuk EC2-Classic.
New-EC2SecurityGroup -GroupName my-security-group -Description "my security group"Output:
sg-45678901-
Untuk detail API, lihat CreateSecurityGroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Snapshot.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat snapshot dari volume yang ditentukan.
New-EC2Snapshot -VolumeId vol-12345678 -Description "This is a test"Output:
DataEncryptionKeyId : Description : This is a test Encrypted : False KmsKeyId : OwnerAlias : OwnerId : 123456789012 Progress : SnapshotId : snap-12345678 StartTime : 12/22/2015 1:28:42 AM State : pending StateMessage : Tags : {} VolumeId : vol-12345678 VolumeSize : 20-
Untuk detail API, lihat CreateSnapshot di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2SpotDatafeedSubscription.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat umpan data instance Spot.
New-EC2SpotDatafeedSubscription -Bucket amzn-s3-demo-bucket -Prefix spotdataOutput:
Bucket : amzn-s3-demo-bucket Fault : OwnerId : 123456789012 Prefix : spotdata State : Active-
Untuk detail API, lihat CreateSpotDatafeedSubscription di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Subnet.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat subnet dengan CIDR yang ditentukan.
New-EC2Subnet -VpcId vpc-12345678 -CidrBlock 10.0.0.0/24Output:
AvailabilityZone : us-west-2c AvailableIpAddressCount : 251 CidrBlock : 10.0.0.0/24 DefaultForAz : False MapPublicIpOnLaunch : False State : pending SubnetId : subnet-1a2b3c4d Tag : {} VpcId : vpc-12345678-
Untuk detail API, lihat CreateSubnet di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Tag.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menambahkan tag tunggal ke sumber daya yang ditentukan. Kunci tag adalah 'MyTag' dan nilai tag adalah 'milik'. TagValue Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
New-EC2Tag -Resource i-12345678 -Tag @{ Key="myTag"; Value="myTagValue" }Contoh 2: Contoh ini memperbarui atau menambahkan tag yang ditentukan ke sumber daya yang ditentukan. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
New-EC2Tag -Resource i-12345678 -Tag @( @{ Key="myTag"; Value="newTagValue" }, @{ Key="test"; Value="anotherTagValue" } )Contoh 3: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat tag untuk parameter Tag.
$tag = New-Object Amazon.EC2.Model.Tag $tag.Key = "myTag" $tag.Value = "myTagValue" New-EC2Tag -Resource i-12345678 -Tag $tag-
Untuk detail API, lihat CreateTags di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Volume.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat volume yang ditentukan.
New-EC2Volume -Size 50 -AvailabilityZone us-west-2a -VolumeType gp2Output:
Attachments : {} AvailabilityZone : us-west-2a CreateTime : 12/22/2015 1:42:07 AM Encrypted : False Iops : 150 KmsKeyId : Size : 50 SnapshotId : State : creating Tags : {} VolumeId : vol-12345678 VolumeType : gp2Contoh 2: Permintaan contoh ini membuat volume dan menerapkan tag dengan kunci tumpukan dan nilai produksi.
$tag = @{ Key="stack"; Value="production" } $tagspec = new-object Amazon.EC2.Model.TagSpecification $tagspec.ResourceType = "volume" $tagspec.Tags.Add($tag) New-EC2Volume -Size 80 -AvailabilityZone "us-west-2a" -TagSpecification $tagspec-
Untuk detail API, lihat CreateVolume di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2Vpc.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat VPC dengan CIDR yang ditentukan. Amazon VPC juga membuat yang berikut untuk VPC: set opsi DHCP default, tabel rute utama, dan ACL jaringan default.
New-EC2VPC -CidrBlock 10.0.0.0/16Output:
CidrBlock : 10.0.0.0/16 DhcpOptionsId : dopt-1a2b3c4d InstanceTenancy : default IsDefault : False State : pending Tags : {} VpcId : vpc-12345678-
Untuk detail API, lihat CreateVpc di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2VpcEndpoint.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat Endpoint VPC baru untuk layanan com.amazonaws.eu-west-1.s3 di VPC vpc-0fc1ff23f45b678eb
New-EC2VpcEndpoint -ServiceName com.amazonaws.eu-west-1.s3 -VpcId vpc-0fc1ff23f45b678ebOutput:
ClientToken VpcEndpoint ----------- ----------- Amazon.EC2.Model.VpcEndpoint-
Untuk detail API, lihat CreateVpcEndpoint di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2VpnConnection.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat koneksi VPN antara gateway pribadi virtual yang ditentukan dan gateway pelanggan yang ditentukan. Outputnya mencakup informasi konfigurasi yang dibutuhkan administrator jaringan Anda, dalam format XML.
New-EC2VpnConnection -Type ipsec.1 -CustomerGatewayId cgw-1a2b3c4d -VpnGatewayId vgw-1a2b3c4dOutput:
CustomerGatewayConfiguration : [XML document] CustomerGatewayId : cgw-1a2b3c4d Options : Routes : {} State : pending Tags : {} Type : VgwTelemetry : {} VpnConnectionId : vpn-12345678 VpnGatewayId : vgw-1a2b3c4dContoh 2: Contoh ini membuat koneksi VPN dan menangkap konfigurasi dalam file dengan nama yang ditentukan.
(New-EC2VpnConnection -CustomerGatewayId cgw-1a2b3c4d -VpnGatewayId vgw-1a2b3c4d).CustomerGatewayConfiguration | Out-File C:\path\vpn-configuration.xmlContoh 3: Contoh ini membuat koneksi VPN, dengan perutean statis, antara gateway pribadi virtual yang ditentukan dan gateway pelanggan yang ditentukan.
New-EC2VpnConnection -Type ipsec.1 -CustomerGatewayId cgw-1a2b3c4d -VpnGatewayId vgw-1a2b3c4d -Options_StaticRoutesOnly $true-
Untuk detail API, lihat CreateVpnConnection di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2VpnConnectionRoute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat rute statis yang ditentukan untuk koneksi VPN yang ditentukan.
New-EC2VpnConnectionRoute -VpnConnectionId vpn-12345678 -DestinationCidrBlock 11.12.0.0/16-
Untuk detail API, lihat CreateVpnConnectionRoute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-EC2VpnGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat gateway pribadi virtual yang ditentukan.
New-EC2VpnGateway -Type ipsec.1Output:
AvailabilityZone : State : available Tags : {} Type : ipsec.1 VpcAttachments : {} VpnGatewayId : vgw-1a2b3c4d-
Untuk detail API, lihat CreateVpnGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRegister-EC2Address.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaitkan alamat IP Elastic yang ditentukan dengan instance yang ditentukan dalam VPC.
C:\> Register-EC2Address -InstanceId i-12345678 -AllocationId eipalloc-12345678Output:
eipassoc-12345678Contoh 2: Contoh ini mengaitkan alamat IP Elastic yang ditentukan dengan instance yang ditentukan di EC2-Classic.
C:\> Register-EC2Address -InstanceId i-12345678 -PublicIp 203.0.113.17-
Untuk detail API, lihat AssociateAddress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRegister-EC2DhcpOption.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaitkan opsi DHCP yang ditentukan yang ditetapkan dengan VPC yang ditentukan.
Register-EC2DhcpOption -DhcpOptionsId dopt-1a2b3c4d -VpcId vpc-12345678Contoh 2: Contoh ini mengaitkan opsi DHCP default yang ditetapkan dengan VPC yang ditentukan.
Register-EC2DhcpOption -DhcpOptionsId default -VpcId vpc-12345678-
Untuk detail API, lihat AssociateDhcpOptions di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRegister-EC2Image.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mendaftarkan AMI menggunakan file manifes yang ditentukan di Amazon S3.
Register-EC2Image -ImageLocation amzn-s3-demo-bucket/my-web-server-ami/image.manifest.xml -Name my-web-server-ami-
Untuk detail API, lihat RegisterImage di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRegister-EC2PrivateIpAddress.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menetapkan alamat IP pribadi sekunder yang ditentukan ke antarmuka jaringan yang ditentukan.
Register-EC2PrivateIpAddress -NetworkInterfaceId eni-1a2b3c4d -PrivateIpAddress 10.0.0.82Contoh 2: Contoh ini membuat dua alamat IP pribadi sekunder dan menetapkannya ke antarmuka jaringan yang ditentukan.
Register-EC2PrivateIpAddress -NetworkInterfaceId eni-1a2b3c4d -SecondaryPrivateIpAddressCount 2-
Untuk detail API, lihat AssignPrivateIpAddresses di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRegister-EC2RouteTable.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaitkan tabel rute yang ditentukan dengan subnet yang ditentukan.
Register-EC2RouteTable -RouteTableId rtb-1a2b3c4d -SubnetId subnet-1a2b3c4dOutput:
rtbassoc-12345678-
Untuk detail API, lihat AssociateRouteTable di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Address.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini merilis alamat IP Elastic yang ditentukan untuk instance dalam VPC.
Remove-EC2Address -AllocationId eipalloc-12345678 -ForceContoh 2: Contoh ini merilis alamat IP Elastic yang ditentukan untuk instance di EC2-Classic.
Remove-EC2Address -PublicIp 198.51.100.2 -Force-
Untuk detail API, lihat ReleaseAddress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2CapacityReservation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membatalkan reservasi kapasitas cr-0c1f2345db6f7cdba
Remove-EC2CapacityReservation -CapacityReservationId cr-0c1f2345db6f7cdbaOutput:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2CapacityReservation (CancelCapacityReservation)" on target "cr-0c1f2345db6f7cdba". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y True-
Untuk detail API, lihat CancelCapacityReservation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2CustomerGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus gateway pelanggan yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2CustomerGateway -CustomerGatewayId cgw-1a2b3c4dOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2CustomerGateway (DeleteCustomerGateway)" on Target "cgw-1a2b3c4d". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteCustomerGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2DhcpOption.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus set opsi DHCP yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2DhcpOption -DhcpOptionsId dopt-1a2b3c4dOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2DhcpOption (DeleteDhcpOptions)" on Target "dopt-1a2b3c4d". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteDhcpOptions di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2FlowLog.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus FlowLogId fl-01a2b3456a789c01 yang diberikan
Remove-EC2FlowLog -FlowLogId fl-01a2b3456a789c01Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2FlowLog (DeleteFlowLogs)" on target "fl-01a2b3456a789c01". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y-
Untuk detail API, lihat DeleteFlowLogs di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Host.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini merilis ID host yang diberikan h-0badafd1dcb2f3456
Remove-EC2Host -HostId h-0badafd1dcb2f3456Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2Host (ReleaseHosts)" on target "h-0badafd1dcb2f3456". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y Successful Unsuccessful ---------- ------------ {h-0badafd1dcb2f3456} {}-
Untuk detail API, lihat ReleaseHosts di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Instance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengakhiri instance yang ditentukan (instance mungkin sedang berjalan atau dalam status 'berhenti'). Cmdlet akan meminta konfirmasi sebelum melanjutkan; gunakan sakelar -Force untuk menekan prompt.
Remove-EC2Instance -InstanceId i-12345678Output:
CurrentState InstanceId PreviousState ------------ ---------- ------------- Amazon.EC2.Model.InstanceState i-12345678 Amazon.EC2.Model.InstanceState-
Untuk detail API, lihat TerminateInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2InternetGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus gateway Internet yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2InternetGateway -InternetGatewayId igw-1a2b3c4dOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2InternetGateway (DeleteInternetGateway)" on Target "igw-1a2b3c4d". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteInternetGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2KeyPair.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus pasangan kunci yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2KeyPair -KeyName my-key-pairOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2KeyPair (DeleteKeyPair)" on Target "my-key-pair". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteKeyPair di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2NetworkAcl.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus ACL jaringan yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2NetworkAcl -NetworkAclId acl-12345678Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2NetworkAcl (DeleteNetworkAcl)" on Target "acl-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteNetworkAcl di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2NetworkAclEntry.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus aturan yang ditentukan dari ACL jaringan yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2NetworkAclEntry -NetworkAclId acl-12345678 -Egress $false -RuleNumber 100Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2NetworkAclEntry (DeleteNetworkAclEntry)" on Target "acl-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteNetworkAclEntry di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2NetworkInterface.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus antarmuka jaringan yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2NetworkInterface -NetworkInterfaceId eni-12345678Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2NetworkInterface (DeleteNetworkInterface)" on Target "eni-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteNetworkInterface di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2PlacementGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus grup penempatan yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2PlacementGroup -GroupName my-placement-groupOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2PlacementGroup (DeletePlacementGroup)" on Target "my-placement-group". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeletePlacementGroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Route.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus rute yang ditentukan dari tabel rute yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2Route -RouteTableId rtb-1a2b3c4d -DestinationCidrBlock 0.0.0.0/0Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2Route (DeleteRoute)" on Target "rtb-1a2b3c4d". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteRoute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2RouteTable.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus tabel rute yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2RouteTable -RouteTableId rtb-1a2b3c4dOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2RouteTable (DeleteRouteTable)" on Target "rtb-1a2b3c4d". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteRouteTable di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2SecurityGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus grup keamanan yang ditentukan untuk EC2-VPC. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2SecurityGroup -GroupId sg-12345678Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2SecurityGroup (DeleteSecurityGroup)" on Target "sg-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):Contoh 2: Contoh ini menghapus grup keamanan yang ditentukan untuk EC2-Classic.
Remove-EC2SecurityGroup -GroupName my-security-group -Force-
Untuk detail API, lihat DeleteSecurityGroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Snapshot.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus snapshot yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2Snapshot -SnapshotId snap-12345678Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2Snapshot (DeleteSnapshot)" on target "snap-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteSnapshot di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2SpotDatafeedSubscription.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus umpan data instans Spot Anda. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2SpotDatafeedSubscriptionOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2SpotDatafeedSubscription (DeleteSpotDatafeedSubscription)" on Target "". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteSpotDatafeedSubscription di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Subnet.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus subnet yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2Subnet -SubnetId subnet-1a2b3c4dOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2Subnet (DeleteSubnet)" on Target "subnet-1a2b3c4d". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteSubnet di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Tag.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus tag yang ditentukan dari sumber daya yang ditentukan, terlepas dari nilai tag. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau yang lebih baru.
Remove-EC2Tag -Resource i-12345678 -Tag @{ Key="myTag" } -ForceContoh 2: Contoh ini menghapus tag yang ditentukan dari sumber daya yang ditentukan, tetapi hanya jika nilai tag cocok. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau yang lebih baru.
Remove-EC2Tag -Resource i-12345678 -Tag @{ Key="myTag";Value="myTagValue" } -ForceContoh 3: Contoh ini menghapus tag yang ditentukan dari sumber daya yang ditentukan, terlepas dari nilai tag.
$tag = New-Object Amazon.EC2.Model.Tag $tag.Key = "myTag" Remove-EC2Tag -Resource i-12345678 -Tag $tag -ForceContoh 4: Contoh ini menghapus tag yang ditentukan dari sumber daya yang ditentukan, tetapi hanya jika nilai tag cocok.
$tag = New-Object Amazon.EC2.Model.Tag $tag.Key = "myTag" $tag.Value = "myTagValue" Remove-EC2Tag -Resource i-12345678 -Tag $tag -Force-
Untuk detail API, lihat DeleteTags di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Volume.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melepaskan volume yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2Volume -VolumeId vol-12345678Output:
Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2Volume (DeleteVolume)" on target "vol-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteVolume di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2Vpc.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus VPC yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2Vpc -VpcId vpc-12345678Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2Vpc (DeleteVpc)" on Target "vpc-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteVpc di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2VpnConnection.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus koneksi VPN yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2VpnConnection -VpnConnectionId vpn-12345678Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2VpnConnection (DeleteVpnConnection)" on Target "vpn-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteVpnConnection di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2VpnConnectionRoute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus rute statis yang ditentukan dari koneksi VPN yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2VpnConnectionRoute -VpnConnectionId vpn-12345678 -DestinationCidrBlock 11.12.0.0/16Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2VpnConnectionRoute (DeleteVpnConnectionRoute)" on Target "vpn-12345678". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteVpnConnectionRoute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-EC2VpnGateway.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus gateway pribadi virtual yang ditentukan. Anda akan diminta untuk konfirmasi sebelum operasi berlangsung, kecuali Anda juga menentukan parameter Force.
Remove-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4dOutput:
Confirm Are you sure you want to perform this action? Performing operation "Remove-EC2VpnGateway (DeleteVpnGateway)" on Target "vgw-1a2b3c4d". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):-
Untuk detail API, lihat DeleteVpnGateway di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRequest-EC2SpotFleet.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membuat permintaan armada Spot di Zona Ketersediaan dengan harga terendah untuk jenis instans yang ditentukan. Jika akun Anda EC2-VPC hanya mendukung, armada Spot meluncurkan instans di Zona Ketersediaan dengan harga terendah yang memiliki subnet default. Jika akun Anda mendukung EC2-Classic, armada Spot meluncurkan instans EC2-Classic di Zona Ketersediaan dengan harga terendah. Perhatikan bahwa harga yang Anda bayar tidak akan melebihi harga Spot yang ditentukan untuk permintaan tersebut.
$sg = New-Object Amazon.EC2.Model.GroupIdentifier $sg.GroupId = "sg-12345678" $lc = New-Object Amazon.EC2.Model.SpotFleetLaunchSpecification $lc.ImageId = "ami-12345678" $lc.InstanceType = "m3.medium" $lc.SecurityGroups.Add($sg) Request-EC2SpotFleet -SpotFleetRequestConfig_SpotPrice 0.04 ` -SpotFleetRequestConfig_TargetCapacity 2 ` -SpotFleetRequestConfig_IamFleetRole arn:aws:iam::123456789012:role/my-spot-fleet-role ` -SpotFleetRequestConfig_LaunchSpecification $lc-
Untuk detail API, lihat RequestSpotFleet di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRequest-EC2SpotInstance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini meminta instance Spot satu kali di subnet yang ditentukan. Perhatikan bahwa grup keamanan harus dibuat untuk VPC yang berisi subnet yang ditentukan, dan itu harus ditentukan oleh ID menggunakan antarmuka jaringan. Ketika Anda menentukan antarmuka jaringan, Anda harus menyertakan ID subnet menggunakan antarmuka jaringan.
$n = New-Object Amazon.EC2.Model.InstanceNetworkInterfaceSpecification $n.DeviceIndex = 0 $n.SubnetId = "subnet-12345678" $n.Groups.Add("sg-12345678") Request-EC2SpotInstance -InstanceCount 1 -SpotPrice 0.050 -Type one-time ` -IamInstanceProfile_Arn arn:aws:iam::123456789012:instance-profile/my-iam-role ` -LaunchSpecification_ImageId ami-12345678 ` -LaunchSpecification_InstanceType m3.medium ` -LaunchSpecification_NetworkInterface $nOutput:
ActualBlockHourlyPrice : AvailabilityZoneGroup : BlockDurationMinutes : 0 CreateTime : 12/26/2015 7:44:10 AM Fault : InstanceId : LaunchedAvailabilityZone : LaunchGroup : LaunchSpecification : Amazon.EC2.Model.LaunchSpecification ProductDescription : Linux/UNIX SpotInstanceRequestId : sir-12345678 SpotPrice : 0.050000 State : open Status : Amazon.EC2.Model.SpotInstanceStatus Tags : {} Type : one-time-
Untuk detail API, lihat RequestSpotInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanReset-EC2ImageAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengatur ulang atribut 'launchPermission' ke nilai defaultnya. Secara default, AMI bersifat pribadi.
Reset-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission-
Untuk detail API, lihat ResetImageAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanReset-EC2InstanceAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengatur ulang atribut 'sriov NetSupport 'untuk instance yang ditentukan.
Reset-EC2InstanceAttribute -InstanceId i-12345678 -Attribute sriovNetSupportContoh 2: Contoh ini mengatur ulang atribut 'EBSOptimized' untuk instance yang ditentukan.
Reset-EC2InstanceAttribute -InstanceId i-12345678 -Attribute ebsOptimizedContoh 3: Contoh ini mengatur ulang atribut 'source DestCheck 'untuk instance yang ditentukan.
Reset-EC2InstanceAttribute -InstanceId i-12345678 -Attribute sourceDestCheckContoh 4: Contoh ini mengatur ulang atribut 'menonaktifkan ApiTermination 'untuk instance yang ditentukan.
Reset-EC2InstanceAttribute -InstanceId i-12345678 -Attribute disableApiTerminationContoh 5: Contoh ini mengatur ulang atribut 'instanceInitiatedShutdownBehavior' untuk instance yang ditentukan.
Reset-EC2InstanceAttribute -InstanceId i-12345678 -Attribute instanceInitiatedShutdownBehavior-
Untuk detail API, lihat ResetInstanceAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanReset-EC2NetworkInterfaceAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengatur ulang source/destination pemeriksaan untuk antarmuka jaringan yang ditentukan.
Reset-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -SourceDestCheck-
Untuk detail API, lihat ResetNetworkInterfaceAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanReset-EC2SnapshotAttribute.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengatur ulang atribut yang ditentukan dari snapshot yang ditentukan.
Reset-EC2SnapshotAttribute -SnapshotId snap-12345678 -Attribute CreateVolumePermission-
Untuk detail API, lihat ResetSnapshotAttribute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRestart-EC2Instance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini me-reboot instance yang ditentukan.
Restart-EC2Instance -InstanceId i-12345678-
Untuk detail API, lihat RebootInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRevoke-EC2SecurityGroupEgress.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus aturan untuk grup keamanan yang ditentukan untuk EC2-VPC. Ini mencabut akses ke rentang alamat IP yang ditentukan pada port TCP 80. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
$ip = @{ IpProtocol="tcp"; FromPort="80"; ToPort="80"; IpRanges="203.0.113.0/24" } Revoke-EC2SecurityGroupEgress -GroupId sg-12345678 -IpPermission $ipContoh 2: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat IpPermission objek.
$ip = New-Object Amazon.EC2.Model.IpPermission $ip.IpProtocol = "tcp" $ip.FromPort = 80 $ip.ToPort = 80 $ip.IpRanges.Add("203.0.113.0/24") Revoke-EC2SecurityGroupEgress -GroupId sg-12345678 -IpPermission $ipContoh 3: Contoh ini mencabut akses ke grup keamanan sumber yang ditentukan pada port TCP 80.
$ug = New-Object Amazon.EC2.Model.UserIdGroupPair $ug.GroupId = "sg-1a2b3c4d" $ug.UserId = "123456789012" Revoke-EC2SecurityGroupEgress -GroupId sg-12345678 -IpPermission @( @{ IpProtocol="tcp"; FromPort="80"; ToPort="80"; UserIdGroupPairs=$ug } )-
Untuk detail API, lihat RevokeSecurityGroupEgress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRevoke-EC2SecurityGroupIngress.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mencabut akses ke port TCP 22 dari rentang alamat yang ditentukan untuk grup keamanan yang ditentukan untuk. EC2-VPC Perhatikan bahwa Anda harus mengidentifikasi grup keamanan untuk EC2-VPC menggunakan ID grup keamanan bukan nama grup keamanan. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
$ip = @{ IpProtocol="tcp"; FromPort="22"; ToPort="22"; IpRanges="203.0.113.0/24" } Revoke-EC2SecurityGroupIngress -GroupId sg-12345678 -IpPermission $ipContoh 2: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat IpPermission objek.
$ip = New-Object Amazon.EC2.Model.IpPermission $ip.IpProtocol = "tcp" $ip.FromPort = 22 $ip.ToPort = 22 $ip.IpRanges.Add("203.0.113.0/24") Revoke-EC2SecurityGroupIngress -GroupId sg-12345678 -IpPermission $ipContoh 3: Contoh ini mencabut akses ke port TCP 22 dari rentang alamat yang ditentukan untuk grup keamanan yang ditentukan untuk. EC2-Classic Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
$ip = @{ IpProtocol="tcp"; FromPort="22"; ToPort="22"; IpRanges="203.0.113.0/24" } Revoke-EC2SecurityGroupIngress -GroupName "my-security-group" -IpPermission $ipContoh 4: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat IpPermission objek.
$ip = New-Object Amazon.EC2.Model.IpPermission $ip.IpProtocol = "tcp" $ip.FromPort = 22 $ip.ToPort = 22 $ip.IpRanges.Add("203.0.113.0/24") Revoke-EC2SecurityGroupIngress -GroupName "my-security-group" -IpPermission $ip-
Untuk detail API, lihat RevokeSecurityGroupIngress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanSend-EC2InstanceStatus.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini melaporkan umpan balik status untuk instance yang ditentukan.
Send-EC2InstanceStatus -Instance i-12345678 -Status impaired -ReasonCode unresponsive-
Untuk detail API, lihat ReportInstanceStatus di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanSet-EC2NetworkAclAssociation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaitkan ACL jaringan yang ditentukan dengan subnet untuk asosiasi ACL jaringan yang ditentukan.
Set-EC2NetworkAclAssociation -NetworkAclId acl-12345678 -AssociationId aclassoc-1a2b3c4dOutput:
aclassoc-87654321-
Untuk detail API, lihat ReplaceNetworkAclAssociation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanSet-EC2NetworkAclEntry.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menggantikan entri yang ditentukan untuk ACL jaringan yang ditentukan. Aturan baru memungkinkan lalu lintas masuk dari alamat yang ditentukan ke subnet terkait.
Set-EC2NetworkAclEntry -NetworkAclId acl-12345678 -Egress $false -RuleNumber 100 -Protocol 17 -PortRange_From 53 -PortRange_To 53 -CidrBlock 203.0.113.12/24 -RuleAction allow-
Untuk detail API, lihat ReplaceNetworkAclEntry di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanSet-EC2Route.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menggantikan rute yang ditentukan untuk tabel rute yang ditentukan. Rute baru mengirimkan lalu lintas yang ditentukan ke gateway pribadi virtual yang ditentukan.
Set-EC2Route -RouteTableId rtb-1a2b3c4d -DestinationCidrBlock 10.0.0.0/24 -GatewayId vgw-1a2b3c4d-
Untuk detail API, lihat ReplaceRoute di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanSet-EC2RouteTableAssociation.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaitkan tabel rute yang ditentukan dengan subnet untuk asosiasi tabel rute yang ditentukan.
Set-EC2RouteTableAssociation -RouteTableId rtb-1a2b3c4d -AssociationId rtbassoc-12345678Output:
rtbassoc-87654321-
Untuk detail API, lihat ReplaceRouteTableAssociation di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStart-EC2Instance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memulai instance yang ditentukan.
Start-EC2Instance -InstanceId i-12345678Output:
CurrentState InstanceId PreviousState ------------ ---------- ------------- Amazon.EC2.Model.InstanceState i-12345678 Amazon.EC2.Model.InstanceStateContoh 2: Contoh ini memulai instance yang ditentukan.
@("i-12345678", "i-76543210") | Start-EC2InstanceContoh 3: Contoh ini memulai kumpulan instance yang saat ini dihentikan. Objek Instance yang dikembalikan oleh Get-EC2Instance disalurkan ke Start-EC2Instance. Sintaks yang digunakan oleh contoh ini memerlukan PowerShell versi 3 atau lebih tinggi.
(Get-EC2Instance -Filter @{ Name="instance-state-name"; Values="stopped"}).Instances | Start-EC2InstanceContoh 4: Dengan PowerShell versi 2, Anda harus menggunakan New-Object untuk membuat filter untuk parameter Filter.
$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "instance-state-name" $filter.Values = "stopped" (Get-EC2Instance -Filter $filter).Instances | Start-EC2InstanceContoh 5: Contoh ini memvalidasi izin untuk memulai instance EC2 menggunakan DryRun parameter tanpa benar-benar memulai instance. Catatan: Ini menimbulkan pengecualian jika berhasil yang merupakan perilaku yang diharapkan.
Start-EC2Instance -InstanceId 'i-0abcdef123456' -Region 'us-west-1' -DryRun $true-
Untuk detail API, lihat StartInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStart-EC2InstanceMonitoring.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memungkinkan pemantauan terperinci untuk instance yang ditentukan.
Start-EC2InstanceMonitoring -InstanceId i-12345678Output:
InstanceId Monitoring ---------- ---------- i-12345678 Amazon.EC2.Model.Monitoring-
Untuk detail API, lihat MonitorInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStop-EC2ImportTask.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membatalkan tugas impor yang ditentukan (baik snapshot atau impor gambar). Jika diperlukan, alasan dapat diberikan menggunakan
-CancelReasonparameter.Stop-EC2ImportTask -ImportTaskId import-ami-abcdefgh-
Untuk detail API, lihat CancelImportTask di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStop-EC2Instance.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghentikan instance yang ditentukan.
Stop-EC2Instance -InstanceId i-12345678Output:
CurrentState InstanceId PreviousState ------------ ---------- ------------- Amazon.EC2.Model.InstanceState i-12345678 Amazon.EC2.Model.InstanceState-
Untuk detail API, lihat StopInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStop-EC2InstanceMonitoring.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menonaktifkan pemantauan terperinci untuk instance yang ditentukan.
Stop-EC2InstanceMonitoring -InstanceId i-12345678Output:
InstanceId Monitoring ---------- ---------- i-12345678 Amazon.EC2.Model.Monitoring-
Untuk detail API, lihat UnmonitorInstances di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStop-EC2SpotFleetRequest.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membatalkan permintaan armada Spot yang ditentukan dan mengakhiri instans Spot terkait.
Stop-EC2SpotFleetRequest -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE -TerminateInstance $trueContoh 2: Contoh ini membatalkan permintaan armada Spot yang ditentukan tanpa menghentikan instans Spot terkait.
Stop-EC2SpotFleetRequest -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE -TerminateInstance $false-
Untuk detail API, lihat CancelSpotFleetRequests di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStop-EC2SpotInstanceRequest.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membatalkan permintaan instance Spot yang ditentukan.
Stop-EC2SpotInstanceRequest -SpotInstanceRequestId sir-12345678Output:
SpotInstanceRequestId State --------------------- ----- sir-12345678 cancelled-
Untuk detail API, lihat CancelSpotInstanceRequests di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUnregister-EC2Address.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini memisahkan alamat IP Elastic yang ditentukan dari instance yang ditentukan dalam VPC.
Unregister-EC2Address -AssociationId eipassoc-12345678Contoh 2: Contoh ini memisahkan alamat IP Elastic yang ditentukan dari instance yang ditentukan di EC2-Classic.
Unregister-EC2Address -PublicIp 203.0.113.17-
Untuk detail API, lihat DisassociateAddress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUnregister-EC2Image.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membatalkan pendaftaran AMI yang ditentukan.
Unregister-EC2Image -ImageId ami-12345678-
Untuk detail API, lihat DeregisterImage di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUnregister-EC2PrivateIpAddress.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus alamat IP pribadi yang ditentukan dari antarmuka jaringan yang ditentukan.
Unregister-EC2PrivateIpAddress -NetworkInterfaceId eni-1a2b3c4d -PrivateIpAddress 10.0.0.82-
Untuk detail API, lihat UnassignPrivateIpAddresses di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUnregister-EC2RouteTable.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menghapus asosiasi yang ditentukan antara tabel rute dan subnet.
Unregister-EC2RouteTable -AssociationId rtbassoc-1a2b3c4d-
Untuk detail API, lihat DisassociateRouteTable di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUpdate-EC2SecurityGroupRuleIngressDescription.
- Alat untuk PowerShell V5
-
Contoh 1: Memperbarui deskripsi aturan grup keamanan masuk (inbound) yang ada.
$existingInboundRule = Get-EC2SecurityGroupRule -SecurityGroupRuleId "sgr-1234567890" $ruleWithUpdatedDescription = [Amazon.EC2.Model.SecurityGroupRuleDescription]@{ "SecurityGroupRuleId" = $existingInboundRule.SecurityGroupRuleId "Description" = "Updated rule description" } Update-EC2SecurityGroupRuleIngressDescription -GroupId $existingInboundRule.GroupId -SecurityGroupRuleDescription $ruleWithUpdatedDescriptionContoh 2: Menghapus deskripsi aturan grup keamanan masuk (inbound) yang ada (dengan menghilangkan parameter dalam permintaan).
$existingInboundRule = Get-EC2SecurityGroupRule -SecurityGroupRuleId "sgr-1234567890" $ruleWithoutDescription = [Amazon.EC2.Model.SecurityGroupRuleDescription]@{ "SecurityGroupRuleId" = $existingInboundRule.SecurityGroupRuleId } Update-EC2SecurityGroupRuleIngressDescription -GroupId $existingInboundRule.GroupId -SecurityGroupRuleDescription $ruleWithoutDescription-
Untuk detail API, lihat UpdateSecurityGroupRuleDescriptionsIngress di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-