Cloud Security: IAM, Network Isolation, and Encryption
An AWS-focused guide to identity, network isolation, encryption, and monitoring, with limited mappings to comparable Azure and Google Cloud control areas.
Cloud security combines identity, network isolation, encryption, and monitoring so a mistaken permission does not expose every workload. This guide uses AWS examples to explain IAM roles, VPC endpoints, KMS keys, security groups, CloudTrail, GuardDuty, and common failure patterns. It helps teams choose controls they can operate and check where configuration or monitoring still leaves gaps.
Cloud Security: IAM, Network Isolation, and Encryption
Introduction
Cloud services do not remove the need for careful access and network design. A workload with an overbroad role can read data it never needs, while a private subnet can still allow risky outbound traffic or reach a sensitive service through a loose endpoint policy.
The worked path in this guide is AWS-specific. Start by identifying the assets, threats, and failure impact for your workload; assign an owner to each control; then define what evidence will show the control is configured and working. AWS services can help implement or observe controls, but enabling a service alone does not establish that a system is secure. The comparison below names broad control areas in other clouds only where the function is comparable; the products do not have identical features or policies.
When to Use
Cloud-Native Security Services vs. Third-Party
Cloud-native security tools like Security Hub, GuardDuty, and CloudTrail on AWS integrate tightly with the provider’s control plane. Findings surface in the same console where you manage everything else. CloudTrail Event history records management events, while trails and event data stores need explicit selectors for data events such as S3 object access. The upside is simplicity: enable a service, get findings, done. Security Hub CSPM is centered on AWS resources and can ingest findings from supported integrations. Connector coverage and supported asset types change, so verify the current service documentation before treating it as a cross-cloud inventory; a broader CSPM may provide a more unified view.
Third-party CSPM platforms can bring findings and resource inventory from multiple cloud providers, and sometimes on-premises systems, into one dashboard. Connector coverage varies by product, so check whether it includes the accounts and services you use. A unified view may help with cross-provider investigations and compliance reporting. The trade-off is added integration work and another vendor relationship. Teams may also keep provider-native tools for detection and response features that the aggregator does not provide.
The detection coverage difference is where the separation gets real. GuardDuty uses machine learning trained on AWS-specific attack patterns. It catches things like unusual S3 access from an unusual location, brute force attempts on SSH, or cryptocurrency mining behavior in EC2. Third-party CSPMs use rules-based detection that works across providers but may miss AWS-specific signals that GuardDuty catches because the aggregation logic does not replicate the provider-native detection engine. Many organizations run both: GuardDuty for AWS-specific threats, the CSPM for cross-provider visibility and compliance reporting.
For a single-cloud workload, provider tools may cover the findings and records your team needs when configured for the relevant accounts, regions, and event types. A third-party CSPM may still help with inventory, workflows, or reporting, but its license and integration cost should match a concrete need. In a multi-cloud setup, compare the provider consoles and supported connectors, then decide whether a unified view improves a workflow your team actually uses.
A layered approach can work well: provider tools handle native detection, a CSPM brings together supported findings, and a SIEM or SOAR tool supports centralized investigation and response. Each adds setup and operating costs. Compare current service pricing and CSPM licensing against the coverage your team needs before adding another tool.
| Factor | Cloud-Native | Third-Party CSPM |
|---|---|---|
| Detection depth | AWS-specific ML models, high accuracy on AWS threats | Rules-based, cross-provider, may miss provider-specific signals |
| Operational overhead | Low (enable per-service, native console) | High (integration setup, vendor management, ongoing config) |
| Multi-cloud support | Single provider only | Unified view across all providers |
| Cost model | Per-consume or per-asset | Per-asset, scales expensively |
| Compliance reporting | Per-provider | Cross-provider, aggregated |
| Best for | Single-cloud, AWS-focused environments | Multi-cloud, complex hybrid environments |
In practice, start with cloud-native detection in each provider. Add a third-party aggregator when the overhead of checking multiple consoles becomes a real burden, and use a SIEM or SOAR tool if your response process needs centralized analysis or automation.
Cloud service names are not one-to-one
| Control area | AWS example | Microsoft Azure example | Google Cloud example |
|---|---|---|---|
| Identity and resource authorization | IAM | Azure RBAC | Cloud IAM |
| Private virtual networking | VPC | Virtual Network | VPC network |
| Key management | KMS | Key Vault Keys | Cloud KMS |
| Application secret management | Secrets Manager | Key Vault Secrets | Secret Manager |
Treat these as starting points for finding the relevant control area, not as equivalent products. Scope, policy evaluation, network behavior, audit events, and pricing differ. Check the current provider documentation for the exact service and region you use.
VPC Endpoints vs. NAT Gateway
The difference between VPC endpoints and NAT gateways comes down to what traffic you need and where it goes. Gateway endpoints route traffic from your VPC to S3 or DynamoDB without a NAT gateway; interface endpoints use AWS PrivateLink for supported services. Gateway endpoints have no hourly charge, while interface endpoints and NAT gateways have separate hourly and data-processing charges. NAT gateways provide internet egress from private subnets.
For private subnets that only need S3 or DynamoDB, gateway endpoints avoid NAT data-processing fees. A common production setup uses private subnets for application servers, an outbound route such as a NAT gateway for package downloads or external APIs, and gateway endpoints for S3 and DynamoDB. If S3 traffic uses a NAT gateway, it adds NAT processing charges.
VPC endpoints do not provide general internet access. Gateway endpoints cover S3 and DynamoDB, while interface endpoints can reach supported AWS services, partner services, and privately published services in other accounts. For arbitrary public destinations such as package registries and third-party APIs, private instances still need an outbound route such as a NAT gateway or proxy. Some teams use endpoints alongside NAT gateways, with explicit routes for each destination.
For S3, a gateway endpoint adds routes for S3 prefix lists so matching traffic uses the AWS network without a NAT gateway. Without that endpoint, private-subnet traffic typically uses its configured outbound route, such as a NAT gateway. Endpoint type and regional pricing affect the cost, so compare them with your traffic volume and deployment needs.
The security angle matters for production workloads. VPC endpoints can have endpoint policies that restrict access to specific buckets or actions. A misconfigured application that tries to list all S3 buckets gets denied by the endpoint policy even if the IAM role allows s3:* on all resources. This adds a service-access boundary: IAM says what the role can do, while the endpoint policy restricts what can pass through that endpoint. Without the endpoint policy, IAM and resource policies are the main authorization controls for those requests.
VPC endpoints cannot replace an outbound route for every destination. Patching from public repositories, downloading packages from public registries, calling third-party APIs, and fetching vendor software all require internet egress or another configured path, such as a proxy. A NAT gateway is one common way to provide that egress from private subnets.
Teams that route S3 traffic through NAT gateways can accumulate data-processing fees. For S3 and DynamoDB, gateway endpoints avoid those NAT processing charges; check regional pricing for any other endpoint types in use.
Route table priority is where teams get confused. VPC endpoint traffic uses the VPC route table local prefix, which takes precedence over 0.0.0.0/0 NAT routes. This means adding a VPC endpoint does not automatically route all S3 traffic through it. Only traffic destined for the specific S3 prefix lists uses the endpoint route. The confusion comes from assuming VPC endpoints work like NAT for all destinations. When you add a VPC endpoint, you are adding a specific route for S3 prefix lists, not a catch-all redirect.
| Factor | VPC Endpoints | NAT Gateway |
|---|---|---|
| Cost | Gateway: no hourly charge; interface: billed by endpoint and data | Hourly and data-processing charges |
| Latency | Private routing to supported AWS services | Outbound route through NAT gateway |
| Security | Endpoint policies restrict access to specific buckets/actions | No endpoint policy, relies on IAM only |
| Use case | Supported AWS and private services (including S3 and DynamoDB) | General outbound internet (patching, public APIs, registries) |
| Route priority | Local prefix takes precedence over 0.0.0.0/0 | 0.0.0.0/0 catches all unmatched traffic |
| Best for | Private subnets accessing AWS services | Private subnets needing internet access |
Customer-Managed KMS Keys vs. Cloud-Managed Keys
Customer-managed KMS keys have a monthly key fee and usage charges; check current AWS KMS pricing before estimating cost. You control key policies, rotation settings, and lifecycle. See AWS KMS pricing and the key-management guide. Cross-account access needs authorization on both sides: the key policy in the owning account and an IAM policy for the caller. CloudTrail can record key-use events for review.
AWS-managed keys have no monthly key fee, though API usage may be charged. AWS manages their policies and rotates them automatically each year. You can inspect their metadata and use in CloudTrail, but you cannot change their policy, rotation, or lifecycle. They may fit workloads that do not need direct key control or cross-account use; check the AWS key documentation for service-specific limits.
Deleting a customer-managed key can make data encrypted under it permanently inaccessible after the deletion process completes. AWS KMS requires a waiting period that can be configured from 7 to 30 days. Before scheduling deletion, identify dependent data and services, assign an approver, and verify the recovery and retention requirements for that key. Follow the current AWS KMS key deletion guidance; do not assume every provider uses the same lifecycle.
IAM Best Practices
Identity and Access Management (IAM) is the foundation of cloud security. Every request to a cloud API requires authentication and authorization. IAM policies determine what identities can do what operations on which resources.
The cardinal rule is least privilege: grant only the permissions required for a task, and nothing more. This applies to human users, service accounts, and compute workloads.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3ReadOnlyForApplication",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": ["arn:aws:s3:::my-app-bucket", "arn:aws:s3:::my-app-bucket/*"]
}
]
}
For workforce access, prefer federation through an identity provider or IAM Identity Center with permission sets. Use IAM roles for workloads and grant them only the actions they need. If a legacy workflow still requires IAM users, groups can make those permissions easier to manage, but they do not replace federation or narrow policies.
# Demo only; scope the policy before using this pattern in production.
aws iam create-group --group-name developers
# Attach a policy to the group
aws iam attach-group-policy \
--group-name developers \
--policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
# Add a user to the group
aws iam add-user-to-group \
--group-name developers \
--user-name alice
Regularly audit IAM configurations. AWS Access Analyzer, Microsoft Entra external identities, and Google Cloud Policy Analyzer can help identify external access or overly broad permissions. Remove unused access keys, deactivate old credentials, and rotate secrets on a schedule.
Service Accounts and Workload Identity
Human users are not the only identities in cloud environments. Compute workloads—EC2 instances, containers, Lambda functions—need permissions to access other AWS services. The question is how those workloads authenticate.
Storing long-lived access keys in code or environment variables is risky. EC2 instance profiles provide temporary role credentials; workloads should use those credentials through the SDK instead of storing static keys. Credentials exposed in logs or environment variables can still be stolen and misused.
Workload identity is the solution. Instead of storing credentials, workloads assume a role using short-lived tokens. The role permissions are scoped to what the workload actually needs.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
On EKS, use IAM Roles for Service Accounts (IRSA) or EKS Pod Identity to give a workload short-lived AWS credentials tied to its Kubernetes service account. Keep Kubernetes API permissions separate: create an RBAC Role and RoleBinding only when the application needs to call the Kubernetes API, and grant the minimum verbs and resources. Restrict pod access to the node’s instance metadata role so a workload cannot inherit broader credentials.
# IRSA example: associate this service account with a narrowly scoped IAM role
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-app
namespace: production
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/my-app-role
VPC and Network Isolation
Network isolation in cloud environments uses virtual private clouds (VPCs) with subnet segmentation. The principle is straightforward: nothing should be directly accessible from the internet unless intentionally exposed.
# VPC with public and private subnets
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
}
# Public subnets for load balancers
resource "aws_subnet" "public" {
count = 2
vpc_id = aws_vpc.main.id
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index)
availability_zone = data.aws_availability_zones.available.names[count.index]
map_public_ip_on_launch = true
tags = {
Type = "Public"
}
}
# Private subnets for application servers
resource "aws_subnet" "private" {
count = 2
vpc_id = aws_vpc.main.id
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 10)
availability_zone = data.aws_availability_zones.available.names[count.index]
tags = {
Type = "Private"
}
}
# NAT gateway for outbound traffic from private subnets
resource "aws_eip" "nat" {
domain = "vpc"
}
resource "aws_nat_gateway" "main" {
allocation_id = aws_eip.nat.id
subnet_id = aws_subnet.public[0].id
}
resource "aws_route_table" "private" {
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.main.id
}
}
Application servers sit in private subnets and cannot be reached directly from the internet. Load balancers in public subnets route traffic to application servers. Database and cache servers sit in private subnets with no direct internet route; give them only the egress paths their dependencies require.
Security groups filter traffic for associated resources and are stateful: responses to permitted inbound connections are allowed automatically.
# Security group for public load balancers
resource "aws_security_group" "load_balancer" {
name = "load-balancer"
description = "Security group for public load balancers"
vpc_id = aws_vpc.main.id
# Allow public HTTP and HTTPS; redirect HTTP to HTTPS at the load balancer
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# Forward HTTP only to application servers in the private subnets
egress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = aws_subnet.private[*].cidr_block
}
}
# Security group for web servers
resource "aws_security_group" "web" {
name = "web-servers"
description = "Security group for web servers"
vpc_id = aws_vpc.main.id
# Allow inbound HTTP from the load balancer security group
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
security_groups = [aws_security_group.load_balancer.id]
}
# Allow outbound to internet via NAT
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
Encryption at Rest and in Transit
Encrypt data wherever it lives. Many cloud services encrypt stored data by default, but the key type and controls vary by service. For example, Amazon S3 applies SSE-S3 to new objects by default; use explicit configuration when you need SSE-KMS or customer-managed key control.
# S3 bucket with customer-managed KMS encryption
resource "aws_s3_bucket" "data" {
bucket = "my-sensitive-data"
}
resource "aws_s3_bucket_server_side_encryption_configuration" "data" {
bucket = aws_s3_bucket.data.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
kms_master_key_id = aws_kms_key.data.arn
}
}
}
# KMS key with restricted usage
resource "aws_kms_key" "data" {
description = "KMS key for sensitive data"
deletion_window_in_days = 30
enable_key_rotation = true
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "Enable IAM User Permissions"
Effect = "Allow"
Principal = {
AWS = "arn:aws:iam::123456789012:root"
}
Action = "kms:*"
Resource = "*"
},
{
Sid = "Allow use by application"
Effect = "Allow"
Principal = {
AWS = "arn:aws:iam::123456789012:role/my-app-role"
}
Action = ["kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKey"]
Resource = "*"
}
]
})
}
TLS encrypts data in transit. Force HTTPS on all public endpoints. Use TLS for connections between services, especially when they cross network boundaries. Certificate management can be automated with services like AWS Certificate Manager or Let’s Encrypt.
Security Groups and Firewall Rules
Security groups should be as restrictive as possible. Start with deny all inbound, allow specific ports and sources.
# Database security group - minimal access
resource "aws_security_group" "database" {
name = "database"
description = "Security group for RDS instance"
vpc_id = aws_vpc.main.id
# Accept PostgreSQL only from the application tier
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
security_groups = [aws_security_group.web.id]
}
# Review the provider's default egress rule and restrict it as needed.
}
Network ACLs provide subnet-level filtering as a secondary control. Security groups handle instance-level filtering. Use both together: NACLs for subnet-wide rules like blocking a specific IP range, security groups for instance-specific access control.
VPC endpoint policies restrict which actions are allowed through an endpoint. Without an endpoint, traffic follows the VPC’s configured route to the service, often through a NAT gateway for private subnets. An endpoint can keep service traffic on the AWS network and add a policy boundary.
Cloud-Native Security Services
Each major cloud provider offers security services that layer on top of basic IAM and networking.
AWS Security Hub CSPM aggregates findings from GuardDuty, Inspector, Macie, and supported partner integrations. Microsoft Defender for Cloud and Google Security Command Center provide similar cloud security posture capabilities. These services provide centralized visibility and compliance monitoring across your cloud footprint.
Cloud-native firewalls and WAFs filter traffic at the edge. AWS WAF works with CloudFront and Application Load Balancers, Azure WAF with Application Gateway, and GCP Cloud Armor with Cloud CDN and load balancers. A WAF adds a useful layer for exposed HTTP services, but it does not replace secure application code or restricted network access.
Logging and monitoring make incident response possible. CloudTrail records management events by default in Event history; configure trails and event selectors for the management and data events your audit requirements need. VPC Flow Logs capture selected network flow metadata, and GuardDuty uses threat intelligence and anomaly detection to flag suspicious activity. Route relevant findings and logs to a SIEM or analytics platform.
Defense-in-Depth Architecture
flowchart TD
A[Internet Traffic] --> B[WAF / Cloud Firewall]
B --> C[Load Balancer]
C --> D[Security Groups]
D --> E[Application Tier]
E --> F[Database Tier]
F --> G[KMS Encryption]
A --> H[IAM Authentication]
H --> E
E --> I[VPC Endpoints]
I --> J[S3 / DynamoDB]
Trade-Off Table
| Security Control | Complexity | Security Benefit | Best For |
|---|---|---|---|
| Customer-managed KMS keys | High | Full audit and rotation control | Regulated workloads, cross-account access |
| AWS-managed KMS keys | Low | AWS-managed policy and rotation; no monthly key fee | Workloads that do not need direct key control |
| VPC endpoints | Medium | Traffic stays internal, lower cost | Private access to S3, DynamoDB from private subnets |
| NAT gateway for private traffic | Medium | Outbound-only internet for private subnets | Patching, external API calls from private instances |
| Security groups | Low | Instance-level stateful firewall | Primary network isolation for compute |
| NACLs | Medium | Subnet-level stateless filtering | Broad subnet rules, blocking specific CIDRs |
| IAM roles over user credentials | Low | Short-lived tokens, no credential management | All compute workloads |
Production Failure Scenarios
| Failure | Impact | Mitigation |
|---|---|---|
| IAM role trust policy misconfiguration locking out resources | Resources cannot assume roles, deployments fail | Use AWS Access Analyzer before deploying, test trust policies in dev |
| KMS key deletion without waiting for grace period | Encrypted data becomes irrecoverable | Choose a deletion waiting period from recovery needs; AWS KMS allows 7 to 30 days |
| Security group overly restrictive blocking legitimate traffic | Application cannot connect to dependencies, outages | Always test security group changes in staging first, use descriptive names |
| VPC endpoint policy denying required S3 access | Application cannot read from S3, deployments fail | Explicitly list required actions in endpoint policy, test after changes |
| CloudTrail not enabled for all regions | Attack activity in disabled regions goes unlogged | Enable CloudTrail across all regions, aggregate to single bucket |
Observability Checklist
- Enable CloudTrail coverage in every active region and account; explicitly select data events for services and resources that need them.
- Alert on root-account use, unusual role assumptions, IAM policy changes, security group edits, and KMS key policy or deletion changes.
- Collect VPC Flow Logs for the network interfaces that matter, then review rejected connections and unexpected outbound volume.
- Track configuration drift such as public storage, broad ingress rules, disabled encryption, and logging changes.
- Centralize logs in a separate account or security boundary, restrict who can change or delete them, and set retention to match investigation and business needs.
- Test alert delivery and incident queries periodically; a log source that nobody can search during an incident is not useful coverage.
What to monitor:
CloudTrail records the event types you configure. Management events are available by default; select data events explicitly when you need them. Enable coverage in all active regions and route logs to a centralized bucket with object lock to prevent tampering.
GuardDuty monitors for compromised workloads. Review findings daily and route alerts to your security team’s notification channel.
Security Hub can aggregate findings from GuardDuty, Inspector, Macie, and supported integrations. Enable only the services and regions in scope, then confirm that findings are arriving.
VPC Flow Logs record selected network-flow metadata such as source and destination addresses, ports, and byte counts. They are not packet captures and do not record every type of IP traffic, so use them alongside other telemetry.
Key commands and queries:
# List recent CloudTrail events
aws cloudtrail lookup-events --max-results 10
# Get GuardDuty findings
aws guardduty list-findings \
--detector-id abc123 \
--finding-criteria '{"Severity": [{"Eq": ["HIGH"]}]}'
# Query VPC Flow Logs for port 22 access
aws logs start-query \
--log-group-name /aws/vpc/flow-logs \
--start-time 1700000000 \
--end-time 1700003600 \
--query-string 'fields srcAddr, dstAddr, dstPort, action | filter dstPort = 22 | limit 20'
# Check IAM Access Analyzer findings
aws accessanalyzer list-findings \
--analyzer-arn arn:aws:access-analyzer:us-east-1:123456789012:analyzer/my-analyzer
Security and Compliance Notes
Cloud security responsibilities shift with the service. With virtual machines, you typically manage the guest operating system, patches, applications, identity policies, and network rules. With a managed database or serverless service, the provider takes on more of the platform work, but you still control data access, configuration, and how the service fits into your environment. Write down who owns each control instead of treating a provider’s certification as proof that your workload is compliant. See the AWS shared responsibility model for an AWS example.
Use centralized identity, MFA for human access, short-lived workload credentials, and narrow role trust policies. Put network controls around the services that need them: private endpoints where appropriate, explicit egress paths, and security group rules tied to known workloads. Provider guardrails can block some risky configurations, but they do not replace review of workload permissions or application behavior.
Data location includes more than the primary database. Check the selected region and any cross-region replication, backups, snapshots, logs, support exports, and third-party integrations. Confirm that the provider service and its features support your location and contractual requirements; service availability and data handling can differ by region. Restrict who can change region choices and replication settings, and record the approved locations.
Treat audit evidence as a control that must be configured and retained. For example, CloudTrail Event history covers management events, while trails and event data stores need explicit settings for data events; review the CloudTrail event types against your investigation needs. Provider reports can help document provider-managed controls, but your own access, network, retention, and privacy controls still need evidence.
Logs can contain usernames, IP addresses, resource names, and request details. Collect only fields needed for security and operations, limit access to the log store, encrypt it, and set a retention period that matches policy and legal requirements. Avoid copying sensitive payloads into logs unless there is a documented need and appropriate protection.
Common Pitfalls / Anti-Patterns
Using the AWS root user for daily operations. The root user has full permissions and cannot be restricted by IAM policies. Protect it with MFA and use it only for tasks that require root credentials. Use federation or IAM Identity Center for routine human access, and roles for workloads.
Over-permissive IAM roles. Granting *:* or AdministratorAccess to workloads because it is faster than scoping permissions defeats the purpose of least privilege. Start with minimal permissions and add only what the workload actually needs.
Leaving security groups open to 0.0.0.0/0. Allowing all inbound traffic to a database or cache port from anywhere on the internet is a common breach vector. Security groups should restrict access to known CIDRs or specific security groups.
Assuming every service has the same encryption defaults. Amazon S3 encrypts new objects by default with SSE-S3, while other services and stronger customer-managed-key requirements may need extra configuration. Verify each service’s settings and enforce the specific encryption controls your data requires.
Forgetting to rotate access keys. Long-lived access keys on service accounts are a common exfiltration target. Rotate keys regularly, use short-lived credentials via IAM roles wherever possible.
Trade-off Analysis (Tools)
| Security Tool | Preventative vs Detective | CI/CD vs Runtime | Cost |
|---|---|---|---|
| Cloud-native (GuardDuty, Security Hub, Defender) | Detective | Runtime | Pay per consume |
| CSPM (Prisma Cloud, Wiz) | Both | Runtime | Per-asset pricing |
| SAST / IaC scanning | Preventative | CI/CD | Tool cost |
| Secret scanning (Gitleaks, TruffleHog) | Preventative | CI/CD | Free / paid tiers |
| Runtime security (Falco, Sysdig) | Detective | Runtime | Infrastructure + license |
| SIEM (Splunk, Elastic) | Detective | Runtime | High (licensing + storage) |
Illustrative Failure Scenarios
| Scenario | Possible impact | Control to review |
|---|---|---|
| A vendor role can reach a production data store beyond its task | A compromised vendor credential may expose unrelated systems | Limit trust and permissions to the required workflow; review network paths |
| A workload can retrieve broad role credentials through a metadata endpoint | Server-side request forgery may expose permissions available to the workload | Restrict metadata access and scope the role to the workload’s needs |
| An object store policy grants public access unintentionally | Data may be readable outside the intended audience | Block public access where appropriate and verify effective bucket and organization policies |
| A database accepts connections without authentication or from broad networks | Unauthenticated users may read, alter, or encrypt data | Require authentication and restrict network paths |
| A build pipeline can publish unsigned or unverified artifacts | A compromised build step may distribute a malicious update | Protect build credentials, verify artifact provenance, and review signing controls |
These are illustrative scenarios, not incident reports. A threat model should identify which assets, identities, network paths, and deployment steps apply to the workload.
Quick Recap Checklist
- Defense in depth means layering IAM, network isolation, and encryption—not relying on any single control.
- Least privilege is the cardinal rule: grant only the permissions needed, nothing more.
- IAM roles with short-lived credentials reduce the need to store long-lived keys in code or environment variables.
- Gateway endpoints for S3 and DynamoDB can avoid NAT processing charges; interface endpoints and NAT have separate costs.
- CloudTrail, GuardDuty, and Security Hub provide the monitoring foundation for any AWS environment.
Interview Questions
Implementation starts with understanding what permissions your identities actually need rather than defaulting to broad policies. Use IAM Access Analyzer to identify external access and policy simulators to test policies before deployment. Create groups for roles, attach policies to groups, and add users to groups rather than attaching policies directly to users. Regularly audit unused access keys and deactivate old credentials.
NAT gateways handle outbound internet access for private instances—for patching, downloading packages, calling external APIs. They don't allow inbound connections from the internet.
Use VPC endpoints for supported private services and NAT gateways when private instances need general internet egress. Gateway endpoints for S3 and DynamoDB can avoid NAT processing charges; compare interface-endpoint and NAT costs for other traffic.
Static access keys in code or environment variables can be exposed and reused. Instance profiles provide EC2 workloads with temporary credentials for an IAM role, and other platforms offer similar workload identity mechanisms: Azure managed identities, AWS IAM roles, and Google Cloud Workload Identity Federation.
Database servers sit in private subnets without a direct internet route and accept connections only from the application tier. KMS encrypts data at rest, and IAM roles control access to AWS services.
For Kubernetes workloads, network policies restrict pod-to-pod communication, and a service mesh can add mTLS between services. Gateway endpoints provide private paths to S3 and DynamoDB.
Configure the database security group to accept inbound PostgreSQL or MySQL traffic only from the application tier security group ID. This means the rule looks like: port 5432, source security group sg-xxxxxxxx. When application servers scale, they automatically get database access. When database servers scale, they inherit the same restrictions.
Outbound rules should be minimal—typically only to the application tier or specific external services the database needs to reach.
AWS-managed keys have no monthly key charge, though service usage may still be billed. AWS manages their policy and automatic annual rotation; you can review their metadata and use, but cannot change their policy or lifecycle.
Choose a customer-managed key when you need direct lifecycle or cross-account control. AWS-managed keys suit workloads that do not need those controls and can use the service's default key configuration.
Second, use an S3 VPC endpoint with an endpoint policy to add a network-level restriction on requests that use that endpoint. Without an endpoint, private-subnet traffic follows its configured route, often through a NAT gateway. Endpoint policies can deny actions such as PutObject for requests that pass through the endpoint.
Third, enable S3 Block Public Access at the account level. Fourth, use CloudTrail with S3 data events to detect unusual GetObject patterns—large volumes of downloads from an unusual location or at unusual times.
Use SCPs to set organization-wide permission guardrails, such as denying actions in disallowed regions or preventing changes to security controls. They can also use condition keys to deny sensitive actions when a request lacks MFA. SCPs do not grant permissions, and they do not apply to the AWS Organizations management account or service-linked roles.
Attach SCPs to the organization root, an OU, or an account to set the maximum permissions available to affected principals. Test policy changes carefully so they do not block required administrative or recovery actions.
For non-Kubernetes services, use TLS for all network communication. Either terminate TLS at the load balancer and use internal encryption between services, or implement TLS end-to-end. Certificate management can be automated with services like AWS Certificate Manager or Let's Encrypt with cert-manager for Kubernetes.
The key requirement is enforcing TLS everywhere—not just on public endpoints. Internal services should also use TLS, especially when crossing network boundaries like availability zones.
Detection methods: AWS Config rules can detect overly permissive security groups and alert or auto-remediate. GuardDuty can flag unusual inbound traffic patterns. VPC Flow Logs provide selected flow metadata that can help show accepted and rejected connections. Security Hub aggregates these findings.
Prevention: Use AWS Config rules with remediation to automatically close security groups that open ports to 0.0.0.0/0. Set up AWS Security Hub to alert on configuration changes. Never allow 0.0.0.0/0 for database or cache ports—these should only accept traffic from specific security groups or CIDRs you control.
For existing buckets, run a scan and remediate any unencrypted ones. Use S3 Inventory to track encryption status across all buckets. For KMS encryption, ensure the policy restricts key usage to specific roles and services that need access.
Automate bucket provisioning through reviewed infrastructure-as-code templates or an approved account workflow. Verify that the resulting encryption type and key policy meet the workload's requirements.
The split varies by service type. For IaaS (EC2, VPC), you manage the OS and applications. For PaaS (RDS, Lambda), the provider manages the platform. For SaaS, most controls are provider-managed.
This means you cannot rely on the cloud provider to secure your data or configurations. Even with a "secure" cloud platform, misconfigured IAM, open security groups, or unencrypted data is your fault.
Containment should be coordinated with the incident lead: restrict the affected role's permissions and revoke active sessions using IAM's role session-revocation mechanism. Isolate affected resources, preserve logs, and identify which data was accessed and how the role was exposed.
Reduce the blast radius with endpoint policies that restrict S3 access to required buckets and actions, plus S3 Block Public Access. Use SCPs as guardrails for principals in organization member accounts; they do not constrain principals from outside the organization.
Enable Security Hub in the accounts and regions in scope. Use supported standards to assess configuration, route relevant findings to a SIEM or ticketing system, and review automated remediation before applying it.
Without an aggregator, you may need to review findings across several services. Security Hub provides one view of supported AWS and partner findings, but check connector and regional coverage before treating it as a complete multicloud inventory.
For external users, create an IAM role with trust policy allowing your identity provider to assume it. Scope permissions to exactly what external users need. Set session duration to limit exposure. Enable MFA at the identity provider level, not just in AWS.
For programmatic access, use STS to issue short-lived credentials rather than access keys. For third-party cross-account roles, require an external ID where appropriate. Regularly audit which federated identities are active and remove unused ones.
Use SCPs to set permission guardrails across member accounts, such as denying actions in specific regions or denying sensitive actions unless the request includes MFA. SCPs do not grant permissions, and they do not apply to the management account or service-linked roles.
SCPs attached to the organization root, an OU, or an account define the maximum permissions available to affected principals. An explicit deny overrides an allow, and an action also needs an identity-based or resource-based policy that grants it.
Within Kubernetes, use RBAC to grant API permissions only when the workload needs them. Network policies can restrict pod-to-pod communication, and Pod Security Standards limit what pods can do.
Give each workload a dedicated service account and avoid cluster-admin permissions. Test access to AWS APIs and the Kubernetes API separately; an IAM role does not grant Kubernetes permissions.
Security monitoring use cases include spotting unusual connection patterns, unexpected traffic between subnets, or large outbound transfers. Flow Logs provide evidence for these investigations, but they do not record every traffic type or packet contents.
Route Flow Logs to CloudWatch Logs or S3, then analyze with Athena or a SIEM. Set up CloudWatch alarms on unusual traffic patterns. Store logs with Object Lock to prevent tampering.
For manual rotation (if you need rotation more frequently or on a specific schedule): create a new KMS key, update applications to use the new key for encryption, ensure existing data can still be decrypted with old key, then disable the old key. Do not delete old keys until all data encrypted with them is either re-encrypted or no longer needed.
Use envelope encryption: a data key encrypts data, the data key is encrypted by KMS key. Rotating the KMS key only requires re-encrypting data keys, not the data itself.
Containment: restrict compromised role permissions or revoke active role sessions, then apply network controls to isolate affected resources. Preserve evidence; do not delete logs or stop instances that may contain useful artifacts without incident-lead approval.
Investigation: use CloudTrail to identify what actions were taken, from which IP, using which credentials. Check whether data was exfiltrated via S3 or other services. Identify the initial access vector — was it an exposed access key, a compromised service account, or a misconfigured resource?
Recovery: rotate all credentials that might be compromised. Remove any backdoors added by attacker (new IAM users, security group rules, cron jobs). Restore from known-good backups if data was modified.
Post-incident: document timeline, root cause, and remediation. Update detection rules to catch similar attacks faster. Notify affected customers if data was exposed.
Further Reading
- Network Security: Firewalls, Segmentation, and Zero Trust — practical network boundary and traffic-control concepts
- Secrets Management — storing, rotating, and granting access to application credentials
- Incident Response — investigation and recovery practices for security events
- Access Control Models and Least Privilege — designing narrow permissions and reviewable access policies
- Encryption at Rest — storage encryption, key management, and operational controls
- AWS IAM Documentation — identity and access management concepts and policy types
- AWS PrivateLink Documentation — private connectivity to AWS, partner, and account-owned services
- AWS KMS Key Types — key ownership, control, rotation, and pricing distinctions
- AWS Security Hub — AWS security posture management and supported integrations
- AWS Organizations SCP Guide — permission guardrails and the principals they affect
- Terraform S3 Encryption Resource — current provider configuration for bucket encryption
Conclusion
Cloud Security Checklist
# 1. Create and start a multi-region CloudTrail trail
aws cloudtrail create-trail --name my-trail --is-multi-region-trail --s3-bucket-name my-cloudtrail-bucket
aws cloudtrail start-logging --name my-trail
# 2. Enable GuardDuty
aws guardduty create-detector --enable
# 3. Enforce encryption on S3 buckets
aws s3api put-bucket-encryption \
--bucket my-bucket \
--server-side-encryption-configuration '{"Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}}]}'
# 4. Demo only: ReadOnlyAccess is broad, not a least-privilege policy
aws iam create-group --group-name readonly
aws iam attach-group-policy --group-name readonly --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
# 5. Block public access to S3 buckets
aws s3api put-public-access-block \
--bucket my-bucket \
--public-access-block-configuration 'BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true'
Choose a small set of controls that your team can operate consistently, then review their coverage as services and data flows change. For cost planning, see Cost Optimization.
Category
Related Posts
Kubernetes Network Policies: Practical Pod Security
Implement microsegmentation in Kubernetes using Network Policies to control traffic flow between pods and enforce zero-trust networking.
Event Security and Sensitive Data in EDA
Secure event-driven systems with least-privilege identities, encrypted transport and payloads, careful data minimization, and a deliberate retention plan.
Forward and Reverse Proxies: Routing, Trust, and Use Cases
Learn how forward and reverse proxies handle HTTP traffic, CONNECT tunnels, TLS termination, caching, routing, trusted headers, and production failures.