Skip to content

END-TO-END-TLS Encryption

0

Hi AWS team,

I have 10 Python applications running as ECS services (Fargate) within the same ECS cluster. Currently, these services communicate with each other using HTTP, but I want to secure the inter-service communication with HTTPS.

Here are the key requirements and current setup details:

All applications are deployed in Amazon ECS (Fargate) and communicate internally using ECS Service Connect or service discovery.

I want all ECS-to-ECS communication to happen over HTTPS.

I plan to use AWS Private Certificate Authority (AWS PCA) to issue certificates.

No private key should be stored or used manually within the ECS tasks or images — the certificate should be managed automatically (for example, via ACM or Secrets Manager).

The current setup is provisioned using Terraform.

Each service currently exposes an HTTP endpoint (e.g., port 8080).

I need guidance on:

How to configure ECS services to use AWS PCA-issued certificates for HTTPS without managing private keys manually?

Is there a recommended AWS approach to automate certificate provisioning and rotation for such internal service-to-service HTTPS setups?

Can this be achieved entirely via Terraform (for example, integrating ACM, Secrets Manager, and ECS task definitions)?

Any architecture patterns, Terraform examples, or best practices would be very helpful.

Thanks!

2 Answers
0

For your ECS services that need secure inter-service communication, Amazon ECS Service Connect with TLS encryption is an excellent solution that meets your requirements.

Service Connect supports automatic traffic encryption using TLS certificates for Amazon ECS services. Here's how you can implement this:

  1. Use AWS Private CA with Service Connect:
  • Amazon ECS can automatically generate, rotate, and distribute TLS certificates for encrypting traffic between your services.
  • Service Connect supports AWS Private CA TLS certificates with 256-bit ECDSA and 2048-bit RSA encryption.
  • It uses TLS 1.3 by default for secure communications.
  1. Certificate Management Without Manual Handling:
  • When you enable Service Connect with TLS encryption, the service interacts with AWS Secrets Manager to store the private keys for TLS certificates.
  • You won't need to manually manage private keys within your ECS tasks or container images.
  • Service Connect handles certificate rotation automatically, especially if you use short-lived certificates (recommended for cost savings and security).
  1. Implementation Steps:
  • Create a subordinate CA in AWS Private Certificate Authority
  • Enable Service Connect for your ECS services
  • Configure TLS encryption for the Service Connect configuration
  • Ensure your services are configured to use the awsvpc network mode
  1. Terraform Implementation:
  • You can use Terraform to provision the AWS Private CA
  • Configure your ECS service definitions to enable Service Connect with TLS
  • Set up the necessary IAM permissions for ECS to interact with Secrets Manager and AWS Private CA

For your specific case with 10 Python applications, you'll need to:

  1. Update your application code to use HTTPS instead of HTTP for inter-service calls
  2. Configure Service Connect in your ECS task definitions to enable TLS
  3. Manage access to Secrets Manager appropriately to maintain security

This approach eliminates the need to manually handle certificates in your applications while providing secure, encrypted communication between your services.
Sources
Encrypt Amazon ECS Service Connect traffic - Amazon Elastic Container Service

answered a year ago

0

End-to-End TLS for ECS Fargate Inter-Service Communication

You can achieve secure HTTPS communication between ECS services without managing private keys manually by using Amazon ECS Service Connect with TLS integrated with AWS Private Certificate Authority (PCA). This approach provides automated certificate issuance and rotation while ensuring no private keys are stored or exposed within your Fargate tasks.

If you need mutual TLS or more advanced routing, AWS App Mesh is the next step up. It uses Envoy sidecars and ACM PCA–issued certificates to provide per-service mTLS, advanced routing, observability, and retries. For simpler one-way encryption, Service Connect TLS is the cleanest, managed path.

Recommended Approach

  1. Service Connect TLS + ACM PCA Service Connect supports end-to-end encryption for traffic between ECS services. Certificates are issued automatically by ACM PCA and managed by ECS, which eliminates manual handling of private keys. Terraform can provision both the PCA and the ECS service configuration, with the ECS provider supporting the TLS parameters.

  2. App Mesh with ACM PCA for mTLS For full mutual authentication, App Mesh allows you to configure Envoy proxies to use ACM PCA–issued certificates without your application containers handling key material. You’ll need to configure SDS (Secret Discovery Service) or a secrets management mechanism for certificate distribution, but the rotation and trust chain remain managed by AWS.

  3. ALB-Based Authentication Alternative You can also terminate TLS at internal Application Load Balancers using client certificate authentication via ACM PCA. This simplifies management but stops TLS at the ALB instead of true end-to-end encryption.

Terraform Pattern Overview

Below is a conceptual Terraform structure showing how to combine ACM PCA with ECS Service Connect for automated TLS:

Private Certificate Authority

resource "aws_acmpca_certificate_authority" "pca" { permanent_deletion_time_in_days = 7 certificate_authority_configuration { key_algorithm = "RSA_2048" signing_algorithm = "SHA256WITHECDSA" subject { common_name = "internal-pca" organization = "example" } } }

ECS Service with Service Connect TLS

resource "aws_ecs_service" "example" { name = "svc-a" cluster = aws_ecs_cluster.cluster.id task_definition = aws_ecs_task_definition.app.arn desired_count = 2

service_registries { registry_arn = aws_service_discovery_service.sd.arn }

Enable Service Connect TLS configuration here

depending on the Terraform provider version in use

}

The PCA resource can issue the signing authority used by ECS Service Connect. You’ll also create the IAM role that ECS uses to obtain and rotate certificates automatically.

Best Practices

Keep all TLS configuration managed through ECS or App Mesh so tasks never handle private keys directly.

Use least-privilege IAM roles for ECS and Service Connect TLS operations.

Start with a non-production namespace and test inter-service HTTPS to confirm health checks and service discovery behavior under TLS.

Enable CloudWatch metrics and VPC flow logs to confirm encrypted traffic patterns.

If adopting App Mesh, standardize Envoy configurations across all 10 services and automate deployment via your Terraform modules.

Practical Steps

Create an ACM PCA in Terraform and define the certificate hierarchy for internal service certificates.

Enable ECS Service Connect TLS in your ECS namespace and reference your PCA as the certificate authority.

Allow ECS to create or assume the IAM role required for certificate issuance and rotation.

Roll out TLS to one or two services first to validate compatibility before extending cluster-wide.

For complex topologies or mTLS requirements, consider migrating to App Mesh or implementing a gradual hybrid of both patterns.

Summary

Encryption-only traffic: ECS Service Connect TLS with ACM PCA.

Full mTLS or richer routing: AWS App Mesh with ACM PCA and Envoy proxies.

Simplified central termination: Internal ALB with client certificate authentication.

Each approach meets your “no manual key management” requirement, supports Terraform automation, and scales cleanly as your cluster grows.

If you’d like, I can outline a ready-to-run Terraform module that provisions the PCA, Service Connect TLS roles, and ECS services to implement this pattern end-to-end—or design a phased rollout plan to migrate your 10 services without downtime

answered a year ago

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.