0%
AWS Developer Associate (DVA-C03) Exam Prep: Development, Security, Testing, Deployment and Troubleshooting
How the Exam Works
Domain 1: Development with AWS Services
Domain 3: Testing and Deployment
Domain 4: Troubleshooting and Optimization
New in DVA-C03: Containers and AI
Final Review and Mock Exams
IAM and Cognito for Developers
Security is about a quarter of the Developer Associate exam, and most of it is IAM and Cognito. The architect exam asks which identity service fits an organization. This exam asks what your code and your templates need: the exact policy that lets a function read one table, why a call is denied, how a service gets credentials, how a mobile app signs users in and reaches AWS without embedded keys. This lesson covers policies and how AWS evaluates them, roles and STS, Cognito user pools and identity pools, federation and least privilege. Encryption and secrets have their own lesson next.
The parts of a policy
An IAM policy is a JSON document with a Version (always 2012-10-17 for current features) and one or more Statements. Each statement has an Effect (Allow or Deny), an Action or list of actions, a Resource or list of resources and optionally a Condition. Resource-based policies also have a Principal, which names who the statement applies to.
Actions are named service:Operation, such as s3:GetObject or sqs:SendMessage, and accept wildcards like s3:Get*. Resources are ARNs. Some actions apply to different resource types than you might expect, and that causes many access denied errors in practice. s3:ListBucket applies to the bucket ARN (arn:aws:s3:::reports), while s3:GetObject applies to object ARNs (arn:aws:s3:::reports/*). A policy that grants both actions on only one of those ARNs fails for the other action. Querying a DynamoDB global secondary index needs the index ARN, as in the example above, not only the table ARN.
NotAction and NotResource invert the match. They are useful in deny statements, such as denying everything except a short list of actions when MFA is absent, but risky in allow statements, because "allow everything except" grants far more than intended.
Conditions and policy variables
Conditions narrow a statement using condition keys. Global keys apply to every service: aws:SourceIp, aws:SourceVpce, aws:PrincipalTag, aws:RequestedRegion, aws:MultiFactorAuthPresent, aws:SecureTransport and aws:CurrentTime. Service keys are specific: s3:prefix for list calls, dynamodb:LeadingKeys for the partition key of items, kms:ViaService for key use through a service. Operators include StringEquals, StringLike, ArnLike, IpAddress, Bool, NumericLessThan and DateGreaterThan, with IfExists variants and ForAllValues or ForAnyValue for multi-valued keys.
Policy variables insert request context into a policy. The aws:username variable, written with a dollar sign and braces inside the JSON, lets one policy give every IAM user their own S3 prefix. The same mechanism with the cognito-identity.amazonaws.com:sub variable gives every Cognito user their own prefix or DynamoDB partition, which the Cognito section returns to.
Identity-based and resource-based policies
Identity-based policies attach to an IAM user, group or role and say what that principal can do. They come in three forms: AWS managed policies (maintained by AWS, broad, reusable), customer managed policies (yours, reusable, versioned) and inline policies (embedded in one principal, deleted with it). Prefer customer managed policies for anything you reuse; use inline policies when the permission must never outlive the principal.
Resource-based policies attach to a resource and say who can do what to it. S3 bucket policies, SQS queue policies, SNS topic policies, KMS key policies, Lambda function policies, ECR repository policies, Secrets Manager secret policies and API Gateway resource policies are all examples. They always contain a Principal element, which can be an account, a role, a user, an AWS service such as sns.amazonaws.com, or a wildcard.
Within one account, an action is allowed if either an identity policy or a resource policy allows it, and nothing denies it. Across accounts, both sides must allow it: the caller's identity policy must allow the action on the other account's resource, and the resource policy must allow the caller's principal. That difference is the root of many exam questions about cross account access.
Resource policies you write as a developer
You meet resource policies whenever one service calls another. An S3 event that invokes a function needs a statement in the function's resource policy allowing s3.amazonaws.com to call lambda:InvokeFunction. API Gateway invoking a function needs the same with apigateway.amazonaws.com. A queue receiving from an SNS topic needs a queue policy. Always add conditions such as aws:SourceArn and aws:SourceAccount to statements whose principal is a service, so that only your bucket or your topic can use the permission, not the same service acting on behalf of someone else. This is the confused deputy protection that AWS recommends for every service principal.
Users, groups and roles in application code
An IAM user has long-term credentials: a password for the console and up to two access keys. A group is a collection of users that share policies; groups cannot be principals in resource policies and cannot be nested. A role has no long-term credentials; principals assume it and get temporary ones. For application code, the guidance is consistent: workloads on AWS use roles, people sign in through IAM Identity Center or federation, and IAM users with access keys are a last resort for the rare tool that cannot use anything else. When an IAM user's keys must exist, rotate them using the two key slots: create a second key, deploy it, confirm the old key is unused through its last used date, then deactivate and delete the old one.
What the exam is checking here
Read the policy JSON in the question carefully. The bug is usually a wrong ARN level (bucket versus objects, table versus index), a missing action (ListBucket for a listing, Query rather than GetItem), a missing condition or a statement on the wrong side of a cross account call. Options that grant full access with wildcards fix the symptom and fail the least privilege test the question is really asking.
Policy versions and managed policy updates
A customer managed policy keeps up to five versions, and one of them is the default that takes effect. Editing a policy creates a new version and makes it the default, so a bad change can be rolled back by setting an earlier version as the default again, without rewriting anything. AWS managed policies are updated by AWS, and those updates take effect for every principal using them, which is one reason production roles usually rely on customer managed policies that change only when you change them. Inline policies have no versions; the policy is simply whatever the current text is.
Policies also have size limits. An inline policy on a role, or a managed policy, is limited to several thousand characters, and a role can have only a limited number of managed policies attached by default. When a policy grows past the limit, the usual fix is not to request more space but to tidy the policy: use wildcards on resource names that share a prefix, group actions with a pattern such as dynamodb:Get*, split permissions by function into separate roles, or move to tag based conditions.
Worked example: a reporting function
A reporting function reads one DynamoDB table and its status index, lists and reads objects under the input/ prefix of a bucket, writes results under output/, and sends a summary to an SQS queue. A good policy has four statements. The first allows dynamodb:Query and dynamodb:GetItem on the table ARN and the index ARN. The second allows s3:ListBucket on the bucket ARN with an s3:prefix condition of input/. The third allows s3:GetObject on input/* and s3:PutObject on output/. The fourth allows sqs:SendMessage on the queue ARN. Each wrong option in a question about this function usually breaks one of these: listing on the object ARN, a missing index ARN, s3: on the whole bucket, or sqs:* on every queue. Learn to see the four statements quickly and the question answers itself.
Explicit names versus wildcards in ARNs
Wildcards in ARNs are fine when they match a deliberate naming scheme, such as table/orders-* for per-environment tables or role/app-* for application roles. They become a problem when they cover more than intended: arn:aws:s3:::* matches every bucket in every account, and a Resource of a single asterisk matches everything the action applies to. When a stem asks for the most secure policy that still works, pick the option with the narrowest ARN that covers every resource the code touches, not the one with the fewest lines.
s3:ListBucket is granted on arn:aws:s3:::bucket, and s3:GetObject on arn:aws:s3:::bucket/*. A policy with only one of the two ARNs fails one of the calls, which is the single most common S3 policy bug.