

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

# 範例：預防 WorkSpaces 應用程式應用程式 Amazon S3 儲存貯體政策跨服務混淆代理人
<a name="example-s3-bucket"></a>

當您將資料存放在 Amazon S3 儲存貯體中時，儲存貯體可能會遭遇混淆代理人問題。這可能會使彈性機群、應用程式區塊、安裝指令碼、應用程式圖示及工作階段指令碼等資料容易受到惡意人士攻擊。

為了預防混淆代理人問題，您可以在 Amazon S3 儲存貯體政策中針對 `ELASTIC-FLEET-EXAMPLE-BUCKET` 指定 `aws:SourceAccount` 條件或 `aws:SourceArn` 條件。

以下資源政策說明如何透過下列任一種方式預防混淆代理人問題：
+ `aws:SourceAccount` 具有您 AWS 帳戶 ID 的
+ 全域條件內容鍵 `aws:SourceArn`

WorkSpaces 應用程式目前不支援應用程式圖示的混淆代理人預防。服務僅支援 VHD 檔案和安裝指令碼。如果您嘗試為應用程式圖示新增其他條件，圖示將不會對使用者顯示。

在下列範例中，儲存貯體政策僅允許擁有者帳戶中的 WorkSpaces 應用程式彈性機群資源存取 `ELASTIC_FLEET_EXAMPLE_BUCKET`。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ConfusedDeputyPreventionExamplePolicy",
            "Effect": "Allow",
            "Principal": {
                "Service": "appstream.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": [
                "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/vhd-folder/*",
                "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/scripts/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "{{your AWS 帳戶 ID}}"
                }
            }
        },
        {
            "Sid": "AllowRetrievalPermissionsToS3AppIconsForAppStream",
            "Effect": "Allow",
            "Principal": {
                "Service": "appstream.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/app-icons/*"
        }
    ]
}
```

------

您也可以使用 `aws:SourceArn` 條件來限制特定資源的資源存取權。

**注意**  
如果不知道資源的完整 ARN，或者您想要指定多個資源，請使用 `aws:SourceArn` 全域條件內容鍵搭配萬用字元 (\*) 來表示 ARN 的未知部分。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ConfusedDeputyPreventionExamplePolicy",
            "Effect": "Allow",
            "Principal": {
                "Service": "appstream.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": [
                "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/vhd-folder/*",
                "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/scripts/*"
            ],
            "Condition": {
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:appstream:{{us-east-1}}:{{111122223333}}:app-block/*"
                }
            }
        },
        {
            "Sid": "AllowRetrievalPermissionsToS3AppIconsForAppStream",
            "Effect": "Allow",
            "Principal": {
                "Service": "appstream.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/app-icons/*"
        }
    ]
}
```

------

您也可以使用 `aws:SourceArn` 和 `aws:SourceAccount` 條件來限制特定資源和帳戶的資源存取權。

**注意**  
如果不知道資源的完整 ARN，或者您想要指定多個資源，請使用 `aws:SourceArn` 全域條件內容鍵搭配萬用字元 (\*) 來表示 ARN 的未知部分。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "ConfusedDeputyPreventionExamplePolicy",
            "Effect": "Allow",
            "Principal": {
                "Service": "appstream.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": [
                "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/vhd-folder/*",
                "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/scripts/*"
            ],
            "Condition": {
                "ArnLike": {
                "aws:SourceArn": "arn:aws:appstream:{{us-east-1}}:{{111122223333}}:app-block/*"
                },
                "StringEquals": {
                    "aws:SourceAccount": "{{your AWS account ID}}"
                }
            }
        },
        {
            "Sid": "AllowRetrievalPermissionsToS3AppIconsForAppStream",
            "Effect": "Allow",
            "Principal": {
                "Service": "appstream.amazonaws.com"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::{{ELASTIC-FLEET-EXAMPLE-BUCKET}}/app-icons/*"
        }
    ]
}
```

------