Bird
Raised Fist0
AWScloud~10 mins

Data transfer cost awareness in AWS - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the provider configuration to specify the AWS region for the S3 bucket to reduce data transfer costs.

AWS
provider "aws" {
  region = "[1]"
}

resource "aws_s3_bucket" "example" {
  bucket = "my-bucket"
}
Drag options to blanks, or click blank then click option'
Aus-east-1
Bap-southeast-2
Ceu-west-1
Dsa-east-1
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a region far from your users increases data transfer costs.
Leaving the region unspecified can cause default region usage, which may be costly.
2fill in blank
medium

Complete the code to enable VPC endpoints to reduce data transfer costs between EC2 and S3.

AWS
resource "aws_vpc_endpoint" "s3_endpoint" {
  vpc_id            = aws_vpc.main.id
  service_name      = "com.amazonaws.[1].s3"
  vpc_endpoint_type = "Gateway"
}
Drag options to blanks, or click blank then click option'
Aus-west-2
Beu-west-1
Cap-northeast-1
Dus-east-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a service name region different from the VPC region causes errors.
Not using VPC endpoints causes data to route over the internet, increasing costs.
3fill in blank
hard

Fix the error in the security group rule to allow inbound traffic only from the same VPC to reduce data transfer costs.

AWS
resource "aws_security_group_rule" "allow_internal" {
  type              = "ingress"
  from_port         = 0
  to_port           = 65535
  protocol          = "tcp"
  cidr_blocks       = ["[1]"]
  security_group_id = aws_security_group.main.id
}
Drag options to blanks, or click blank then click option'
A10.0.0.0/16
B0.0.0.0/0
C192.168.1.0/24
D172.16.0.0/12
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0.0.0.0/0 opens access to the internet, increasing costs.
Using a CIDR block outside the VPC range causes connectivity issues.
4fill in blank
hard

Fill in the blank to configure an S3 bucket policy that allows access only from a specific VPC endpoint to reduce data transfer costs.

AWS
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
      "Condition": {
        "StringEquals": {
          "aws:sourceVpce": "[1]"
        }
      }
    }
  ]
}
Drag options to blanks, or click blank then click option'
Avpce-1234567890abcdef0
Bvpce-0987654321fedcba9
Cvpce-abcdef1234567890a
Dvpce-0a1b2c3d4e5f6g7h8
Attempts:
3 left
💡 Hint
Common Mistakes
Using an incorrect or non-existent VPC endpoint ID causes access denial.
Leaving the condition out allows public access, increasing costs.
5fill in blank
hard

Fill all three blanks to create a CloudWatch alarm that triggers when data transfer out exceeds a threshold, helping monitor and control costs.

AWS
resource "aws_cloudwatch_metric_alarm" "data_transfer_alarm" {
  alarm_name          = "HighDataTransferOut"
  comparison_operator = "[1]"
  evaluation_periods  = 1
  metric_name         = "NetworkOut"
  namespace           = "AWS/EC2"
  period              = 300
  statistic           = "[2]"
  threshold           = [3]
  alarm_description   = "Alarm when data transfer out exceeds threshold"
  actions_enabled     = true
}
Drag options to blanks, or click blank then click option'
AGreaterThanThreshold
BAverage
C1000000000
DLessThanThreshold
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'LessThanThreshold' triggers alarm on low usage, not high.
Setting threshold too low causes false alarms.

Practice

(1/5)
1. Which type of AWS data transfer is usually free of charge?
easy
A. Data transfer between instances in the same Availability Zone using private IPs
B. Data transfer from AWS to the internet
C. Data transfer between different AWS regions
D. Data transfer from the internet to AWS

Solution

  1. Step 1: Understand AWS data transfer zones

    Data transfer within the same Availability Zone using private IPs is typically free because it stays inside the same physical location.
  2. Step 2: Compare with other transfer types

    Transfers to the internet or between regions usually incur costs due to crossing physical or network boundaries.
  3. Final Answer:

    Data transfer between instances in the same Availability Zone using private IPs -> Option A
  4. Quick Check:

    Same AZ private IP transfer = free [OK]
Hint: Same AZ private IP transfers are free, others usually cost [OK]
Common Mistakes:
  • Thinking all data transfers inside AWS are free
  • Confusing region transfer with same zone transfer
  • Assuming internet transfers are free
2. Which AWS data transfer direction is correctly paired with its typical cost behavior?
easy
A. Data transfer between different AWS regions - free
B. Data transfer from AWS to the internet - charged
C. Data transfer within the same Availability Zone using public IP - free
D. Data transfer from the internet to AWS - charged

Solution

  1. Step 1: Review common AWS data transfer costs

    Data transfer from AWS to the internet is usually charged because it leaves AWS's network.
  2. Step 2: Check other options for correctness

    Transfers between regions are charged, same AZ public IP transfers are charged, and internet to AWS transfers are usually free.
  3. Final Answer:

    Data transfer from AWS to the internet - charged -> Option B
  4. Quick Check:

    AWS to internet = charged [OK]
Hint: AWS to internet data transfer usually costs money [OK]
Common Mistakes:
  • Assuming cross-region transfer is free
  • Confusing public and private IP transfer costs
  • Thinking inbound internet data is charged
3. Consider this AWS setup: An EC2 instance in us-east-1 sends 10 GB of data to an EC2 instance in us-west-2. Which cost applies?
medium
A. Only storage cost applies, no data transfer cost
B. No charge because both are EC2 instances
C. Free data transfer within the same AWS account
D. Data transfer charge for cross-region transfer applies

Solution

  1. Step 1: Identify the data transfer type

    Data moves between two different AWS regions (us-east-1 to us-west-2), which is cross-region transfer.
  2. Step 2: Understand cost implications

    Cross-region data transfer is charged by AWS because data crosses physical boundaries and networks.
  3. Final Answer:

    Data transfer charge for cross-region transfer applies -> Option D
  4. Quick Check:

    Cross-region transfer = charged [OK]
Hint: Cross-region data transfer always costs money [OK]
Common Mistakes:
  • Assuming all EC2 to EC2 transfers are free
  • Ignoring region boundaries
  • Confusing storage and transfer costs
4. You notice unexpectedly high AWS bills. You find data transfer between two EC2 instances in the same region but different Availability Zones. What is the likely cause?
medium
A. Data transfer inside the same instance is charged
B. Data transfer within the same AZ is charged
C. Data transfer between AZs in the same region is charged
D. Data transfer to the internet is free

Solution

  1. Step 1: Identify the data transfer path

    Data moves between two Availability Zones in the same region, which is cross-AZ transfer.
  2. Step 2: Check AWS cost rules for cross-AZ transfer

    AWS charges for data transfer between AZs even within the same region, causing higher bills.
  3. Final Answer:

    Data transfer between AZs in the same region is charged -> Option C
  4. Quick Check:

    Cross-AZ transfer = charged [OK]
Hint: Cross-AZ data transfer costs money, same AZ private IP does not [OK]
Common Mistakes:
  • Assuming same region means free transfer
  • Confusing AZ and instance boundaries
  • Thinking internet transfer is free
5. You design an application with EC2 instances in two regions: us-east-1 and eu-central-1. The app frequently transfers 50 GB daily between these regions. How can you reduce data transfer costs?
hard
A. Use S3 buckets in each region and replicate data asynchronously
B. Move all instances to the same Availability Zone
C. Transfer data via the public internet to avoid AWS charges
D. Use AWS Direct Connect to create a dedicated network link between regions

Solution

  1. Step 1: Understand cross-region transfer costs

    Frequent large data transfers between regions incur high costs.
  2. Step 2: Evaluate cost-saving strategies

    Using S3 replication asynchronously reduces direct cross-region transfer costs by syncing data efficiently.
  3. Step 3: Analyze other options

    AWS Direct Connect is for on-premises to AWS, not cross-region; moving instances to same AZ is impossible across regions; public internet transfer still incurs costs and latency.
  4. Final Answer:

    Use S3 buckets in each region and replicate data asynchronously -> Option A
  5. Quick Check:

    Async S3 replication reduces cross-region transfer costs [OK]
Hint: Use S3 replication to cut cross-region transfer costs [OK]
Common Mistakes:
  • Thinking Direct Connect works cross-region
  • Assuming public internet transfer is cheaper
  • Trying to put instances in same AZ across regions
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard