

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 搭配使用 `RemovePermission` 與 CLI
<a name="lambda_example_lambda_RemovePermission_section"></a>

下列程式碼範例示範如何使用 `RemovePermission`。

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

**AWS CLI**  
**若要從現有的 Lambda 函數中移除許可**  
下列 `remove-permission` 範例會移除許可以調用名為 `my-function` 的函數。  

```
aws lambda remove-permission \
    --function-name my-function \
    --statement-id sns
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《[AWS Lambda 開發人員指南》中的使用 Lambda 的資源型政策](https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html)。 *AWS *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》中的 [RemovePermission](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/remove-permission.html)。**

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

**Tools for PowerShell V4**  
**範例 1：此範例會移除 Lambda 函數之指定 StatementId 的函數政策。**  

```
$policy =  Get-LMPolicy -FunctionName "MylambdaFunction123" -Select Policy | ConvertFrom-Json| Select-Object -ExpandProperty Statement
Remove-LMPermission -FunctionName "MylambdaFunction123" -StatementId $policy[0].Sid
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [RemovePermission](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此範例會移除 Lambda 函數之指定 StatementId 的函數政策。**  

```
$policy =  Get-LMPolicy -FunctionName "MylambdaFunction123" -Select Policy | ConvertFrom-Json| Select-Object -ExpandProperty Statement
Remove-LMPermission -FunctionName "MylambdaFunction123" -StatementId $policy[0].Sid
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [RemovePermission](https://docs.aws.amazon.com/powershell/v5/reference)。

------