[英]AWS CDK Deployment Issues
我試圖將示例公共映像從 ecr 部署到 cdk。 因此,我以不使用 nat 網關的方式為此編寫了一些代碼,因此我為 aws 服務創建了一些 vpc 端點。 這是完整的代碼供參考,
from aws_cdk import (
Stack,
aws_ec2 as ec2,
aws_ecr as ecr,
aws_ecs as ecs,
aws_ecs_patterns as ecs_patterns
)
from constructs import Construct
class Microservice(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
vpc = ec2.Vpc(
self,
"MyVpc",
max_azs=2,
nat_gateways=0,
)
vpc.add_interface_endpoint(
"S3Endpoint", service=ec2.InterfaceVpcEndpointAwsService.S3, private_dns_enabled=False)
vpc.add_interface_endpoint(
"SSMEndpoint", service=ec2.InterfaceVpcEndpointAwsService.SSM)
vpc.add_interface_endpoint(
"EcrDockerEndpoint", service=ec2.InterfaceVpcEndpointAwsService.ECR_DOCKER)
vpc.add_interface_endpoint(
"EcrEndpoint", service=ec2.InterfaceVpcEndpointAwsService.ECR)
cluster = ecs.Cluster(self, "MyCluster", vpc=vpc)
ecs_patterns.ApplicationLoadBalancedFargateService(
self,
"MyFargateService",
cluster=cluster,
cpu=512,
task_image_options=ecs_patterns.ApplicationLoadBalancedTaskImageOptions(
image=ecs.ContainerImage.from_ecr_repository(
ecr.Repository.from_repository_name(self, "SampleRepo", "ecs-sample-image/amazon-ecs-sample"))
),
memory_limit_mib=1024
)
cdk synth 運行良好,但是當我部署它然后在 aws 中時,我收到一條錯誤消息:
STOPPED (Resourceinitializationerror: unable to pull secrets or registry auth: execution resource retrieval failed: unable to retrieve ecr registry auth: service call has been retried 3 time(s): RequestError: send request failed caused by: Post "https://api.ecr.us-east-1.amazonaws.com/": dial tcp 209.54.183.210:443: i/o timeout)
任何人都請幫助我理解這里的問題。
我在這里看到兩個可能的問題:
service.node.add_dependency(endpoint)
) 或將 VPC 和服務分成兩個不同的堆棧。 分離網絡、數據和應用程序堆棧被認為是最佳實踐。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.