如何使用 aws cli 配置 AWS Fargate 以允许入站流量

How can I configure AWS Fargate to allow inbound traffic using aws cli

我正在尝试开始使用 AWS Fargate(使用 aws cli 来编写脚本)并启动了我的服务,我可以从它执行的日志中看到。

然而,当我连接到任务的 public IP 时,我在容器正在侦听的端口上没有得到任何响应。容器在本地工作。

如何使用 aws cli 配置 AWS Fargate 以允许入站流量?

很可能,问题与安全组配置问题有关。 您必须启用容器正在使用的端口。

您可以创建或更新当前安全组以允许从 VPC 外部访问该端口。

用于创建新的安全组:https://docs.aws.amazon.com/cli/latest/reference/ec2/create-security-group.html

更新当前安全组: https://docs.aws.amazon.com/cli/latest/reference/ec2/update-security-group-rule-descriptions-ingress.html

用于更新 ECS 服务的安全组: https://docs.aws.amazon.com/cli/latest/reference/ecs/update-service.html

原来问题出在默认安全组不允许入站流量。以下命令使我能够找到我的 VPC 使用了哪个安全组,并允许所有入站流量进入该 VPC。

aws ec2 describe-security-groups --filters 名称=vpc-id,值=$vpcid

aws ec2 authorize-security-group-ingress --group-id $secgroup --protocol tcp --cidr 0.0.0.0/0 --port 0-65535