DVA-C02 domain - 26% of the exam

Security

Security is 26% of the DVA-C02 exam. These are the objectives it covers, each with practice questions, with every answer explained.

The domain in numbers

94
Practice questions
8
Objectives
70
Medium
24
Hard

Where people go wrong

  • Confusing Cognito user pools and identity pools

    The wrong answers swap the two Cognito components. An identity pool is offered as the sign-in directory, although it stores no profiles or passwords, and a user pool token is offered as the credential for signing S3 or DynamoDB requests, although SigV4 needs AWS credentials. A user pool handles sign-up and sign-in and issues tokens. An identity pool exchanges an authenticated identity for temporary AWS credentials from an assumed IAM role.

    See it in a sample question
  • Keeping a stored access key where a role belongs

    The wrong answers keep a long-lived IAM user key in the design and only change where it sits: in environment variables, in the image, in Secrets Manager, in Parameter Store, or behind GetSessionToken. Each still leaves a static secret to store and rotate. The correct answers attach a role that the compute service hands to the SDK as temporary credentials: the Lambda execution role, the ECS task role or the EC2 instance profile. On ECS the execution role is a separate role for pulling images and writing logs.

    See it in a sample question
  • Giving one Cognito token another token's job

    The wrong answers hand each Cognito token the job of another. The ID token conveys identity claims such as name and email for the client, yet it is sent to an API that authorises on OAuth scopes; the access token carries those scopes and is the one a Cognito authoriser matches. The refresh token is presented to an API, although it only obtains new tokens from the token endpoint. An expired access token is treated as extendable, although only the refresh token renews the session without a new sign-in.

    See it in a sample question
  • Granting cross-account access from one side only

    The wrong answers supply only half of a cross-account grant. They leave out the bucket policy in the account that owns the bucket, or put the Allow on the owning side and skip the identity policy for the calling role. For a customer managed KMS key in another account, they grant kms:Decrypt in the caller's IAM policy alone, or add the key policy statement and skip the IAM policy. Both accounts must permit the call: the resource policy names the external principal, and the caller's identity policy allows the action.

    See it in a sample question
  • Expecting Parameter Store to rotate a credential

    The wrong answers expect Parameter Store to rotate a credential. A SecureString parameter is encrypted, so it looks like a managed secret, but it has no native scheduled rotation and the team would have to build the rotation logic. KMS key rotation is offered for the same job, although it replaces key material and never changes an application credential. Secrets Manager with a managed rotation function changes the database password on a schedule, while Parameter Store standard parameters suit non-sensitive settings such as feature toggles.

    See it in a sample question

Objectives in this domain

What to study

The official documents this domain's practice questions cite most.

Sample questions from this domain

Free sampleSecuritymedium

A developer is building a mobile application that must let end users sign up, sign in with email and password, and reset forgotten passwords, all managed by AWS without running a custom user database. After sign-in the application calls a backend REST API but does not yet need to call AWS service APIs directly. Which Amazon Cognito component should the developer use for this sign-up and sign-in requirement?

  • AAn Amazon Cognito identity pool, because it provides the hosted sign-up and sign-in screens and stores each user profile and password for the mobile application.
  • BAn AWS Identity and Access Management user for each application user, because IAM manages credentials and password resets centrally for any kind of human sign-in.
  • CAn Amazon Cognito identity pool federated to social providers, because it authenticates the email and password and then returns session tokens to the application.
  • DAn Amazon Cognito user pool, because it is a managed user directory that handles sign-up, sign-in, and password reset and issues tokens after authentication. Correct
Use an Amazon Cognito user pool as the managed directory that handles end-user sign-up, sign-in, and password reset and issues tokens. A Cognito user pool is a managed identity directory that authenticates end users through sign-up, sign-in, and password recovery flows and returns JWT ID and access tokens on success, whereas an identity pool only exchanges an existing identity for temporary AWS credentials.

Why A is wrong: An identity pool exchanges an existing identity for AWS credentials and does not store user profiles or passwords, so it cannot provide the sign-up and sign-in directory the application needs.

Why B is wrong: IAM users are meant for workforce and service access, not large fluctuating end-user populations, and AWS advises against creating an IAM user per application user for sign-in.

Why C is wrong: An identity pool federates already authenticated identities and never validates an email and password itself, so it cannot perform the primary sign-in that the application requires.

Why D is correct: A Cognito user pool is a fully managed directory that performs sign-up, sign-in, and password recovery and returns ID and access tokens, which matches the stated requirement exactly.

Free sampleSecuritymedium

A developer is writing a Lambda function that needs to write items to a DynamoDB table and publish to an Amazon SNS topic. The team wants the function to receive temporary, automatically rotated credentials scoped to only those two actions, with no secrets stored in the deployment package or environment variables. How should the developer provide these credentials to the function code?

  • AAssign an execution role to the function granting only the DynamoDB write and SNS publish actions, and let the SDK use the credentials Lambda injects at runtime. Correct
  • BGenerate an IAM user with the two permissions, create an access key, and place the key and secret in the function environment variables for the SDK to read.
  • CHave the function call AWS STS GetSessionToken at startup with a bundled access key so the returned short-lived token is used for the DynamoDB and SNS calls.
  • DStore an access key and secret in AWS Secrets Manager, fetch them on each invocation, and configure the SDK to sign the DynamoDB and SNS requests with them.
Grant a Lambda function least-privilege access through its execution role so the SDK uses injected temporary credentials with no stored secrets. Every Lambda function assumes its execution role, and the service injects temporary STS credentials for that role into the runtime; the SDK default provider chain reads them automatically, so a tightly scoped role policy delivers least privilege without any access key in code or configuration.

Why A is correct: The Lambda execution role supplies temporary STS credentials through the runtime environment, and the SDK picks them up automatically, so a least-privilege policy meets the requirement with no stored secrets.

Why B is wrong: Environment variable access keys are long-lived IAM user secrets that do not rotate and remain stored with the function, which fails the requirement for temporary credentials with no stored secrets.

Why C is wrong: GetSessionToken still depends on a long-lived IAM user key that must be bundled, so a stored secret remains and the approach contradicts the no-secrets requirement.

Why D is wrong: This still relies on a long-lived IAM user key that merely lives in Secrets Manager, adding cost and latency while leaving a static credential that the execution role would avoid entirely.

Free sampleSecuritymedium

A single-page application signs users in through an Amazon Cognito user pool and receives an ID token, an access token, and a refresh token. The access token expires after one hour, and the team does not want users forced to re-enter their password every hour. The application must obtain new, valid access tokens silently while the session remains active. Which token should the application use to obtain fresh tokens without prompting for credentials again?

  • AThe expired access token, replayed to the token endpoint so Cognito extends its expiry and returns the same token with a later expiration.
  • BThe ID token, sent to the user pool token endpoint, which validates the user identity and issues a replacement access token in return.
  • CA newly generated client secret hash, submitted on each request so the user pool reissues an access token for the still-active session.
  • DThe refresh token, exchanged with the user pool token endpoint to obtain new ID and access tokens without re-entering credentials. Correct
Use the Cognito refresh token to obtain new access and ID tokens silently before forcing a user to sign in again. Cognito issues three tokens. The access token and ID token are short lived. The refresh token has a longer configurable lifetime and is exchanged at the token endpoint for new access and ID tokens, letting the application keep the session alive without re-prompting for the password until the refresh token itself expires or is revoked.

Why A is wrong: An access token is immutable and cannot be extended; once expired it is rejected, and the token endpoint does not renew an existing access token in place.

Why B is wrong: The ID token conveys authenticated identity to the client and is not a grant; the token endpoint does not accept it to mint replacement access tokens.

Why C is wrong: A secret hash authenticates the app client during certain calls but does not by itself renew a user's tokens, and public SPA clients should not hold a client secret.

Why D is correct: The refresh token is designed for exactly this; presenting it to the token endpoint returns new ID and access tokens silently while it remains valid, avoiding a fresh sign-in.

Free sampleSecuritymedium

An application in AWS account A runs under an IAM role and must read objects from an S3 bucket owned by a different account, account B. The team can edit policies in both accounts. Which combination of policies grants the role in account A access to the bucket in account B following least privilege?

  • AAdd only a bucket policy in account B that allows the role principal, because a resource-based policy alone authorises a cross-account principal with no identity policy needed.
  • BGrant s3:GetObject to the role in account A through its identity policy, and add a bucket policy in account B that allows that role principal on the bucket. Correct
  • CAdd only an identity policy in account A allowing s3:GetObject on the bucket Amazon Resource Name, because the resource ARN reaches across the account boundary by itself.
  • DAttach the AWS managed AmazonS3FullAccess policy to the role in account A, because a managed policy automatically authorises buckets owned by other accounts.
Cross-account S3 access requires an identity policy in the caller account and a resource-based bucket policy in the owner account. For access across accounts, both the trusting and trusted sides must grant permission: the role in account A needs an identity-based Allow, and the bucket in account B needs a resource-based policy naming that role, so each account authorises its own resources.

Why A is wrong: A bucket policy alone seems sufficient, but the role in account A still needs an identity policy permitting s3:GetObject, since both accounts must allow the cross-account call.

Why B is correct: Cross-account S3 access needs both an identity policy in account A and a resource-based bucket policy in account B that names the role, because each account must permit its own side.

Why C is wrong: Naming the bucket ARN looks like enough, but account B never granted access, so without its bucket policy the cross-account request is denied.

Why D is wrong: Full access is both over-broad and one-sided, since account B must still allow the principal in its bucket policy, so the managed policy alone does not work.

Free sampleSecuritymedium

A developer stores an Amazon RDS database password used by a production application and must rotate it on a fixed schedule without writing or hosting any custom rotation logic. The team wants AWS to change the password on the database and update the stored value automatically. Which AWS service should the developer use to hold the credential?

  • AAWS Secrets Manager with rotation enabled, using the managed rotation function for the RDS engine to change the password on the database and store the new value. Correct
  • BAWS Systems Manager Parameter Store with a SecureString parameter, relying on the built-in scheduled rotation feature to change the RDS password and update the stored value.
  • CAWS Key Management Service with a customer managed key, scheduling annual key rotation so the database password is replaced each time the backing key material rotates.
  • DAmazon S3 with an encrypted object holding the password, enabling object lifecycle rules to overwrite the object on a schedule so the credential changes automatically.
Choose AWS Secrets Manager with managed rotation when a database credential must be rotated automatically with no custom rotation code to maintain. Secrets Manager offers managed rotation functions for supported database engines such as Amazon RDS, so it can change the password on the database itself and update the stored secret on a defined schedule, which Parameter Store, KMS, and S3 cannot do without custom code.

Why A is correct: Secrets Manager provides managed rotation for supported RDS engines, so it changes the password on the database and updates the secret on a schedule without the developer writing custom rotation logic.

Why B is wrong: Parameter Store encrypts a SecureString but has no native scheduled rotation that changes a database password, so the team would still have to build and host the rotation logic themselves.

Why C is wrong: KMS rotation replaces key material used to encrypt data and never changes an application credential, so it cannot rotate the RDS database password the application uses to connect.

Why D is wrong: S3 lifecycle rules transition or expire objects and never alter a database password, so storing the credential as an object provides no rotation against the RDS instance.

Other domains in this exam

See also the DVA-C02 cert hub, the study guide, and the cheat sheet.

Examworthy is not affiliated with or endorsed by Amazon Web Services. Original, blueprint-aligned practice material only.