Skip to content

VPC configuration for a Fargate job

0

We are running Fargate jobs from step functions where a single job might use/access S3, DynamoDB, Athena and Timestream. I see that we need to host the Fargate job in a VPC and give a subnet id and security group to it.

If we specify a security group without inbound rules and 0.0.0.0/0 as OUT rule (i.e. deny all) and for a subnet, we give one of the default subnets, do we need to enable BPA to not allow access outside of cloud? Would this be enough for the security and functioning of the Fargate job or something else needs to be considered? Should the security group be any different?

We tried it with BPA on ingress-only and having an exclusion for the VPC to allow bidirectional. The fargate job launched successfully and finished. However, it feels like BPA is unnecessary if there is an exclusion like that.

asked a year ago347 views

2 Answers
1
Accepted Answer

You're thinking along the right lines — but let’s clarify a few key points:

Fargate in a VPC: When running Fargate tasks in a VPC, they need:

  1. Subnet (public or private with NAT)
  2. Security group (acts like a virtual firewall)

Security Group Settings:

  • It's fine for the security group to have no inbound rules (Fargate tasks typically initiate outbound connections).
  • For outbound, you can restrict 0.0.0.0/0, but only if your task doesn't need internet access (e.g., S3 via VPC endpoint is fine).

BPA (Block Public Access):

  • If your resources (like S3) are private and accessed via VPC endpoints, BPA is often not needed.
  • However, if BPA is enabled, you need exclusions (as you did) to allow internal access, making BPA somewhat redundant in this context.

✅ Recommendation:

  • Use VPC endpoints for S3, DynamoDB, Timestream, and Athena if possible.
  • Use private subnets with no NAT for stricter control.
  • Use security groups with only required outbound traffic.
  • BPA is optional here, especially if you're already restricting internet traffic.

So yes — your current setup is valid, and BPA might not add much if you’re excluding the VPC anyway.

answered a year ago

EXPERT

reviewed a year ago

  • Thanks, after a bit of digging I figured out we need VPC endpoints, though making them work turned out to be a bit of a challenge.

0

BPA is a new security standard in AWS VPC. Its not mandatory, however your approach is right. Theres 2 options for you depending on your traffic.

  1. You can enable BPA with Block INGRESS and not create any exclusions
  2. You can Enable BPA with blocking Bidirection and then you will need your Exclusion (Bidirectional).

You will only need the Exclusions for your public subnets

EXPERT

answered a year ago

  • When I enabled BPA with block ingress traffic, I started getting error: "ResourceInitializationError: unable to pull secrets or registry auth: The task cannot pull registry auth from Amazon ECR: There is a connection issue between the task and Amazon ECR. Check your task network configuration ... i/o timeout"

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.