swiftlang / swiftlang/docs

Swift Server Guide - Accessing AWS RDS from Locally Running Docker Compose Instances

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

content migration
Dominant language
Python
Stars
28
Forks
5
Avg merge
18h 33m
Merged PRs (30d)
18

Description

Outline 3. Accessing AWS RDS from Locally Running Docker Compose Instances

Accessing AWS RDS from Locally Running Docker Compose Instances

In this chapter, we demonstrate how to access your previously created PostgreSQL RDS service on AWS from your locally running Swift web service using the aws-hummingbird-docker-compose.yaml file. We will configure the Docker Compose file to use the real AWS PostgreSQL endpoint, verify the SSL connection using the eu-central-1-bundle.pem (compiled into the hummingbird-todos image), and test the running service with curl commands similar to those in Chapter 1.


Table of Contents


Overview

  • Replace the Placeholder: Update the <aws_database_endpoint_here> in the Docker Compose file with your AWS PostgreSQL RDS public endpoint.
  • Region & SSL Verification: We are working in the eu-central-1 (Frankfurt) region. The eu-central-1-bundle.pem is used to verify the SSL connection to RDS.
  • Build & Run: Build and run the configuration using a single Docker image (hummingbird-todos).
  • Testing: Validate the setup with curl commands.
  • Next Steps: In the upcoming chapter, we will create a VPN connection to the AWS VPC for a more secure access to the RDS instance.

1. Configure the Docker Compose File

Open the aws-hummingbird-docker-compose.yaml file and locate the following environment variable configuration:

services:
  hummingbird-todos:
	  platform: linux/amd64
    build:
      context: .
      dockerfile: hummingbird-docker/Dockerfile
    ports:
      - "8080:8080"
    environment:
      DATABASE_HOST: <aws_database_endpoint_here>
      DATABASE_PORT: 5432
      DATABASE_USER: postgres
      DATABASE_PASSWORD: postgres
      DATABASE_NAME: postgres
      ROOT_CERT_PATH: eu-central-1-bundle.pem
    command: ["--hostname", "0.0.0.0", "--port", "8080"]

Replace <aws_database_endpoint_here> with the actual public endpoint of your AWS PostgreSQL RDS instance. For example, if your endpoint is mydbinstance.abc123def456.eu-central-1.rds.amazonaws.com, update the file accordingly.

2. Build and Run the Docker Compose Setup

Since this setup uses a single Docker image (hummingbird-todos), build the image with:

docker compose -f aws-hummingbird-docker-compose.yaml build

Then, start the container using:

docker compose -f aws-hummingbird-docker-compose.yaml up

This will launch the web service on port 8080 with the proper configuration for connecting to the AWS-hosted PostgreSQL RDS.

3. Test the Web Service

After starting the container, verify that the service is running correctly by using the following curl commands:

Create a Todo
curl -X POST http://localhost:8080/todos \
  -H "Content-Type: application/json" \
  -d '{"title": "Complete AWS integration", "order": 1}'
List All Todos
curl -X GET http://localhost:8080/todos

These tests confirm that the web service is operational and correctly interacting with your AWS RDS instance over a secure SSL connection.

Next Chapter Preview

In the next chapter, we will create a VPN connection to your AWS VPC. This will allow you to access the RDS instance in a more secure way by restricting access to authorized networks only, thereby enhancing the overall security of your application.


Enjoy accessing your AWS RDS service from your locally running Docker Compose instances, and get ready for even more secure connectivity in the upcoming chapter!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the proposed chapter text alongside aws-hummingbird-docker-compose.yaml and the referenced Dockerfile and certificate. Start by checking that the Docker Compose environment, build and run commands, and curl examples match the documented Swift service. Done means the guide accurately explains local Docker Compose access to AWS PostgreSQL RDS and its SSL verification.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker-compose, postgresql, swift
Domain
cloud, databases, devops, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.