

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

# 内部开发平台的黄金之路示例
<a name="examples"></a>

**Topics**
+ [无服务器工作负载](#example-serverless)
+ [Amazon Elastic Container Service（Amazon ECS）](#example-ecs)
+ [Amazon Elastic Kubernetes Service (Amazon EKS)](#example-eks)

## 无服务器工作负载
<a name="example-serverless"></a>

*开发*
+ 使用 [AWS Serverless Application Model (AWS SAM) CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-test-and-debug.html) 进行本地开发和测试。
+ 使用[AWS 集成应用程序测试套件](https://github.com/awslabs/aws-iatk)进行集成测试。
+ 在负载测试期间，使用 [Amazon CodeGuru Profiler](https://docs.aws.amazon.com/codeguru/latest/profiler-ug/what-is-codeguru-profiler.html) 对您的应用程序进行微调。

*应用程序设计和部署*
+ 使用 fo [AWS Cloud Development Kit (AWS CDK)](https://docs.aws.amazon.com/cdk/v2/guide/home.html)r 基础架构即代码。
+ 使用 [CDK](https://docs.aws.amazon.com/cdk/v2/guide/cdk_pipeline.html) Pipelines自动部署基础架构和应用程序。
+ 对于脚手架资源，请使用容器镜像创建[AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)函数并将其存储在亚马逊[弹性容器注册表 (Ama](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html) zon ECR) Container Registry 中。
+ 使用 [Lambda 图像](https://gallery.ecr.aws/lambda)而不是普通图片。
+ 对于联网，建议您在启用了 VPC [流日志并使用接口 VPC](https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html) [终端节点](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html)访问私有资源的虚拟私有云 (VPCs) 中部署 Lambda 函数。
+ 使用 [Amazon API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html) 将 HTTP 请求路由到 Lambda 函数。
+ 使用[版本](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html)来管理您的 Lambda 函数的部署。
+ [AWS AppConfig](https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html)用于带有验证器的动态配置。
+ [AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html)用于检索机密。
+ 要进行灰度测试，请使用[别名路由配置](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html#configuring-alias-routing)将部分流量发送到第二个 Lambda 函数版本。
+ 在 Amazon 中使用[自动回滚](https://docs.aws.amazon.com/codedeploy/latest/userguide/deployments-rollback-and-redeploy.html#deployments-rollback-and-redeploy-automatic-rollbacks) AWS CodeDeploy 并配置[警报](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html) CloudWatch 以启动回滚。

*操作*
+ 启用 [API Gateway 访问日志](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html)。
+ 记录 API Gateway 请求编号、扩展请求编号和 Lambda 请求编号。
+ 对 Lambda 函数使用结构化日志，最好采用 JSON 格式。
+ 将日志发送到标准输出 (stdout)，而不是调用日志 API。 CloudWatch 
+ 使用 [AWS Lambda Powertools](https://github.com/aws-powertools/) 实施无服务器最佳实践。
+ 根据贵组织的要求设置日志保留期。
+ 启用 [CloudWatch Lambda Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights.html) 来收集、汇总和汇总诊断信息，例如冷启动。这可以帮助您隔离并快速解决您的 Lambda 函数的问题。
+ 在 CloudWatch、中、`Errors``Throttles``ProvisionedConcurrencySpilloverInvocations`、和`Duration`指标来监控您的 Lambda 函数。有关更多信息，请参阅[使用 Lambda 函数指标](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics.html#monitoring-metrics-types)。
+ 在中 CloudWatch，使用 4xx 错误代码、5xx 错误代码和延迟指标来监控您的。 APIs
+ [AWS X-Ray](https://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html)用于收集有关您的应用程序所处理的请求的数据。对于使用分布式组件和服务的应用程序，这可以帮助您快速识别问题和优化机会。

## Amazon Elastic Container Service（Amazon ECS）
<a name="example-ecs"></a>

*开发*
+ 遵循亚马逊弹性容器服务 (Amazon ECS) 容器镜像[的最佳实践](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-considerations.html)。
+ 使用 [Amazon Elastic Container Registry (Amazon ECR](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html)) 来存储容器镜像并进行持续的安全扫描。

*应用程序设计和部署*
+ 按照[最佳实践](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/application_architecture.html#application_architecture_fargate)在 Amazon ECS 上架构您的应用程序。
+ 使用基础架构即[AWS Cloud Development Kit (AWS CDK)](https://docs.aws.amazon.com/cdk/v2/guide/home.html)代码和 CI/CD 管道，用于基础架构和应用程序部署。
+ 使用 [Amazon ECS Service Connect](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect.html) 管理用于服务发现、连接和流量监控的 Amazon ECS 配置。
+ 将 [Amazon Elastic File System (Amazon EFS)](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html) 用于水平扩展的容器化应用程序。如果您的应用程序需要亚毫秒的延迟并且不需要共享文件[系统，请使用 Amazon Elastic Block Store (Amazon EBS](https://docs.aws.amazon.com/ebs/latest/userguide/what-is-ebs.html)) Block Store。

*操作*
+ [AWS Fargate](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html)之所以使用，是因为它提供了一种托管的方式来容器化您的工作负载，而无需管理服务器或亚马逊弹性计算云 (Amazon EC2) 实例的集群。
+ 将[蓝/绿部署](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-bluegreen.html)与配合使用。 AWS CodeDeploy
+ 使用 [Amazon CloudWatch Container Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/deploy-container-insights-ECS.html) 收集、汇总和汇总来自容器化应用程序和微服务的指标和日志。
+ 启用[FireLens 适用于 Amazon ECS](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html) 的日志驱动程序，使用 for Fl [uent Bit](https://github.com/aws/aws-for-fluent-bit) sidecar 容器来提高性能并将日志流重定向到不同的位置，例如亚马逊简单存储服务 (Amazon S3) CloudWatch Simple Storage Service 或日志组。AWS 

*其他资源*
+ [亚马逊 ECS 蓝图](https://github.com/aws-ia/ecs-blueprints) () GitHub

## Amazon Elastic Kubernetes Service (Amazon EKS)
<a name="example-eks"></a>

*开发*
+ 遵循亚马逊弹性容器服务 (Amazon ECS) 容器镜像[的最佳实践](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-considerations.html)。
+ 使用 [Amazon Elastic Container Registry (Amazon ECR](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html)) 来存储容器镜像并进行持续的安全扫描。

*应用程序设计和部署*
+ 使用 [Helm](https://helm.sh/docs/) 打包您的应用程序模板。
+ 按照一种 GitOps 方法使用 A [rgo CD](https://argo-cd.readthedocs.io/en/stable/) 来部署您的应用程序。
+ 使用 [AWS Load Balancer 控制器](https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html)管理 Kubernetes 集群的弹性负载平衡资源。
+ 使用[证书管理器和AWS 私有证书颁发机构](https://github.com/cert-manager/cert-manager)[颁发者](https://github.com/cert-manager/aws-privateca-issuer/)管理 TLS 证书。
+ 使用[亚马逊 Elastic Block Store (Amazon EBS) 容器存储接口 (CSI)](https://docs.aws.amazon.com/eks/latest/userguide/ebs-csi.html) 驱动程序或[亚马逊弹性文件系统 (Amazon EFS) CSI](https://docs.aws.amazon.com/eks/latest/userguide/efs-csi.html) 驱动程序获取存储选项。
+ 使用 [ExternalDNS](https://github.com/kubernetes-sigs/external-dns) 将 Kubernetes 服务与亚马逊 Route 53 集成。
+ 使用[外部密钥运算符](https://github.com/external-secrets/external-secrets)将机密存储在 AWS Secrets Manager 或 AWS Systems Manager 参数存储中。
+ 使用 [Crossp](https://www.crossplane.io/) lane 从你的 Kubernetes 集群管理 AWS 基础架构。

*操作*
+ 将 [Calico](https://www.tigera.io/project-calico/) 用于网络策略，使用 [Gatekeeper](https://github.com/open-policy-agent/gatekeeper) 作为策略控制器。
+ 使用 [Karpenter](https://github.com/aws/karpenter-provider-aws) 进行集群自动扩展。
+ 使用[适用于 Prometheus 的亚马逊托管服务和](https://docs.aws.amazon.com/prometheus/latest/userguide/what-is-Amazon-Managed-Service-Prometheus.html)[亚马逊](https://docs.aws.amazon.com/grafana/latest/userguide/what-is-Amazon-Managed-Service-Grafana.html)托管 Grafana 来提高可观察性。
+ 使用 [Kubecost](https://www.kubecost.com/) 提供实时的基础设施成本可见性。

*其他资源*
+ [亚马逊 EKS 的 Terraform 蓝图](https://aws-ia.github.io/terraform-aws-eks-blueprints/)