using-cloud-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cloud CLI Patterns

Cloud CLI 使用模式

Credentials are pre-configured. Use
--help
or Context7 for syntax.
凭据已预先配置。可使用
--help
或Context7查看语法。

BigQuery

BigQuery

bash
undefined
bash
undefined

Always estimate cost first

先预估成本

bq query --dry_run --use_legacy_sql=false 'SELECT ...'
bq query --dry_run --use_legacy_sql=false 'SELECT ...'

Run query

运行查询

bq query --use_legacy_sql=false --format=json 'SELECT ...'
bq query --use_legacy_sql=false --format=json 'SELECT ...'

List tables

列出表

bq ls project:dataset
bq ls project:dataset

Get table schema

获取表结构

bq show --schema --format=json project:dataset.table

**Cost awareness**: Charged per bytes scanned. Use `--dry_run`, partition tables, specify columns.
bq show --schema --format=json project:dataset.table

**成本注意事项**:按扫描字节数计费。使用`--dry_run`、分区表、指定列。

GCP (gcloud)

GCP (gcloud)

bash
undefined
bash
undefined

List resources

列出资源

gcloud compute instances list --format=json
gcloud compute instances list --format=json

Describe resource

描述资源

gcloud compute instances describe INSTANCE --zone=ZONE --format=json
gcloud compute instances describe INSTANCE --zone=ZONE --format=json

Create with explicit project

显式指定项目创建

gcloud compute instances create NAME --project=PROJECT --zone=ZONE
gcloud compute instances create NAME --project=PROJECT --zone=ZONE

Use --quiet for automation

自动化场景使用--quiet参数

gcloud compute instances delete NAME --quiet
undefined
gcloud compute instances delete NAME --quiet
undefined

AWS

AWS

bash
undefined
bash
undefined

List resources

列出资源

aws ec2 describe-instances --output json
aws ec2 describe-instances --output json

With JMESPath filtering

使用JMESPath过滤

aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId' --output text
aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId' --output text

Explicit region

显式指定区域

aws s3 ls s3://bucket --region us-west-2
aws s3 ls s3://bucket --region us-west-2

Dry run where available

支持的场景下使用预演模式

aws ec2 run-instances --dry-run ...
undefined
aws ec2 run-instances --dry-run ...
undefined

References

参考资料

  • GCP.md - GCP service patterns and common commands
  • AWS.md - AWS service patterns and common commands
  • scripts/ - Helper scripts for common operations
  • GCP.md - GCP服务使用模式及常用命令
  • AWS.md - AWS服务使用模式及常用命令
  • scripts/ - 用于常见操作的辅助脚本