【以下的问题经过翻译处理】 嗨,我一直在试图让这个工作,但却无法解决问题。
我有一个在2个私有子网中的ECS Fargate集群。有2个公共子网和Nat GWs(需要运行于Fargate中的任务) 。目前,我已经通过NatGW处理了S3流量,并希望实现"S3端点"以符合最佳实践。我已创建了CFN脚本来创建端点并关联安全组。所有资源都已经创建并且似乎正在工作。但是,从日志中我发现S3的流量仍然通过NatGW进行。 我有什么基本错误吗?是否有一种方法可以强制来自任务的流量到S3端点?
Fargate任务安全组的出站规则如下:
SecurityGroupEgress:
- IpProtocol: "-1"
CidrIp: 0.0.0.0/0
以下是创建端点和安全组的脚本:
endpointS3SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: "Security group for S3 endpoint"
GroupName: "S3-endpoint-sg"
Tags:
- Key: "Name"
Value: "S3-endpoint-sg"
VpcId: !Ref vpc
SecurityGroupIngress:
- IpProtocol: "tcp"
FromPort: 443
ToPort: 443
SourceSecurityGroupId: !Ref fargateContainerSecurityGroup
# S3 endpoint
endpointS3:
Type: AWS::EC2::VPCEndpoint
Properties:
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal: '*'
Action: 's3:*'
Resource: '*'
SubnetIds:
- !Ref privateSubnet1
- !Ref privateSubnet2
VpcEndpointType: Interface
SecurityGroupIds:
- !Ref endpointS3