Lesson 2 of 6 Data Security

Keeping Data Services Private with Network Controls

This lesson explains how VPC design, endpoints and security groups keep data services off the internet while letting them reach each other and AWS APIs.

Learning outcomes

After completing this lesson, you will be able to:

  • Place data services in private subnets with VPC endpoints.
  • Configure a Glue connection for a VPC resource.
  • Restrict access by network with aws:SourceVpce conditions.

Network controls

Network controls keep data services off the internet while letting them reach each other. Databases and clusters run in private subnets. A Glue connection to a VPC resource places Glue's network interfaces in a subnet, and their security group needs a self-referencing rule, allowing all traffic from the same group, so Glue's workers can talk to each other; the subnet also needs a route to S3. A gateway VPC endpoint gives private, free access to S3 and DynamoDB. Interface VPC endpoints give private access to services such as Glue, Athena, Kinesis, STS and Secrets Manager, and their endpoint policies limit which resources can be reached through them.

On the S3 side, access points give each application its own endpoint and policy on a shared bucket, and the aws:SourceVpce condition in a bucket policy rejects requests that do not arrive through a specific endpoint. Redshift enhanced VPC routing forces COPY and UNLOAD traffic through the VPC, so these controls apply to it. The following table summarises the controls.

ControlPurpose
Private subnetsKeep databases and clusters off the internet
Self-referencing security group ruleRequired for Glue connections to VPC resources (plus routes to S3)
Gateway VPC endpointPrivate access to S3 and DynamoDB
Interface VPC endpointsPrivate access to Glue, Athena, Kinesis, STS, Secrets Manager and more; endpoint policies limit what is reachable
S3 Access PointsPer-application endpoint and policy on a shared bucket
aws:SourceVpce in bucket policiesRequire access through specific endpoints
Redshift enhanced VPC routingForce COPY and UNLOAD through the VPC
Match the pairs

Network controls

Exam skills 4.1.1 · 4.1.5

Match each requirement with the network control.

Log in to try this activity Interactive activities are free with an account.

Glue in a VPC

A Glue job that reads a database in a private subnet must run inside the VPC, which needs several pieces of configuration. A Glue connection specifies the VPC, subnet and security group in which the job's workers are placed. The security group needs a self-referencing inbound rule, allowing all traffic from the same security group, because Glue workers communicate with each other during a Spark job; without it, jobs fail to start.

Running in a private subnet also removes direct internet access, so the job needs other paths to the AWS services it uses. An S3 gateway endpoint, or a NAT gateway, lets it read its script and write results to Amazon S3, and interface endpoints are needed for any other AWS APIs the job calls, such as AWS Secrets Manager for database credentials.

The following diagram shows the network pieces the job needs.

The Glue job reaching a private database without internet access. The Glue connection places the job's workers in the database's VPC and subnet, with a security group that has a self-referencing inbound rule so workers can talk to each other. An S3 gateway endpoint in the route table lets the job read its script and write results, and an interface endpoint reaches Secrets Manager.
SG is the security group; the job reads its database secret through the interface endpoint.
Select all that apply

Glue in a private subnet

Exam skills 4.1.1 · 1.2.2

Identify what a Glue job needs to read a database in a private subnet.

Log in to try this activity Interactive activities are free with an account.

Restricting access by network

Policies can require that data is accessed only from expected networks. Bucket policies with aws:SourceVpce or aws:SourceVpc deny requests from anywhere else, and VPC endpoint policies with aws:ResourceOrgID stop workloads reaching buckets outside the organisation, which closes a common data exfiltration path.

Scenario questions

Stopping exfiltration

Exam skills 4.1.5 · 4.2.6

Choose the control that blocks each path.

Log in to try this activity Interactive activities are free with an account.
Worked example

A Glue job reaching a private database securely

A Glue job must read from a database in a private subnet without internet access. The following table identifies the design element that meets each requirement.

RequirementDesign
The database is in a private subnetGlue connection in the same VPC and subnet
Glue workers must talk to each otherSecurity group with a self-referencing inbound rule
Glue needs S3 without internet accessS3 gateway endpoint in the route table
Least privilegeJob role can read only the secret, the source bucket and the target prefix

Missing the self-referencing security group rule is the classic reason a VPC-connected Glue job fails to start, and missing the S3 endpoint the classic reason it hangs when writing results.

Check yourself

How can S3 traffic from a VPC stay off the internet?

Show answer

Through a gateway VPC endpoint for S3.

Exam Tips

Remember for the exam

  • When Glue cannot reach a database, check the security group's self-referencing rule, the subnet routes and the endpoints.
  • To keep S3 traffic off the internet, use a gateway VPC endpoint.
  • For per-application access to a shared bucket, use S3 Access Points.
  • To require access through your VPC, use aws:SourceVpce in bucket policies.
  • To force COPY and UNLOAD through the VPC, enable Redshift enhanced VPC routing.