AWS Developer Associate Domain 2: Security
52 free practice questions for Security in the AWS Certified Developer – Associate (DVA-C02) exam. Try each question first, then open "Show answer" for the correct option and explanation.
Security practice questions
-
Question 1. What gives a Lambda function permission to write to a DynamoDB table?
Show answer
Answer: C. Its execution role
The execution role is assumed by Lambda when the function runs, and its policies decide which AWS APIs the code can call.
-
Question 2. What allows an S3 bucket in the same account to invoke a Lambda function?
Show answer
Answer: B. A statement in the function's resource-based policy
Resource-based policies control who can invoke the function. The console or add-permission creates the statement.
-
Question 3. A web app must let users sign up, sign in, and receive JWTs. Which service provides this?
Show answer
Answer: A. Amazon Cognito user pools
User pools are user directories that issue ID, access, and refresh tokens.
-
Question 4. Signed-in mobile users need temporary AWS credentials to upload directly to S3. Which service exchanges their token for credentials?
Show answer
Answer: C. Amazon Cognito identity pools
Identity pools federate identities from user pools or social providers and return temporary credentials for an IAM role.
-
Question 5. An API Gateway REST API should accept only requests with valid tokens from a Cognito user pool, with no custom code. What should be used?
Show answer
Answer: C. A Cognito user pool authorizer
The Cognito authorizer validates the token itself. A Lambda authorizer is needed only for custom logic.
-
Question 6. An API must validate tokens from a third-party identity provider and check custom claims. Which REST API feature fits?
Show answer
Answer: D. A Lambda authorizer
Lambda authorizers run custom code that returns an IAM policy, and results can be cached.
-
Question 7. Internal services call an API Gateway API with their IAM roles. Which authorization type should the API use?
Show answer
Answer: B. AWS_IAM, with requests signed using SigV4
IAM authorization checks the caller's signed request against its IAM permissions for execute-api:Invoke.
-
Question 8. A developer must encrypt a 50 MB file with AWS KMS. Why can't the file be passed directly to the Encrypt API?
Show answer
Answer: A. Encrypt accepts at most 4 KB of data
Larger data uses envelope encryption with a data key from GenerateDataKey.
-
Question 9. Which KMS API returns a plaintext data key and the same key encrypted under a KMS key?
Show answer
Answer: A. GenerateDataKey
The app encrypts data with the plaintext key, discards it, and stores the encrypted key with the data.
-
Question 10. In envelope encryption, what is stored alongside the encrypted data?
Show answer
Answer: C. The encrypted data key
To decrypt, the app calls KMS Decrypt on the encrypted data key, then uses the plaintext key locally.
-
Question 11. An app calls KMS Decrypt thousands of times per second and hits throttling. What reduces the number of calls?
Show answer
Answer: D. Cache data keys with the AWS Encryption SDK
Data key caching reuses keys within limits you set, reducing KMS requests and cost.
-
Question 12. What does a KMS encryption context provide?
Show answer
Answer: A. Extra authenticated data that must match on decrypt
The context is logged in CloudTrail and can be used in policy conditions, but it isn't secret.
-
Question 13. A database password must rotate automatically every 30 days. Which service fits BEST?
Show answer
Answer: D. AWS Secrets Manager
Secrets Manager has built-in rotation for RDS and other databases using a rotation function.
-
Question 14. An app needs dozens of configuration values, some encrypted, at low cost without rotation. What fits BEST?
Show answer
Answer: A. Parameter Store with SecureString for sensitive values
Standard parameters are free, and SecureString parameters are encrypted with KMS.
-
Question 15. Which Parameter Store API retrieves all parameters under /myapp/prod/ in one call?
Show answer
Answer: C. GetParametersByPath
Hierarchical names let an app load its configuration by path. Add WithDecryption for SecureString values.
-
Question 16. Objects must be encrypted before they leave the application, so AWS never sees plaintext. Which approach is required?
Show answer
Answer: B. Client-side encryption
Server-side options encrypt at rest in S3. Client-side encryption encrypts before upload.
-
Question 17. A bucket policy must deny uploads that aren't encrypted with SSE-KMS. Which condition key is checked?
Show answer
Answer: B. s3:x-amz-server-side-encryption
Deny PutObject when the header isn't aws:kms. Buckets now encrypt by default, but policies can require a specific type.
-
Question 18. A bucket policy must reject requests over plain HTTP. Which condition should be used?
Show answer
Answer: C. aws:SecureTransport set to false in a Deny statement
Denying when aws:SecureTransport is false forces TLS for all requests.
-
Question 19. A service in account A must access a DynamoDB table in account B. What is the usual approach?
Show answer
Answer: A. Assume a role in account B that trusts account A
The role's trust policy allows account A, and the caller uses sts:AssumeRole to get temporary credentials.
-
Question 20. Which STS API returns temporary credentials for assuming an IAM role?
Show answer
Answer: B. AssumeRole
AssumeRole returns an access key, secret key, and session token with an expiration.
-
Question 21. An API call fails with an encoded authorization failure message. Which API decodes it?
Show answer
Answer: B. sts:DecodeAuthorizationMessage
The decoded message shows which action and resource were denied and why.
-
Question 22. How can a developer test whether a role's policies allow s3:GetObject on a bucket without making the call?
Show answer
Answer: A. The IAM policy simulator
The policy simulator evaluates identity policies and can include resource policies and conditions.
-
Question 23. An explicit Deny and an Allow both match the same request. What happens?
Show answer
Answer: C. The request is denied
An explicit deny always overrides any allow in IAM policy evaluation.
-
Question 24. A GitHub Actions workflow must deploy to AWS without storing access keys as secrets. What should be used?
Show answer
Answer: D. An IAM OIDC identity provider and a role the workflow assumes
The workflow exchanges its OIDC token for short-lived role credentials with AssumeRoleWithWebIdentity.
-
Question 25. A Cognito user pool should require a second factor at sign-in. What should be enabled?
Show answer
Answer: B. Multi-factor authentication (MFA) in the user pool
User pools support TOTP and SMS MFA, optional or required.
-
Question 26. A company wants users to sign in to its app with Google or Facebook through Cognito. What should be configured?
Show answer
Answer: D. Social identity providers in the user pool, with the hosted UI
User pools federate social and SAML/OIDC providers and issue their own tokens to the app.
-
Question 27. Which token from a Cognito user pool should an app send to its API to authorize access to resources?
Show answer
Answer: B. The access token
Access tokens carry scopes and groups for authorization. ID tokens carry identity claims about the user.
-
Question 28. What is the refresh token used for in Cognito?
Show answer
Answer: D. Getting new ID and access tokens without signing in again
Access and ID tokens are short-lived. The refresh token obtains new ones until it expires.
-
Question 29. Users in the "admins" group of a Cognito user pool must get more AWS permissions through an identity pool. What should be configured?
Show answer
Answer: A. A role mapped to the group through role-based access control
Identity pools can choose the IAM role from the user's groups or token claims.
-
Question 30. An IAM policy lets each user read only their own folder in a bucket. Which feature makes one policy work for all users?
Show answer
Answer: D. Policy variables such as ${aws:username} in the resource ARN
Policy variables are replaced at evaluation time, so one policy can scope access per principal.
-
Question 31. With Cognito identity pools, how can users be restricted to their own prefix in S3?
Show answer
Answer: D. Use ${cognito-identity.amazonaws.com:sub} in the role policy
The identity ID variable scopes a shared role's permissions to each identity.
-
Question 32. Where should an application's TLS certificate for a custom API Gateway domain come from at no extra cost?
Show answer
Answer: A. AWS Certificate Manager (ACM)
ACM issues public certificates for free and renews them automatically. Edge-optimized APIs need the certificate in us-east-1.
-
Question 33. A developer logs full request objects in Lambda, including credit card numbers. What is the BEST fix?
Show answer
Answer: D. Remove or mask sensitive fields before logging
Logs are widely readable. Mask sensitive data in code, and consider CloudWatch Logs data protection policies.
-
Question 34. Which CloudWatch Logs feature can detect and mask sensitive data such as credit card numbers in log events?
Show answer
Answer: B. Data protection policies on the log group
Data protection policies use managed identifiers to find and mask sensitive data.
-
Question 35. A developer's application reads a secret from Secrets Manager on every request, adding latency and cost. What helps?
Show answer
Answer: B. Cache the secret in memory with a client-side caching library
Caching reduces API calls. Refresh the cache periodically to pick up rotated values.
-
Question 36. Which KMS key type should be used when an app needs full control over the key policy and rotation?
Show answer
Answer: A. A customer managed key
Customer managed keys let you edit key policies, enable rotation, and disable or schedule deletion.
-
Question 37. A Lambda function calls kms:Decrypt on a customer managed key and gets AccessDenied, though its role allows kms:Decrypt. What else must allow it?
Show answer
Answer: B. The KMS key policy
KMS key policies are the primary access control. They must allow the role directly or delegate to IAM.
-
Question 38. Which S3 encryption option records each use of the key in CloudTrail and lets the customer control the key policy?
Show answer
Answer: B. SSE-KMS with a customer managed key
SSE-KMS uses KMS keys, and every encrypt and decrypt call is logged.
-
Question 39. With SSE-C, what must the client do on every GET of an encrypted object?
Show answer
Answer: A. Provide the same encryption key in the request headers
S3 doesn't store SSE-C keys. HTTPS is required, and losing the key means losing the data.
-
Question 40. Many requests to SSE-KMS encrypted objects cause KMS throttling. What reduces KMS requests?
Show answer
Answer: C. Enable S3 Bucket Keys
Bucket Keys generate a bucket-level key from KMS, so S3 calls KMS far less often.
-
Question 41. An app on ECS Fargate must access S3. How should it get permissions?
Show answer
Answer: B. An ECS task role
The task role is for application calls. The execution role lets ECS pull images and write logs.
-
Question 42. An EC2 instance runs an app that calls DynamoDB. How should credentials be provided?
Show answer
Answer: C. An instance profile with an IAM role
The SDK gets temporary credentials from the instance metadata service automatically.
-
Question 43. Which instance metadata option helps protect role credentials from SSRF attacks on EC2?
Show answer
Answer: C. Requiring IMDSv2 session tokens
IMDSv2 requires a PUT request to get a session token, which blocks many SSRF attempts.
-
Question 44. A developer needs a Lambda function to use a secret, but only the function should be able to read it. What should be done?
Show answer
Answer: A. Allow GetSecretValue on that secret only in the function's role
Least privilege grants access to the specific secret ARN to the specific role that needs it.
-
Question 45. An API Gateway REST API should only be reachable from a specific VPC. What should be used?
Show answer
Answer: D. A private API with a resource policy for the VPC endpoint
Private APIs are reached through an interface VPC endpoint, and the resource policy restricts access.
-
Question 46. What does API Gateway's authorizer caching do for a Lambda authorizer?
Show answer
Answer: A. Reuses the returned policy for a token for a set TTL
Caching reduces authorizer invocations and latency. Keep the TTL short if permissions change often.
-
Question 47. What is the purpose of an IAM permissions boundary on roles that developers create?
Show answer
Answer: C. It caps the maximum permissions the role can ever have
Effective permissions are the intersection of the identity policy and the boundary.
-
Question 48. A developer wants to know which identity their CLI is using. Which command shows it?
Show answer
Answer: B. aws sts get-caller-identity
It returns the account, ARN, and user ID of the current credentials and needs no permissions.
-
Question 49. An app stores user-uploaded files. Which practice follows least privilege for the app's role?
Show answer
Answer: D. Allow only s3:PutObject and s3:GetObject on the app's prefix
Scope actions and resources to what the application actually needs.
-
Question 50. What does the iam:PassRole permission control?
Show answer
Answer: B. Whether a user can hand a role to a service, such as Lambda
Without PassRole restrictions, a user could attach a powerful role to a service they control.
-
Question 51. Which Lambda feature verifies that only trusted, signed code packages can be deployed?
Show answer
Answer: B. Code signing with AWS Signer
A code signing configuration rejects or warns on packages not signed by an allowed signing profile.
-
Question 52. A Lambda function URL must only be callable by IAM principals with permission. Which auth type should be set?
Show answer
Answer: D. AWS_IAM
With AWS_IAM, callers sign requests with SigV4 and need lambda:InvokeFunctionUrl permission.
AWS, Amazon Web Services, and AWS Certified are trademarks of Amazon.com, Inc. or its affiliates. These questions are original study material, not questions from the real exam.