cloud-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cloud Environment Setup

云环境设置

Configure Elastic Cloud authentication and preferences. All other
cloud/*
skills depend on this setup.
配置Elastic Cloud身份验证和偏好设置。所有其他
cloud/*
技能都依赖于该设置。

Workflow

工作流程

text
Setup Progress:
- [ ] Step 1: Verify API key
- [ ] Step 2: Set defaults
- [ ] Step 3: Validate connection
text
Setup Progress:
- [ ] Step 1: Verify API key
- [ ] Step 2: Set defaults
- [ ] Step 3: Validate connection

Step 1: Verify API key

步骤1:验证API密钥

Check whether
EC_API_KEY
is already set:
bash
echo "${EC_API_KEY:?Not set}"
If not set, instruct the user to set it. Never ask the user to paste an API key into the chat — secrets must not appear in conversation history.
Direct the user to:
  1. Generate a key at Elastic Cloud API keys. The key must have Project Admin privileges or higher (Org Owner) to create and manage serverless projects.
  2. Create a
    .env
    file in the project root (recommended — works in sandboxed agent shells):
bash
EC_API_KEY=your-api-key
All
cloud/*
scripts auto-load
.env
from the working directory — no manual sourcing needed.
  1. Alternatively, export directly in the terminal:
bash
export EC_API_KEY="your-api-key"
Terminal exports might not be visible to sandboxed agents running in a separate shell session. Prefer the
.env
file when working with an agent.
Remind the user that storing secrets in local files is acceptable for development, but for production or shared environments, use a centralized secrets manager (for example, HashiCorp Vault, AWS Secrets Manager, 1Password CLI) to avoid secrets sprawl.
检查
EC_API_KEY
是否已设置:
bash
echo "${EC_API_KEY:?Not set}"
如果未设置,请指导用户进行设置。切勿要求用户在聊天中粘贴API密钥——机密信息不得出现在对话历史中。
请指导用户执行以下操作:
  1. Elastic Cloud API密钥页面生成密钥。该密钥必须拥有项目管理员或更高权限(组织所有者)才能创建和管理无服务器项目。
  2. 在项目根目录创建
    .env
    文件(推荐方式——适用于沙盒Agent Shell环境):
bash
EC_API_KEY=your-api-key
所有
cloud/*
脚本会自动从工作目录加载
.env
文件——无需手动导入。
  1. 或者,直接在终端中导出:
bash
export EC_API_KEY="your-api-key"
在独立Shell会话中运行的沙盒Agent可能无法识别终端中导出的变量。与Agent配合使用时,优先选择
.env
文件方式。
提醒用户,在开发环境中可以将机密信息存储在本地文件中,但在生产环境或共享环境中,请使用集中式密钥管理工具(例如HashiCorp Vault、AWS Secrets Manager、1Password CLI),以避免机密信息扩散。

Step 2: Set defaults

步骤2:设置默认值

Export the base URL and default region:
bash
export EC_BASE_URL="https://api.elastic-cloud.com"
export EC_REGION="gcp-us-central1"
Ask the user if they want a different region. To list available regions:
bash
curl -s -H "Authorization: ApiKey ${EC_API_KEY}" \
  "${EC_BASE_URL}/api/v1/serverless/regions" | python3 -m json.tool
导出基础URL和默认区域:
bash
export EC_BASE_URL="https://api.elastic-cloud.com"
export EC_REGION="gcp-us-central1"
询问用户是否需要设置其他区域。如需列出可用区域,请执行:
bash
curl -s -H "Authorization: ApiKey ${EC_API_KEY}" \
  "${EC_BASE_URL}/api/v1/serverless/regions" | python3 -m json.tool

Step 3: Validate connection

步骤3:验证连接

Confirm the API key works by calling the regions endpoint:
bash
curl -sf -H "Authorization: ApiKey ${EC_API_KEY}" \
  "${EC_BASE_URL}/api/v1/serverless/regions" > /dev/null && echo "Authenticated." || echo "Authentication failed."
If validation fails, check:
  • The API key is valid and not expired
  • Network connectivity to
    api.elastic-cloud.com
通过调用区域端点确认API密钥可用:
bash
curl -sf -H "Authorization: ApiKey ${EC_API_KEY}" \
  "${EC_BASE_URL}/api/v1/serverless/regions" > /dev/null && echo "Authenticated." || echo "Authentication failed."
如果验证失败,请检查:
  • API密钥是否有效且未过期
  • api.elastic-cloud.com
    的网络连接是否正常

Examples

示例

First-time setup

首次设置

text
User: set up my cloud environment
Agent: Check if EC_API_KEY is set in your terminal. If not, generate a key at
       https://cloud.elastic.co/account/keys and run:
       export EC_API_KEY="your-key"
       Then confirm and I'll validate the connection.
text
用户:设置我的云环境
Agent:检查你的终端中是否已设置EC_API_KEY。如果未设置,请访问https://cloud.elastic.co/account/keys生成密钥,然后运行:
       export EC_API_KEY="your-key"
       确认后我将验证连接。

Setup with custom region

自定义区域设置

text
User: set up cloud with eu region
Agent: [runs setup, sets EC_REGION to user's preferred EU region]
text
用户:设置使用欧盟区域的云环境
Agent:[执行设置,将EC_REGION设置为用户偏好的欧盟区域]

Guidelines

指导原则

  • Never receive, echo, or log API keys, passwords, or any credentials in the chat. Instruct the user to manage secrets in their terminal or using files directly.
  • Always validate the connection after setting the key.
  • Default region is
    gcp-us-central1
    — only change if the user requests a different region.
  • This skill is a prerequisite. Other cloud skills should refer here when
    EC_API_KEY
    is missing.
  • 切勿在聊天中接收、回显或记录API密钥、密码或任何凭证。指导用户在终端中或直接通过文件管理机密信息。
  • 设置密钥后务必验证连接。
  • 默认区域为
    gcp-us-central1
    ——仅在用户要求时更改。
  • 本技能是前置要求。当其他云技能检测到
    EC_API_KEY
    缺失时,应引导用户参考本设置流程。

Environment variables

环境变量

VariableRequiredDescription
EC_API_KEY
YesElastic Cloud API key
EC_BASE_URL
NoCloud API base URL (default:
https://api.elastic-cloud.com
)
EC_REGION
NoDefault region (default:
gcp-us-central1
)
变量名是否必填说明
EC_API_KEY
Elastic Cloud API密钥
EC_BASE_URL
Cloud API基础URL(默认值:
https://api.elastic-cloud.com
EC_REGION
默认区域(默认值:
gcp-us-central1

Troubleshooting

故障排除

ProblemFix
401 Unauthorized
API key is invalid or expired — generate a new one
connection refused
Check network access to
api.elastic-cloud.com
问题解决方法
401 Unauthorized
API密钥无效或已过期——生成新密钥
connection refused
检查对
api.elastic-cloud.com
的网络访问权限