

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

# 範例：設定 AWS PCS 的全域環境變數
<a name="working-with_ec2-user-data_env"></a>

 在啟動範本`"userData"`中提供此指令碼做為 的值。如需詳細資訊，請參閱[使用 AWS PCS 的 Amazon EC2 使用者資料](working-with_ec2-user-data.md)。

下列範例使用 在節點群組執行個體上`/etc/profile.d`設定全域變數。

```
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
touch /etc/profile.d/awspcs-userdata-vars.sh
echo MY_GLOBAL_VAR1=100 >> /etc/profile.d/awspcs-userdata-vars.sh
echo MY_GLOBAL_VAR2=abc >> /etc/profile.d/awspcs-userdata-vars.sh

--==MYBOUNDARY==--
```