AWSDOP-C02
πŸ“

AWS Recommended Best Practices

Explicit "AWS recommends X over Y" guidance pulled from official AWS documentation. Exam questions are frequently written so that the AWS-recommended option is the correct one.

71 recommendations10 servicesEvery entry sourced

Prefer federation with temporary credentials over IAM users for human access

IAM

Require human users to use temporary credentials when accessing AWS. For centralized access management, AWS recommends IAM Identity Center to manage access to accounts and permissions within them.

🎯 Exam signal: "How should employees access multiple accounts?" β†’ IAM Identity Center, not IAM users per account.
IAM security best practices β†—

Prefer IAM roles over long-term access keys for workloads

IAM

On AWS compute (EC2, Lambda), AWS delivers temporary role credentials automatically β€” there is no need to distribute long-lived IAM user keys. Workloads outside AWS can still use temporary credentials via IAM Roles Anywhere, AssumeRoleWithSAML, or AssumeRoleWithWebIdentity.

🎯 Exam signal: Any answer embedding access keys in code, AMIs, or environment variables is wrong.
IAM security best practices β†—

Require MFA β€” and prefer phishing-resistant MFA

IAM

For scenarios that still need an IAM user or the root user, require MFA. AWS recommends phishing-resistant MFA such as passkeys and security keys wherever possible.

IAM security best practices β†—

Start with AWS managed policies, then move to customer managed policies

IAM

AWS managed policies are a fast starting point but might not grant least privilege, because they are written for all AWS customers. AWS recommends reducing permissions further by defining customer managed policies specific to your use case.

🎯 Exam signal: If an option attaches a broad AWS managed policy and stops there, look for the least-privilege alternative.
IAM security best practices β†—

Use IAM Access Analyzer to generate least-privilege policies from CloudTrail activity

IAM

Access Analyzer analyzes the services and actions your roles actually used (from CloudTrail logs) and generates a fine-grained policy you can review and deploy.

🎯 Exam signal: "Tighten an over-permissive role based on real usage" β†’ Access Analyzer policy generation.
IAM security best practices β†—

Validate policies with IAM Access Analyzer policy validation

IAM

Access Analyzer provides more than 100 policy checks and actionable recommendations. AWS recommends reviewing and validating all existing policies, not just new ones.

IAM security best practices β†—

Verify public and cross-account access with Access Analyzer before granting it

IAM

Access Analyzer continuously monitors supported resource types and generates findings for resources that allow public or cross-account access. You set a zone of trust (account or organization); anything outside it that has access produces a finding.

🎯 Exam signal: "Find S3 buckets / roles / KMS keys shared outside the org" β†’ IAM Access Analyzer.
IAM security best practices β†—

Use SCPs (and RCPs) as guardrails β€” but remember they grant nothing

IAM

AWS recommends SCPs to establish permissions guardrails for all principals across accounts, and RCPs for resources. Critically: "No permissions are granted by SCPs and RCPs." You must still attach identity-based or resource-based policies to actually grant access.

🎯 Exam signal: Any option claiming an SCP "allows" or "enables" a service to do something is wrong.
IAM security best practices β†—

Use permissions boundaries to delegate permissions management

IAM

When you let developers create and manage roles for their own workloads, use permissions boundaries to set the maximum permissions they can delegate. A permissions boundary does not grant permissions on its own.

🎯 Exam signal: "Let developers create roles without privilege escalation" β†’ permissions boundary.
IAM security best practices β†—

Regularly review and remove unused users, roles, permissions and credentials

IAM

IAM provides last accessed information to identify what you no longer need. Use it both to remove stale principals and to refine policies toward least privilege.

IAM security best practices β†—

Use conditions in policies to further restrict access

IAM

Grant access only when the request meets specific conditions β€” for example requiring that all requests be sent over TLS, or that an action is only performed through a specific service such as CloudFormation.

IAM security best practices β†—

Prefer bucket policies over ACLs β€” disable ACLs entirely

S3

AWS recommends disabling ACLs except where you must control access per object. Apply the bucket owner enforced setting for S3 Object Ownership; ACLs are disabled by default for new buckets. Access is then governed by IAM policies, bucket policies, VPC endpoint policies, SCPs and RCPs.

🎯 Exam signal: S3 ACLs are legacy. If an option manages access with ACLs, prefer the bucket-policy answer.
S3 security best practices β†—

Prefer default bucket encryption over a bucket policy to enforce encryption at rest

S3

All S3 buckets have encryption configured by default, and every new object is automatically encrypted at rest, with SSE-S3 as the default configuration. To use a different type, set the default encryption configuration on the bucket rather than policing uploads with a policy.

🎯 Exam signal: The official AWS sample answer states AWS recommends default encryption over a bucket policy to enforce encryption.
S3 security best practices β†—

Use S3 Block Public Access β€” and enforce it organization-wide

S3

Block Public Access gives centralized controls that are enforced regardless of how resources are created. For multi-account setups, AWS Organizations can now centrally manage Block Public Access across the whole organization with a single policy, which removes the need for complex SCPs for this purpose.

S3 security best practices β†—

Prefer SSE-S3 or SSE-KMS over SSE-C

S3

AWS recommends keeping SSE-C disabled unless a workload specifically requires it. SSE-C requires supplying the key on every request, cannot be natively decrypted by AWS managed services, and makes sharing impractical. SSE-S3 or SSE-KMS give equivalent protection with far more flexibility.

S3 security best practices β†—

Enforce TLS with the aws:SecureTransport condition

S3

AWS recommends allowing only encrypted HTTPS connections by using an aws:SecureTransport condition in bucket policies, and pairing it with the s3-bucket-ssl-requests-only AWS Config rule as a detective control.

🎯 Exam signal: The canonical snippet is a Deny with Bool aws:SecureTransport false.
S3 security best practices β†—

Use IAM roles for applications that access S3 β€” never stored credentials

S3

AWS recommends not storing AWS credentials in an application or on an EC2 instance. These are long-term credentials that are not automatically rotated and could have significant business impact if compromised.

S3 security best practices β†—

Enable S3 Versioning, and consider Object Lock for WORM

S3

Versioning lets you recover from both unintended user actions and application failures. Object Lock stores objects using a write-once-read-many model and can help protect artifacts such as CloudTrail logs from deletion.

🎯 Exam signal: Cross-Region Replication requires versioning enabled on BOTH source and destination buckets.
S3 security best practices β†—

Use VPC endpoints for S3 access to keep traffic off the internet

S3

A VPC endpoint for S3 allows connectivity only to S3 and helps prevent traffic from traversing the open internet. Combined with a VPC that has no internet gateway, it helps prevent data exfiltration.

S3 security best practices β†—

Organize stacks by lifecycle and ownership

CloudFormation

Group resources that share a lifecycle and an owning team. Owners can then change their own resources on their own schedule without affecting others β€” the reasoning behind separating, say, a website stack from a database stack.

CloudFormation best practices β†—

Prefer cross-stack references over hardcoded values or input parameters

CloudFormation

Hardcoding values or passing resource names as parameters makes templates hard to reuse and increases overhead. Use Fn::ImportValue to import values another stack exported β€” CloudFormation then prevents deleting the exporting stack while other stacks depend on it.

🎯 Exam signal: Separate teams + separate lifecycles + shared resources β†’ cross-stack references, not nested stacks.
CloudFormation best practices β†—

Use StackSets with service-managed permissions for multi-account deployments

CloudFormation

StackSets create, update or delete stacks across accounts and Regions in a single operation. AWS recommends service-managed permissions with AWS Organizations so you do not have to manually configure IAM roles in each account.

🎯 Exam signal: Automatic deployment covers newly created accounts in the OU β€” the standard answer for "enable X in all future accounts".
CloudFormation best practices β†—

Never embed credentials in templates β€” use dynamic references

CloudFormation

AWS recommends dynamic references to values stored in Secrets Manager or SSM Parameter Store. CloudFormation retrieves the value when needed during stack operations and never stores the actual reference value.

🎯 Exam signal: Also set NoEcho: true on sensitive parameters so values are hidden from console, API and CLI output.
CloudFormation best practices β†—

Create change sets before updating stacks

CloudFormation

Change sets show how proposed changes will impact running resources before you execute them. The classic example: renaming an RDS instance causes CloudFormation to create a new database and delete the old one β€” a change set surfaces that replacement before you lose data.

CloudFormation best practices β†—

Use stack policies to protect critical resources

CloudFormation

A stack policy describes what update actions may be performed on designated resources. AWS recommends specifying a stack policy whenever you create a stack with critical resources. During an update you must explicitly specify protected resources you intend to change.

CloudFormation best practices β†—

Manage all stack resources through CloudFormation β€” never change them out of band

CloudFormation

Out-of-band changes create drift, a mismatch between the template and reality. If a resource is changed outside the template and you then update the stack, those changes are discarded and the resource reverts to the template configuration.

🎯 Exam signal: Pair with regular drift detection; automate it with EventBridge + Lambda.
CloudFormation best practices β†—

Configure rollback triggers for automatic recovery

CloudFormation

Rollback triggers let you name CloudWatch alarms that CloudFormation monitors during create and update operations. If any alarm enters ALARM state, CloudFormation automatically rolls back the entire stack operation.

🎯 Exam signal: "Automatically roll back the stack if error rates spike during deploy" β†’ rollback triggers.
CloudFormation best practices β†—

Use a CloudFormation service role to separate user and stack permissions

CloudFormation

Managing a stack normally requires permissions on every resource inside it. To separate permissions between a user and the service, use a service role β€” CloudFormation then uses the service role policy to make calls instead of the user policy.

🎯 Exam signal: The user only needs iam:PassRole, not the underlying resource permissions.
CloudFormation best practices β†—

Validate templates in CI/CD with cfn-lint and cfn-guard

CloudFormation

cfn-lint catches syntax and configuration issues early. CloudFormation Guard is a policy-as-code tool for enforcing organizational rules β€” for example, ensuring users always create encrypted S3 buckets β€” and can stop deployment of non-compliant resources from within a pipeline.

CloudFormation best practices β†—

Prefer YAML for hand-authored templates

CloudFormation

AWS notes YAML is generally recommended for manual template authoring because of its readability and comment support, which helps in complex templates. JSON is advantageous in automated workflows or when a tool requires it.

CloudFormation best practices β†—

Never put secrets in a pipeline or action configuration

CI/CD

AWS warns that secrets entered directly in an action configuration, in pipeline-level variable defaults, or in CloudFormation configuration will display in logs. Store them in Secrets Manager and reference the secret instead.

🎯 Exam signal: This applies to pipeline variables too β€” not just the obvious action fields.
CodePipeline security best practices β†—

Configure server-side encryption for pipeline artifacts in S3

CI/CD

For pipelines using an S3 source bucket, configure server-side encryption for artifacts by managing AWS KMS keys.

🎯 Exam signal: Cross-account pipelines require a customer managed key β€” the AWS managed aws/s3 key cannot be shared across accounts.
CodePipeline security best practices β†—

Give a Jenkins build provider its own least-privilege instance profile

CI/CD

When using Jenkins for a build or test action, install it on an EC2 instance with a separate instance profile that grants only the AWS permissions required for the project, such as retrieving files from S3.

CodePipeline security best practices β†—

Treat infrastructure templates as code β€” version control, review, automated testing

CI/CD

AWS recommends storing templates in version control, implementing code reviews, and using automated testing to validate changes, then building CI/CD pipelines for infrastructure with CodePipeline, CodeBuild and CodeDeploy.

CloudFormation best practices β†—

Prefer Session Manager over bastion hosts and SSH keys

Systems Manager

Session Manager provides secure node management without the need to open inbound ports, maintain bastion hosts, or manage SSH keys. Leaving inbound SSH or RDP ports open greatly increases the risk of unauthorized commands being run on your nodes.

🎯 Exam signal: Any answer adding a bastion host, NAT gateway or public route for admin access is fighting this recommendation.
Session Manager β†—

Control node access centrally with IAM policies, not SSH key distribution

Systems Manager

Administrators get a single place to grant and revoke access. Because permissions come from IAM rather than SSH keys, you can also grant temporary access β€” for example giving an on-call engineer production access only for the duration of their rotation.

Session Manager β†—

Use VPC endpoints (PrivateLink) for nodes without public IP addresses

Systems Manager

Setting up VPC endpoints for Systems Manager limits all network traffic between your managed nodes, Systems Manager and EC2 to the Amazon network.

🎯 Exam signal: The endpoints needed are ssm, ssmmessages and ec2messages (plus S3 if you log sessions there).
Session Manager β†—

Log session activity to S3 or CloudWatch Logs, and alert with EventBridge + SNS

Systems Manager

Session Manager integrates with CloudTrail, S3 and CloudWatch Logs for session records. You can create an EventBridge rule that detects when a user starts or stops a session and notify through SNS.

🎯 Exam signal: Note: logging is NOT available for sessions that connect through port forwarding or SSH.
Session Manager β†—

On-premises nodes need the advanced-instances tier for Session Manager

Systems Manager

Connecting to non-EC2 nodes with Session Manager requires activating the advanced-instances tier, which carries a charge. There is no additional charge to connect to EC2 instances.

Session Manager β†—

Manage all accounts within a single organization

Organizations

An organization is a security boundary that lets you maintain consistency across accounts. Consistent policies, central visibility and programmatic controls across a multi-account environment are best achieved within a single organization.

Organizations best practices β†—

Group OUs by business purpose, not by reporting structure

Organizations

AWS recommends isolating production workloads under top-level workload-oriented OUs based on a common set of controls, rather than mirroring your company reporting structure, plus one or more non-production OUs for development and test.

🎯 Exam signal: Also separate production from test/dev into different accounts, not just different OUs.
Organizations best practices β†—

Enable org-wide service integrations from the service console, not the Organizations console

Organizations

AWS recommends enabling or disabling trusted access using the target service own console or API/CLI, so the service can perform its required initialization and cleanup steps. AWS Account Management is the only service that requires the Organizations console.

Organizations best practices β†—

Enable root access management to remove member-account root credentials

Organizations

Root access management lets you monitor and remove root user credentials for member accounts and prevents their recovery. Newly created member accounts are then secure by default with no root credentials, eliminating the need for extra steps such as adding MFA after provisioning.

Organizations best practices β†—

Use a group email address for account root users

Organizations

Use a business-managed address that forwards to a group, so that if AWS must contact the account owner the message reaches multiple people β€” reducing the risk of delays when individuals are away.

Organizations best practices β†—

Prefer the aws/secretsmanager managed key β€” switch to a CMK only for cross-account or key policies

Secrets & KMS

For most cases AWS recommends the aws/secretsmanager AWS managed key, which has no cost. Use a customer managed key when you need to access the secret from another account or apply a key policy to the encryption key.

🎯 Exam signal: Same rule as CodePipeline artifacts: AWS managed keys cannot be shared cross-account. Cross-account need β†’ CMK.
Secrets Manager best practices β†—

Scope a secrets CMK with the kms:ViaService condition key

Secrets & KMS

In the key policy, set kms:ViaService to secretsmanager.<region>.amazonaws.com. This limits use of the key to requests coming from Secrets Manager only. Encryption context can narrow it further.

Secrets Manager best practices β†—

Cache secrets client-side rather than calling the API on every request

Secrets & KMS

AWS recommends using a supported caching component to cache secrets and update them only when required β€” client-side caching libraries for Java, Python, .NET, Go and Rust, the AWS Parameters and Secrets Lambda Extension, or the Secrets Manager Agent.

🎯 Exam signal: Reduces both latency and API cost β€” the usual "most efficient" answer for high-volume secret retrieval.
Secrets Manager best practices β†—

Enable automatic rotation β€” single user or alternating users

Secrets & KMS

Secrets that never change become more likely to be compromised. Secrets Manager supports automatic rotation as often as every four hours, with two strategies: single user, and alternating users.

Secrets Manager best practices β†—

Require BlockPublicPolicy when granting PutResourcePolicy

Secrets & KMS

In identity policies that allow secretsmanager:PutResourcePolicy, AWS recommends a Bool condition on secretsmanager:BlockPublicPolicy set to true, so users can only attach resource policies that do not allow broad access. Secrets Manager uses Zelkova automated reasoning to detect broad access.

Secrets Manager best practices β†—

Be careful with aws:SourceIp conditions on secrets β€” prefer VPC endpoint conditions

Secrets & KMS

AWS warns that IP-based conditions break services acting on your behalf: a rotation Lambda calls Secrets Manager from an AWS-internal address space and will fail the filter. aws:SourceIp is also less effective when requests come through a VPC endpoint. Use aws:SourceVpc or aws:SourceVpce instead.

🎯 Exam signal: Classic troubleshooting scenario: "rotation started failing after we added an IP restriction."
Secrets Manager best practices β†—

Run infrastructure on private networks with an interface VPC endpoint

Secrets & KMS

AWS recommends running as much infrastructure as possible on private networks not accessible from the public internet, establishing a private connection between your VPC and Secrets Manager with an interface VPC endpoint.

Secrets Manager best practices β†—

Scan code for unprotected secrets

Secrets & KMS

CodeGuru Reviewer integrates with Secrets Manager to run a secrets detector that finds hardcoded passwords, database connection strings and user names in your code. Amazon Q can also scan a codebase for security issues.

Secrets Manager best practices β†—

Use AWS native basic scanning β€” Clair basic scanning is deprecated

ECS & ECR

ECR offers two basic scanning versions. AWS native basic scanning is GA and recommended, and all new registries are opted into it by default. The older Clair-based basic scanning is deprecated, is not supported in Regions added after September 2024, and is no longer supported anywhere as of October 1, 2025.

🎯 Exam signal: Older exam material equates basic scanning with Clair. Enhanced scanning is still the Amazon Inspector one that covers OS AND language packages.
ECS task and container security β†—

Prefer minimal or distroless images

ECS & ECR

Remove extraneous binaries from container images. Distroless images contain only your application and its runtime dependencies β€” no package managers or shells β€” which improves scanner signal-to-noise and reduces attack surface. Multi-stage builds keep build tooling out of the final image.

ECS task and container security β†—

Run containers as a non-root user

ECS & ECR

Containers run as root by default unless the Dockerfile includes a USER directive. AWS suggests linting Dockerfiles in your CI/CD pipeline for the USER directive and failing the build when it is missing.

ECS task and container security β†—

Use a read-only root file system

ECS & ECR

A container root file system is writable by default. Configuring it read-only forces you to define explicitly where data may be persisted and reduces attack surface. Test first β€” some OS packages expect to write to the filesystem.

ECS task and container security β†—

Use immutable tags in Amazon ECR

ECS & ECR

Immutable tags prevent pushing an altered version of an image over an existing tag, protecting against an attacker replacing an image with a compromised build under the same tag. It forces a new tag for every change.

ECS task and container security β†—

Avoid running containers as privileged

ECS & ECR

A privileged container inherits all Linux capabilities assigned to root on the host. AWS advises setting the ECS container agent variable ECS_DISABLE_PRIVILEGED to true where privileged mode is not needed, or scanning task definitions for the parameter with Lambda.

🎯 Exam signal: Privileged mode is not supported on ECS on Fargate at all.
ECS task and container security β†—

Set CPU and memory limits on tasks (EC2 launch type)

ECS & ECR

Without limits, tasks have access to the host CPU and memory, so one task on a shared host can starve others. Fargate requires CPU and memory values because it uses them for billing, and each Fargate task runs on its own dedicated instance.

ECS task and container security β†—

Provide curated base images instead of letting developers pull from Docker Hub

ECS & ECR

Create a set of vetted images for the application stacks in your organization so developers do not each compose their own Dockerfiles. AWS explicitly advises avoiding pulling images from Docker Hub, because you do not always know what is in them.

ECS task and container security β†—

Use a customer managed key to encrypt images pushed to ECR

ECS & ECR

Images pushed to ECR are automatically encrypted at rest with an AWS KMS managed key. If you need control over the key, ECR supports server-side encryption with a customer managed key.

ECS task and container security β†—

Prefer EKS Pod Identities over IRSA

EKS

Both are preferred ways to deliver temporary AWS credentials to pods, but AWS states: "Unless you have specific usecases for IRSA, we recommend you use EKS Pod Identities when using EKS." Pod Identity needs no OIDC provider per cluster, sets session tags for ABAC, and does not consume your account STS quota.

🎯 Exam signal: IRSA still wins for direct cross-account access (sts:AssumeRoleWithWebIdentity). Pod Identity reaches other accounts only indirectly via role chaining, and requires an iam:PassRole check.
EKS IAM best practices β†—

Block pod access to the node instance profile with IMDSv2 and hop limit 1

EKS

Even with IRSA or Pod Identity, a pod can still inherit the rights of the instance profile assigned to the worker node. Require IMDSv2 and set the PUT response hop limit to 1. Do NOT disable instance metadata entirely β€” components such as the node termination handler depend on it.

🎯 Exam signal: The command is aws ec2 modify-instance-metadata-options --http-tokens required --http-put-response-hop-limit 1.
EKS IAM best practices β†—

Update the aws-node daemonset to use IRSA or Pod Identity

EKS

By default aws-node uses the EC2 instance role, which includes managed policies such as AmazonEKS_CNI_Policy and EC2ContainerRegistryReadOnly. That effectively lets all pods on the node attach/detach ENIs, assign IPs, or pull from ECR β€” a risk AWS recommends removing by moving aws-node to IRSA or Pod Identity.

EKS IAM best practices β†—

Manage access using identity federation and IAM roles whenever possible

EC2

The first EC2 security best practice AWS lists is to manage access to AWS resources and APIs using identity federation with an identity provider and IAM roles, rather than static credentials.

EC2 best practices β†—

Implement the least permissive security group rules

EC2

Security groups should grant only the access actually required. Combined with Session Manager, this lets you close inbound SSH and RDP entirely.

EC2 best practices β†—

Use Amazon Inspector to find software vulnerabilities and unintended network exposure

EC2

Inspector automatically discovers and scans EC2 instances for software vulnerabilities and unintended network exposure. Security Hub CSPM controls monitor EC2 resources against security standards.

🎯 Exam signal: Inspector = vulnerability and exposure scanning. GuardDuty = threat detection. Macie = sensitive data. Config = configuration compliance.
EC2 best practices β†—

Use separate EBS volumes for the OS and your data

EC2

Keep data on its own volume and ensure it persists after instance termination. Use instance store only for temporary data β€” it is deleted when you stop, hibernate or terminate the instance.

EC2 best practices β†—

Encrypt EBS volumes and snapshots

EC2

AWS lists encrypting EBS volumes and snapshots among its core EC2 storage best practices.

EC2 best practices β†—

Deploy critical components across multiple Availability Zones and automate failover

EC2

Replicate data appropriately, design applications to handle dynamic IP addressing on restart, and use EC2 Auto Scaling for automated failover rather than manually reattaching an ENI or Elastic IP.

🎯 Exam signal: AWS also recommends regularly TESTING the recovery process, not just configuring it.
EC2 best practices β†—

Use Trusted Advisor to find cost, availability and security gaps

EC2

Trusted Advisor inspects your environment and recommends where you can save money, improve system availability and performance, or close security gaps. Also check service quotas in advance of needing them.

EC2 best practices β†—

Each entry paraphrases guidance from the linked AWS documentation page. AWS notes that best practices are general guidelines rather than prescriptions β€” but on the exam, the AWS-recommended option is usually the intended answer.