

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 示例：为 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==--
```