Blog
AWS
Cloud
Business
DevSecOps
6
minutes

Best Practices for Container Security on AWS

Containers are superior to Virtual Machines (VM) in many aspects, including the benefits of being lightweight, easily scalable, highly portable, etc. AWS provides two primary container services i.e., Amazon Elastic Container Service (Amazon ECS) and Amazon Elastic Kubernetes Service (EKS). Although both ECS and EKS are growing in popularity but achieving security while using these services is relatively a new topic.
Morgan Perry
Co-founder
Summary
Twitter icon
linkedin icon

This article will provide some tips to achieve security in a containerized environment, especially in Amazon ECS. Here are the section-wise tips :

IAM Management

  • Follow the policy of least privileged access
    Consider a scenario where a developer needs to stop a task periodically. You should create a policy that only permits that particular action. Always go for resource-level permissions (Amazon Resource Name (ARN)) when possible
  • The cluster should serve as an administrative boundary
    Create roles that are scoped to clusters and use the cluster as your primary administrative boundary.
  • Create Pipelines
    Creating pipelines to automate package and deploy applications onto Amazon ECS clusters will reduce the admin overhead and isolate end-users from Amazon ECS API.
  • Use two-factor authentication for important actions
    Suppose you are performing a critical operation like deleting a cluster. In that case, you can add an extra layer of security by creating a policy that enforces 2FA when you are performing a critical action. As mentioned above, the policy should specify the resources it is scoped for.
  • ECS tasks should be assigned roles
    Assigning each task a role aligns with the principle of least privileged access and allows for greater granular control over actions and resources.
    Note that the role assigned to an EC2 instance on which the task is running is different than the role of the task itself (more info here).

Network/Runtime Security

  • Expose only the ports that serve the application
    Do not expose any other ports, except for SSH. Apply this principle to containers as well as the underlying machines. Implement whitelisting of IP’s/security groups where possible
  • Create separate virtual networks for your containers
    This will add a level of isolation that can reduce the attack surface.
  • Use TLS to secure communication between services
    Try to use TLS 1.3 to secure communication between services. TLS 1.2 will be deprecated soon. This process encrypts traffic and makes sure only authorized endpoints are allowed.
  • Make as much use of VPCs, Security groups, network rules, firewall rules, etc. as you can to restrict communication between VMs, VPCs, and the Internet.

Secrets Management

  • Consider using AWS Systems Manager Parameter Store.
    Parameter store is a secure, encrypted repository for configuration data management and secrets management. Do not save secrets in any file or code.
  • Keep an eye on API keys and access/secret keys
    Keep a close eye on unsafe API keys, secrets, etc. Remove any unused keys and try to rotate keys if possible.
  • Use tools for secrets scanning
    Some tools look for leaked credentials and other sensitive secrets in the container image. One of the examples is "gitLeaks", which is an open-source static analysis command-line tool used to detect hard-coded secrets like passwords, API keys, and tokens in local and GitHub repositories (private and public).

HIPAA / PCI Compliance

For PCI Compliance, follow the below tips:

  • First, understand the flow of cardholder data (CHD) within the environment. The CHD flow will determine the applicability of the PCI DSS and will define the boundaries and components of a cardholder data environment.
  • Avoid saving the full card number in your database. If needed, save only the last four digits.
  • Web application penetration tests must include all vulnerabilities (SQLi, XSS, CSRF, etc.)

For HIPAA compliance, follow the below tips:

  • PHI data should be encrypted in transit and at-rest when accessed by containers launched with Amazon ECS.
  • Complete logging should also be enabled and all container logs should be directed to Amazon CloudWatch.
  • You may deploy an overlay network (e.g., VNS3 or Weave Net) to ensure complete encryption of PHI data transferred between containers or provide a redundant encryption layer.

Host & Container security

  • Use a trusted repository of known good code.
    Pulling anything directly from the internet (e.g. Docker Hub) may introduce security risks. AWS ECR is a good option as a secure image repository
  • Sign and Verify Docker Images.
    Signatures help track images to the people who signed them. This makes it difficult to substitute the signed image for a compromised one.
  • Do not include sensitive data in Docker images
    Use some secrets manager to save the secrets securely. In a local development environment, you can use ENV files, and in a production environment, you should use a managed service like AWS parameter store or secrets manager.
  • Secure both host and container
    The hosts that run the container management system should be as secure as the container itself. Assess the security of all components, scan vulnerabilities regularly, monitor threats and keep the system up to date.

Log & Monitoring

  • Ensure that audit logs are enabled and should be monitored for abnormal or unwanted actions, particularly for any authorization failures
  • You can use DataDog for monitoring your containers. You can install the Datadog agent on every EC2 instance in your ECS cluster. Datadog’s Autodiscovery can be used in conjunction with ECS and Docker to automatically discover and monitor running tasks in your environment.
  • Use Cloudwatch alarms in combination with SNS to receive alerts on important metrics e.g. network traffic, abnormal CPU spikes etc.
  • Use AWS Fluent Bit image for container logging. This image provides the capability to route logs to Amazon CloudWatch with SNS as a destination. This image is available on ECR public image gallery (more info here)

Miscellaneous tips for container security

  • Make code scanning part of the CI/CD process
  • Keep an eye on external vulnerabilities through dependency scanning
  • Use image scanning to analyze container images. You can use ECR built-in image scanning feature too
  • If you are using CloudFormation or Terraform, Use IaC scanning tools to validate the configuration of your infrastructure before it is created or updated.
  • If you are making direct HTTPS API requests to AWS, you should sign those requests with temporary security credentials that you get from the AWS Security Token Service

Conclusion

Managing security in the containerized environment is not easy. In this article, we have shared crucial security tips which will help you secure your ECS clusters to a great extent. However, applying these security measures will need skilled resources having expertise in standard application security and containerized environment.

A Modern solution like Qovery can help you set up and manage containers with the desired level of security needs. If you are a startup with growing containerization needs but do not have the required expertise to manage ECS with the above security measures, then Qovery is the right fit for you.

Share on :
Twitter icon
linkedin icon
Tired of fighting your Kubernetes platform?
Qovery provides a unified Kubernetes control plane for cluster provisioning, security, and deployments - giving you an enterprise-grade platform without the DIY overhead.
See it in action

Suggested articles

Kubernetes
 minutes
Kubernetes management: Best practices for enterprise ccaling and cost optimization

Master enterprise Kubernetes management in 2026. Learn best practices for security, FinOps, and reliability, and see how AI-agentic platforms simplify operations.

Mélanie Dallé
Senior Marketing Manager
Kubernetes
Platform Engineering
Infrastructure Management
 minutes
The top 3 OpenShift pains in 2026 (and how platform teams respond)

Is OpenShift becoming too expensive or complex for your team? Discover the top 3 OpenShift pain points; from the "pricing inversion" to vendor lock-in and see why agile platform teams are migrating to modular, developer-first alternatives like Qovery.

Mélanie Dallé
Senior Marketing Manager
AI
Qovery
3
 minutes
How Qovery uses Qovery to speed up its AI project

Discover how Qovery leverages its own platform to accelerate AI development. Learn how an AI specialist deployed a complex stack; including LLMs, QDrant, and KEDA - in just one day without needing deep DevOps or Kubernetes expertise. See how the "dogfooding" approach fuels innovation for our DevOps Copilot.

Romain Gérard
Staff Software Engineer
Product
4
 minutes
Scale What Matters, Not Just CPU - Welcome Keda autoscaling

Not every workload should scale on CPU. Qovery brings event-driven autoscaling into the application lifecycle, letting applications scale on real signals like queue depth or request latency.

Alessandro Carrano
Head of Product
DevOps
Kubernetes
Platform Engineering
15
 minutes
10 Red-Hat OpenShift Alternatives to Reduce Cost and Complexity in 2026

Fed up with OpenShift? Compare the top 10 enterprise alternatives. Discover how modern Kubernetes management platforms like Qovery reduce TCO, simplify Day 2 Ops, and scale AI workloads.

Morgan Perry
Co-founder
Kubernetes
DevOps
9
 minutes
Top 10 Rancher alternatives in 2026: Beyond cluster management

Looking for Rancher alternatives? Compare the top 10 Kubernetes Management Platforms for 2026. From Qovery to OpenShift, find the best tool to scale multi-cluster operations and reduce TCO.

Morgan Perry
Co-founder
Internal Developer Platform
DevOps
 minutes
PaaS vs. DIY IDP: The Fastest Path to a Self-Service Cloud

Building an Internal Developer Platform (IDP) from scratch seems cheaper, but the maintenance costs add up. Discover why a modern PaaS on your own infrastructure is the faster, smarter path to a self-service cloud.

Mélanie Dallé
Senior Marketing Manager
Heroku
15
 minutes
Top 10 Heroku Alternatives in 2026: When Simplicity Hits the Scaling Wall

Escape rising Heroku costs & outages. Compare top alternatives that deliver PaaS simplicity on your own cloud and scale without limits.

Mélanie Dallé
Senior Marketing Manager

It’s time to change
the way you manage K8s

Turn Kubernetes into your strategic advantage with Qovery, automating the heavy lifting while you stay in control.