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
Ready to rethink the way you do DevOps?
Qovery is a DevOps automation platform that enables organizations to deliver faster and focus on creating great products.
Book a demo

Suggested articles

Kubernetes
DevOps
 minutes
Best CI/CD tools for Kubernetes: Streamlining the cluster

Static delivery pipelines are becoming a bottleneck. The best CI/CD tools for Kubernetes are those that move beyond simple code builds to provide total environment orchestration and developer self-service.

Mélanie Dallé
Senior Marketing Manager
DevOps
Cloud
 minutes
Top 10 vSphere alternatives for modern hybrid cloud orchestration

The Broadcom acquisition of VMware has sent shockwaves through the enterprise world, with many organizations facing license cost increases of 2x to 5x. If you are looking to escape rising TCO and rigid subscription bundles, these are the top vSphere alternatives for a modern hybrid cloud.

Mélanie Dallé
Senior Marketing Manager
DevOps
Heroku
 minutes
Top 10 Heroku Postgres competitors for production databases

Escape rising Heroku costs and rigid limitations. Discover the best Heroku Postgres competitors that offer high availability, global scaling, and the flexibility to deploy on your own terms.

Mélanie Dallé
Senior Marketing Manager
DevOps
Kubernetes
Heroku
 minutes
Top 10 GitLab alternatives for DevOps teams

Is GitLab bloat slowing down your engineering team? Compare the top 10 GitLab alternatives for, from GitHub to lightweight automation platforms like Qovery. Escape the monolith and reclaim your velocity.

Mélanie Dallé
Senior Marketing Manager
DevOps
Kubernetes
Heroku
 minutes
Heroku vs. Kubernetes: A comprehensive comparison

Is the "Heroku Tax" draining your budget? Compare Heroku vs. Kubernetes in 2026. Learn how to solve complex orchestration challenges, like queue-based autoscaling and microservice sprawl, without the DevOps toil.

Mélanie Dallé
Senior Marketing Manager
DevOps
Kubernetes
 minutes
The complete guide to migrating from EKS to ECS

Is the EKS operational burden outweighing its benefits? Learn how to migrate from EKS to ECS, the technical trade-offs of AWS-native orchestration, and how to get ECS-level simplicity without losing Kubernetes power.

Mélanie Dallé
Senior Marketing Manager
Kubernetes
DevOps
Platform Engineering
6
 minutes
Kubernetes vs. Docker: Escaping the complexity trap

Is the "Kubernetes Tax" killing your team’s velocity? Compare Docker vs. Kubernetes in 2026 and discover how to get production-grade orchestration with the "Git Push" simplicity of Docker, without the operational toil.

Morgan Perry
Co-founder
DevSecOps
 minutes
Inside Qovery’s security architecture: how we secure your cloud & Kubernetes infrastructure

Discover how Qovery bridges the gap between developers and infrastructure with a "security by design" approach. From federated identities and unique encryption keys to real-time audit logs and SOC2 Type 2 certification - see how we protect your data while eliminating vendor lock-in.

Kevin Pochat
Security & Compliance Engineer

It’s time to rethink
the way you do DevOps

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