containers-roadmap icon indicating copy to clipboard operation
containers-roadmap copied to clipboard

Fargate tasks: ability to set a proxy to be used

Open ricoli opened this issue 6 years ago • 39 comments

Summary

Feature request for Fargate tasks: ability to set a proxy to be used for pulling Docker images and automatically set the proxy env variables inside containers (as per https://docs.docker.com/network/proxy/#configure-the-docker-client)

Description

In environments where security is paramount it is very common to have to use a proxy for all outbound Internet traffic. Given AWS ECR currently doesn't offer a VPC endpoint, pulling images from it requires an Internet connection. It's possible to set such a proxy configuration using EC2 ECS tasks, but not when running Fargate tasks (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html#fargate-tasks-services-networking). Also of great usefulness would be if this proxy configuration would automatically propagate into launched containers of a Fargate task.

EDIT: There's now support for ECR on PrivateLink: https://aws.amazon.com/about-aws/whats-new/2019/01/aws-fargate--amazon-ecs--and-amazon-ecr-now-have-support-for-aws/, so this issue is only relevant for people wishing to use private repositories other than ECR.

ricoli avatar Jul 12 '18 14:07 ricoli

i need this functionality as well

andyakins avatar Aug 10 '18 14:08 andyakins

#metoo We are unable to use Fargate without either a VPC endpoint for ECR (and presumably IAM) or without the ability to specify proxy for image download.

mludvig avatar Aug 15 '18 02:08 mludvig

One of the solutions is to replace NAT instance with squid configured as transparent proxy. On squid instance you need to disable destination check and set it as destination in routing table.

You can read about it here: https://aws.amazon.com/blogs/security/how-to-add-dns-filtering-to-your-nat-instance-with-squid/

Also, Amazon has a blog post on how to make a highly available solution for NAT/Squid: https://aws.amazon.com/articles/high-availability-for-amazon-vpc-nat-instances-an-example/

Right now we have squid instance with ECR access allowed only. We run separate Fargate services squid/proxy for the rest of our needs (applications, etc.).

alovak avatar Sep 17 '18 20:09 alovak

I really need this functionality

angusfz avatar Oct 26 '18 03:10 angusfz

I really need this functionality.

#MeToo

shazi7804 avatar Oct 26 '18 03:10 shazi7804

I really need this functionality !!

noahxp avatar Oct 29 '18 05:10 noahxp

same problem here.

karlismelderis avatar Oct 30 '18 11:10 karlismelderis

I need this. Huge problem with secure fargate setup

williamoverton avatar Nov 11 '18 21:11 williamoverton

We need this too for our company to use fargate.

ishug86 avatar Nov 28 '18 21:11 ishug86

I agree, this is causing a problem for me too, but in my case my proxy is on a non-cloud part of the network, so routing everything through the proxy leads to unnecessary network traffic. So, while the ability to set a proxy would solve the problem functionally, I'm not sure it's the best solution.

My personal preferred options, in descending order of preference:

  • Ability to run ECRs within the VPC - it's feels weird to me that my containers are living outside my VPC anyway, I'd expect the registry to be addressable in my private network somewhere.
  • An endpoint like the s3 access endpoint
  • Ability to set the proxy

tstibbs avatar Nov 29 '18 08:11 tstibbs

+1 for "Why isn't Fargate still ready for this?" Not all the customers really love to use Public subnets in all of their VPCs...

mlepriberluti avatar Nov 29 '18 13:11 mlepriberluti

I am not sure if i am missing somethings in my configuration, but i am able to get image pulled from ECR even when ENI have only private IP and Auto-assign public IP DISABLED mode. i am using same AWS account and region for both ECS service and ECR. Since my containers have no reason to be reached out from the outside world, they are deployed in private subnets with an available route to a NAT gateway and i am able to pull the image from ECR.

hridyeshpant avatar Nov 30 '18 22:11 hridyeshpant

@hridyeshpant I think having a NAT gateway allows you to have connectivity to the internet. Which basically means that all the apps on that subnet can reach the internet unrestricted (that's what the proxy server is used for). Which a lot of teams will not want.

ishug86 avatar Dec 03 '18 17:12 ishug86

we need this, too!

uherberg avatar Jan 22 '19 19:01 uherberg

now that https://aws.amazon.com/about-aws/whats-new/2019/01/aws-fargate--amazon-ecs--and-amazon-ecr-now-have-support-for-aws/ has been released, the need for this issue would only relate to using private repositories other than ECR

ricoli avatar Jan 30 '19 11:01 ricoli

Yes, I agree with @ricoli . This is how we solved the problem for us. We have our Fargate tasks behind an HTTP proxy (without direct NAT access) that filters outgoing traffic just fine. Docker images are pulled via endpoint from ECR.

uherberg avatar Feb 13 '19 17:02 uherberg

ECR endpoints don't work across regions, still an issue for us.

liamn-verrency avatar Jul 30 '19 06:07 liamn-verrency

I really need this functionality too.

Meanwhile, we could use https://aws.amazon.com/about-aws/whats-new/2019/02/aws-fargate-now-has-support-for-aws-privatelink/

mpucholblasco avatar Sep 05 '19 14:09 mpucholblasco

so this issue is only relevant for people wishing to use private repositories other than ECR.

Correct me if I'm mistaken but this also prevents pulling images from the public Docker Registry.

mendhak avatar Feb 24 '20 21:02 mendhak

so this issue is only relevant for people wishing to use private repositories other than ECR.

Correct me if I'm mistaken but this also prevents pulling images from the public Docker Registry.

Only if said images are private of course

ricoli avatar Feb 24 '20 22:02 ricoli

so this issue is only relevant for people wishing to use private repositories other than ECR.

Correct me if I'm mistaken but this also prevents pulling images from the public Docker Registry.

Only if said images are private of course

it's for (all) enterprise customers

konpol avatar Feb 24 '20 22:02 konpol

still need this. Some customers do not use endpoints (for cost reasons among others) and prefer to treat AWS like a remote office with all external traffic going via their internal proxies

jamieschuts avatar May 19 '20 00:05 jamieschuts

Our company need this too. This prevents us from using fargate right now.

Nico-DB avatar May 27 '20 13:05 Nico-DB

Our organisation also requires this functionality in order to use Fargate

major-fire avatar Jun 24 '20 11:06 major-fire

Our company need this feature. Without a proxy option, we cant use fargate.

tmvogts avatar Sep 30 '20 07:09 tmvogts

My use case is related to caching. We have the same image running many times on ECS and Fargate. At the moment every task downloads the same image separately. This results in unnecessary data transfer from NAT Gateway. Instead there could be a proxy inside the private subnet caching the image for subsequent requests.

raehalme avatar Dec 08 '20 15:12 raehalme

My use case is related to caching. We have the same image running many times on ECS and Fargate. At the moment every task downloads the same image separately. This results in unnecessary data transfer from NAT Gateway. Instead there could be a proxy inside the private subnet caching the image for subsequent requests.

@raehalme wouldn't this use case be implemented using an ECR VPC endpoint?

mreferre avatar Dec 09 '20 14:12 mreferre

My use case is related to caching. We have the same image running many times on ECS and Fargate. At the moment every task downloads the same image separately. This results in unnecessary data transfer from NAT Gateway. Instead there could be a proxy inside the private subnet caching the image for subsequent requests.

@raehalme wouldn't this use case be implemented using an ECR VPC endpoint?

@mreferre As VPC endpoint for ECR also charges for the data transfer I'm not sure I understand how it helps solve my use case.

raehalme avatar Dec 13 '20 13:12 raehalme

You are correct. I have interpreted your request as a raw "how do I avoid using NAT GW" and mentioned VPC endpoint as a way to mitigate (not eliminate admittedly, as you noted) those costs.

mreferre avatar Dec 14 '20 10:12 mreferre

My use case is related to caching. We have the same image running many times on ECS and Fargate. At the moment every task downloads the same image separately. This results in unnecessary data transfer from NAT Gateway. Instead there could be a proxy inside the private subnet caching the image for subsequent requests.

@raehalme wouldn't this use case be implemented using an ECR VPC endpoint?

@mreferre As VPC endpoint for ECR also charges for the data transfer I'm not sure I understand how it helps solve my use case.

@raehalme It occurred to me to note someone else is pointing out in a parallel issue that if you configure the GW endpoint S3 transfers cost $0. The docs actually seem to suggest to configure the S3 GW endpoint:

Amazon ECS tasks hosted on Fargate using platform version 1.4.0 or later require both the com.amazonaws.region.ecr.dkr and com.amazonaws.region.ecr.api Amazon ECR VPC endpoints as well as the Amazon S3 gateway endpoint to take advantage of this feature.

Given all major traffic goes through S3 (and ECR traffic is only minimal) you are basically not paying for data transfer. Would that be acceptable?

mreferre avatar Aug 28 '21 13:08 mreferre