

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh [SDK AWS Doc](https://github.com/awsdocs/aws-doc-sdk-examples). GitHub 

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Gunakan `SetInstanceProtection` dengan CLI
<a name="auto-scaling_example_auto-scaling_SetInstanceProtection_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`SetInstanceProtection`.

------
#### [ CLI ]

**AWS CLI**  
**Contoh 1: Untuk mengaktifkan pengaturan perlindungan instance untuk sebuah instance**  
Contoh ini memungkinkan perlindungan instance untuk instance tertentu.  

```
aws autoscaling set-instance-protection \
    --instance-ids i-061c63c5eb45f0416 \
    --auto-scaling-group-name my-asg --protected-from-scale-in
```
Perintah ini tidak menghasilkan output.  
**Contoh 2: Untuk menonaktifkan pengaturan perlindungan instance untuk sebuah instance**  
Contoh ini menonaktifkan perlindungan instance untuk instance tertentu.  

```
aws autoscaling set-instance-protection \
    --instance-ids i-061c63c5eb45f0416 \
    --auto-scaling-group-name my-asg \
    --no-protected-from-scale-in
```
Perintah ini tidak menghasilkan output.  
+  Untuk detail API, lihat [SetInstanceProtection](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/autoscaling/set-instance-protection.html)di *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini memungkinkan perlindungan instance untuk instance tertentu.**  

```
Set-ASInstanceProtection -AutoScalingGroupName my-asg -InstanceId i-12345678 -ProtectedFromScaleIn $true
```
**Contoh 2: Contoh ini menonaktifkan perlindungan instance untuk instance tertentu.**  

```
Set-ASInstanceProtection -AutoScalingGroupName my-asg -InstanceId i-12345678 -ProtectedFromScaleIn $false
```
+  Untuk detail API, lihat [SetInstanceProtection](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini memungkinkan perlindungan instance untuk instance tertentu.**  

```
Set-ASInstanceProtection -AutoScalingGroupName my-asg -InstanceId i-12345678 -ProtectedFromScaleIn $true
```
**Contoh 2: Contoh ini menonaktifkan perlindungan instance untuk instance tertentu.**  

```
Set-ASInstanceProtection -AutoScalingGroupName my-asg -InstanceId i-12345678 -ProtectedFromScaleIn $false
```
+  Untuk detail API, lihat [SetInstanceProtection](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------