Awesome Cheatsheet 云服务平台指南:AWS/Azure/GCP 速查
你是否还在为云服务平台(Cloud Service Platform,云服务平台)的复杂操作而烦恼?面对AWS、Azure、GCP三大云巨头的数百项服务,是否常常记不清关键命令和架构差异?本文将通过12个核心模块、50+实用代码示例和8张对比表格,帮你系统掌握三大云平台的核心技能,读完你将能够:
- 快速定位并使用三大云平台的核心服务
- 掌握跨平台资源管理的命令行技巧
- 通过架构对比图优化云服务选型
- 利用速查表格解决日常运维问题
云服务平台核心架构对比
三大平台服务矩阵概览
| 服务类型 | AWS (Amazon Web Services,亚马逊云服务) | Azure (Microsoft Azure,微软云) | GCP (Google Cloud Platform,谷歌云平台) |
|---|---|---|---|
| 计算服务 | EC2 (Elastic Compute Cloud,弹性计算云) | Virtual Machines | Compute Engine |
| 无服务器 | Lambda | Functions | Cloud Functions |
| 对象存储 | S3 (Simple Storage Service,简单存储服务) | Blob Storage | Cloud Storage |
| 数据库 | RDS (Relational Database Service,关系型数据库服务) | SQL Database | Cloud SQL |
| 容器服务 | ECS/EKS (Elastic Kubernetes Service,弹性Kubernetes服务) | AKS (Azure Kubernetes Service) | GKE (Google Kubernetes Engine) |
| CDN | CloudFront | CDN | Cloud CDN |
服务架构关系图
环境准备与CLI配置
三大平台CLI安装命令
所有命令已适配Linux环境,确保当前工作目录具备执行权限
# AWS CLI 安装 (基于 [requirements.txt](https://gitcode.com/gh_mirrors/aw/awesome-cheatsheet/blob/e7507591b93e2cfd924a55e4ccb8056c44c43ac5/requirements.txt?utm_source=gitcode_repo_files) 依赖管理)
pip install awscli --upgrade
# Azure CLI 安装
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# GCP CLI 安装
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk
配置流程对比
| 步骤 | AWS | Azure | GCP |
|---|---|---|---|
| 初始化 | aws configure | az login | gcloud init |
| 区域设置 | aws configure set region us-west-2 | az account set --subscription <订阅ID> | gcloud config set compute/region us-central1 |
| 凭证验证 | Access Key/Secret Key | 自动令牌管理 | 应用默认凭据 |
| 配置文件 | ~/.aws/credentials | ~/.azure/ | ~/.config/gcloud/ |
计算服务核心操作
EC2/VM/Compute Engine 实例管理
# AWS EC2: 启动实例 (基于Amazon Linux 2镜像)
aws ec2 run-instances \
--image-id ami-0c55b159cbfafe1f0 \
--instance-type t2.micro \
--key-name my-key-pair \
--security-group-ids sg-0123456789abcdef0
# Azure VM: 创建虚拟机
az vm create \
--resource-group myResourceGroup \
--name myVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
# GCP Compute Engine: 创建实例
gcloud compute instances create my-instance \
--image-family ubuntu-2004-lts \
--image-project ubuntu-os-cloud \
--machine-type e2-small \
--zone us-central1-a
无服务器函数对比
// AWS Lambda 函数示例 (Node.js)
exports.handler = async (event) => {
const response = {
statusCode: 200,
body: JSON.stringify('Hello from AWS Lambda!'),
};
return response;
};
// Azure Functions 示例 (Node.js)
module.exports = async function (context, req) {
context.res = {
body: "Hello from Azure Functions!"
};
};
// GCP Cloud Functions 示例 (Node.js)
exports.helloWorld = (req, res) => {
res.send('Hello from Google Cloud Functions!');
};
存储服务操作速查
对象存储基础命令
| 操作 | AWS S3 | Azure Blob Storage | GCP Cloud Storage |
|---|---|---|---|
| 创建存储桶 | aws s3 mb s3://my-bucket | az storage container create --name mycontainer | gsutil mb gs://my-bucket |
| 上传文件 | aws s3 cp file.txt s3://my-bucket | az storage blob upload --container-name mycontainer --file file.txt --name blobname | gsutil cp file.txt gs://my-bucket |
| 下载文件 | aws s3 cp s3://my-bucket/file.txt . | az storage blob download --container-name mycontainer --name blobname --file file.txt | gsutil cp gs://my-bucket/file.txt . |
| 列出内容 | aws s3 ls s3://my-bucket | az storage blob list --container-name mycontainer | gsutil ls gs://my-bucket |
| 删除对象 | aws s3 rm s3://my-bucket/file.txt | az storage blob delete --container-name mycontainer --name blobname | gsutil rm gs://my-bucket/file.txt |
存储类型对比表
| 存储类型 | AWS | Azure | GCP | 适用场景 |
|---|---|---|---|---|
| 标准存储 | S3 Standard | Hot Blob Storage | Standard Storage | 频繁访问数据 |
| 低频存储 | S3 Infrequent Access | Cool Blob Storage | Nearline Storage | 偶尔访问数据 |
| 归档存储 | S3 Glacier | Archive Blob Storage | Coldline Storage | 长期归档数据 |
| 文件存储 | EFS (Elastic File System) | Files Storage | Cloud Filestore | 需要共享的文件系统 |
数据库服务配置指南
关系型数据库创建对比
# AWS RDS: 创建MySQL实例
aws rds create-db-instance \
--db-instance-identifier mydbinstance \
--db-instance-class db.t2.micro \
--engine mysql \
--master-username admin \
--master-user-password password \
--allocated-storage 20
# Azure SQL Database: 创建数据库
az sql server create \
--name myserver \
--resource-group myResourceGroup \
--admin-user admin \
--admin-password password
az sql db create \
--resource-group myResourceGroup \
--server myserver \
--name mydb \
--service-objective S0
# GCP Cloud SQL: 创建实例
gcloud sql instances create myinstance \
--database-version=MYSQL_8_0 \
--tier=db-f1-micro \
--region=us-central1
数据库连接字符串格式
| 数据库类型 | AWS | Azure | GCP |
|---|---|---|---|
| MySQL | mysql -h mydbinstance.123456789012.us-west-2.rds.amazonaws.com -u admin -p | mysql -h myserver.database.windows.net -u admin@myserver -p | gcloud sql connect myinstance --user=root |
| PostgreSQL | psql -h mydbinstance.123456789012.us-west-2.rds.amazonaws.com -U admin -d postgres | psql --host=myserver.postgres.database.azure.com --username=admin@myserver --dbname=postgres | psql "host=35.192.0.1 dbname=postgres user=postgres password=password" |
容器服务管理
Kubernetes服务部署流程
容器镜像仓库操作
| 操作 | AWS ECR (Elastic Container Registry) | Azure ACR (Azure Container Registry) | GCP GCR (Google Container Registry) |
|---|---|---|---|
| 创建仓库 | aws ecr create-repository --repository-name my-repo | az acr create --name myregistry --resource-group myResourceGroup --sku Basic | gcloud artifacts repositories create my-repo --repository-format=docker --location=us-central1 |
| 登录仓库 | aws ecr get-login-password | docker login --username AWS --password-stdin <account-id>.dkr.ecr.<region>.amazonaws.com | az acr login --name myregistry | gcloud auth configure-docker |
| 推送镜像 | docker push <account-id>.dkr.ecr.<region>.amazonaws.com/my-repo:tag | docker push myregistry.azurecr.io/my-image:tag | docker push gcr.io/<project-id>/my-image:tag |
| 拉取镜像 | docker pull <account-id>.dkr.ecr.<region>.amazonaws.com/my-repo:tag | docker pull myregistry.azurecr.io/my-image:tag | docker pull gcr.io/<project-id>/my-image:tag |
网络服务配置
VPC/VNet网络架构对比
负载均衡服务配置
| 负载均衡类型 | AWS | Azure | GCP |
|---|---|---|---|
| 应用层负载均衡 | Application Load Balancer | Application Gateway | Cloud Load Balancing (HTTP(S)) |
| 网络层负载均衡 | Network Load Balancer | Load Balancer | Cloud Load Balancing (TCP/SSL) |
| DNS负载均衡 | Route 53 | Traffic Manager | Cloud DNS |
监控与日志管理
核心监控服务对比
| 功能 | AWS CloudWatch | Azure Monitor | GCP Cloud Monitoring |
|---|---|---|---|
| 指标收集 | 自动收集AWS资源指标 | 自动收集Azure资源指标 | 自动收集GCP资源指标 |
| 日志管理 | CloudWatch Logs | Log Analytics | Cloud Logging |
| 告警配置 | CloudWatch Alarms | Action Groups | Alerting Policies |
| 性能分析 | X-Ray | Application Insights | Cloud Trace |
| 成本分析 | Cost Explorer | Cost Management | Cost Management |
日志查询示例
-- AWS CloudWatch Logs Insights 查询
fields @timestamp, @message
| filter @message like /error/
| sort @timestamp desc
| limit 20
-- Azure Log Analytics 查询
AppLogs
| where Message contains "error"
| sort by TimeGenerated desc
| take 20
-- GCP Cloud Logging 查询
resource.type="gce_instance"
logName="projects/my-project/logs/syslog"
textPayload:"error"
| order by timestamp desc
| limit 20
安全服务配置
IAM权限管理对比
| 权限管理组件 | AWS IAM | Azure AD | GCP IAM |
|---|---|---|---|
| 用户管理 | IAM Users | Azure AD Users | Cloud IAM Users |
| 角色管理 | IAM Roles | Azure AD Roles | IAM Roles |
| 权限策略 | IAM Policies | Role-Based Access Control | IAM Policies |
| 多因素认证 | MFA (Multi-Factor Authentication) | MFA | 2-Step Verification |
| 临时凭证 | STS (Security Token Service) | Azure AD Tokens | Service Accounts |
安全命令示例
# AWS IAM: 创建用户并附加策略
aws iam create-user --user-name myuser
aws iam attach-user-policy --user-name myuser --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
# Azure AD: 创建用户
az ad user create \
--display-name "My User" \
--user-principal-name myuser@contoso.com \
--password password \
--force-change-password-next-login false
# GCP IAM: 添加用户权限
gcloud projects add-iam-policy-binding my-project \
--member=user:myuser@example.com \
--role=roles/storage.objectViewer
成本优化策略
资源成本对比表(月度)
| 资源类型 | AWS | Azure | GCP | 成本优化建议 |
|---|---|---|---|---|
| t2.micro/ B1s/ f1-micro 实例 | ~$11.50 | ~$13.00 | ~$4.00 | 使用抢占式实例/Spot VM |
| 100GB 标准存储 | ~$23.00 | ~$20.00 | ~$20.00 | 实施生命周期策略 |
| 1TB 数据传输(出) | ~$90.00 | ~$87.00 | ~$85.00 | 使用CDN减少传输量 |
| 1GB RAM 数据库 | ~$15.00 | ~$14.00 | ~$12.00 | 选择适当规格,避免过度配置 |
成本监控命令
# AWS Cost Explorer: 获取月度成本摘要
aws ce get-cost-and-usage \
--time-period Start=2023-01-01,End=2023-01-31 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
# Azure Cost Management: 获取成本分析
az costmanagement query \
--type Usage \
--scope /subscriptions/<subscription-id> \
--timeframe MonthToDate \
--dataset granularity='Daily',aggregation='{"totalCost": {"name":"PreTaxCost","function":"Sum"}}'
# GCP Cost Management: 获取成本摘要
gcloud beta billing accounts get-iam-policy <billing-account-id>
自动化与DevOps集成
基础设施即代码(IaC)工具对比
| IaC工具 | AWS | Azure | GCP | 代码示例 |
|---|---|---|---|---|
| CloudFormation | 原生支持 | 不支持 | 不支持 | AWS CloudFormation示例 |
| ARM Templates | 不支持 | 原生支持 | 不支持 | Azure ARM模板示例 |
| Terraform | 支持 | 支持 | 支持 | Terraform多平台示例 |
CI/CD服务集成
# AWS CodePipeline 配置示例
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyPipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
ArtifactStore:
Type: S3
Location: my-artifact-bucket
RoleArn: !GetAtt MyPipelineRole.Arn
Stages:
- Name: Source
Actions:
- Name: Source
ActionTypeId:
Category: Source
Owner: AWS
Provider: CodeCommit
Version: '1'
Configuration:
RepositoryName: my-repo
BranchName: main
# Azure DevOps Pipeline 配置示例
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
# GCP Cloud Build 配置示例
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/my-project/my-image', '.']
images:
- 'gcr.io/my-project/my-image'
迁移策略与最佳实践
云平台迁移流程图
跨平台迁移工具对比
| 迁移类型 | AWS | Azure | GCP |
|---|---|---|---|
| 服务器迁移 | AWS Server Migration Service | Azure Migrate | Migrate for Compute Engine |
| 数据库迁移 | AWS Database Migration Service | Azure Database Migration Service | Database Migration Service |
| 存储迁移 | AWS DataSync | Azure Data Factory | Storage Transfer Service |
| 应用迁移 | AWS Application Migration Service | Azure App Service Migration Assistant | App Engine Migration Toolkit |
问题排查与故障处理
常见问题排查流程
| 问题类型 | 排查步骤 | AWS 工具 | Azure 工具 | GCP 工具 |
|---|---|---|---|---|
| 实例无法启动 | 1. 检查资源配额 2. 检查安全组规则 3. 检查镜像状态 4. 查看启动日志 | EC2 Console, CloudWatch Logs | Azure Portal, Serial Console | Compute Engine Console, Cloud Logging |
| 存储访问失败 | 1. 检查权限设置 2. 验证网络连接 3. 检查存储容量 4. 查看访问日志 | IAM Policy Simulator, S3 Access Analyzer | Storage Explorer, Activity Log | gsutil, Cloud Storage Browser |
| 性能问题 | 1. 检查资源使用率 2. 分析网络流量 3. 查看数据库性能 4. 检查应用日志 | CloudWatch Metrics, X-Ray | Azure Monitor, Application Insights | Cloud Monitoring, Cloud Trace |
故障处理命令示例
# AWS: 查看实例状态
aws ec2 describe-instances --instance-ids i-0123456789abcdef0
# Azure: 重启虚拟机
az vm restart --resource-group myResourceGroup --name myVM
# GCP: 查看实例日志
gcloud compute instances get-serial-port-output my-instance --zone us-central1-a
总结与进阶资源
通过本文的系统梳理,你已经掌握了AWS、Azure和GCP三大云服务平台的核心操作和关键差异。为了进一步提升你的云服务管理技能,建议参考以下资源:
-
官方文档:
- AWS官方文档:AWS Documentation
- Azure官方文档:Azure Documentation
- GCP官方文档:GCP Documentation
-
项目社区资源:
- 贡献指南:CONTRIBUTING.md
- 行为准则:CODE_OF_CONDUCT.md
- 测试脚本:tests/url_validate.py
-
进阶学习路径:
- 云架构师认证:AWS Certified Solutions Architect, Azure Solutions Architect, GCP Professional Cloud Architect
- 成本优化专家:云成本管理专业认证
- DevOps工程师:云平台DevOps专业认证
希望本文能成为你日常云服务管理工作的得力助手。如有任何问题或建议,请通过项目GitHub仓库提交issue或PR。点赞、收藏、关注,获取更多云服务平台实用指南!下期预告:《云原生应用设计模式与最佳实践》。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考



