DVA-C02 - Security (26% of the exam) - Section 2.2

Grant least-privilege application access using IAM roles and AWS STS temporary credentials rather than long-lived access keys.

Grant least-privilege application access by attaching IAM roles to compute resources rather than embedding long-lived access keys in code. Use AWS STS AssumeRole to obtain temporary security credentials scoped to the minimum permissions required for cross-account or cross-service access.

IAM rolesAWS STSAssumeRoleTemporary security credentials

Practice question for this objective

Free sampleSecuritymedium

An application running on an Amazon EC2 instance in account A must read objects from an Amazon S3 bucket owned by account B. The security team forbids long-lived access keys and wants the application to obtain temporary credentials scoped only to that bucket. Account B has created an IAM role whose trust policy allows account A to assume it. How should the application obtain credentials to call S3 in account B?

  • ACreate an IAM user in account B, generate an access key pair, and store the key and secret in the application configuration so the SDK signs S3 requests directly.
  • BAdd the account B bucket to a resource policy on the account A instance role so the SDK automatically uses the instance credentials to reach the cross-account bucket.
  • CEnable cross-account access by attaching the account B role directly as a second instance profile so the SDK presents both roles when it calls the S3 bucket.
  • DCall AWS STS AssumeRole with the account B role ARN using the instance role credentials, then use the returned temporary credentials to sign the S3 requests. Correct
Use AWS STS AssumeRole to obtain temporary scoped credentials for a trusted role in another account instead of long-lived keys. Cross-account access works when the target account role trusts the caller and the caller invokes STS AssumeRole; STS issues temporary credentials for that role, which the SDK then uses to sign requests against resources in the other account with least privilege and automatic expiry.

Why A is wrong: An IAM user access key pair is a long-lived static credential that does not rotate and must be stored, which directly breaks the requirement to avoid long-lived keys.

Why B is wrong: An identity policy in account A cannot by itself authorise calls into account B, and the instance credentials are scoped to account A, so the cross-account read still fails without assuming the role.

Why C is wrong: An EC2 instance can have only one instance profile and roles cannot be stacked that way, so this is not a valid mechanism for reaching the other account at all.

Why D is correct: AssumeRole returns short-lived credentials for the trusted account B role, and signing S3 calls with them gives scoped cross-account access with no stored static keys at all.

See more DVA-C02 practice questions, answers explained.

Exam traps in Security

Answers that look right on this material and are not. Each one is a distractor from a different question in the DVA-C02 bank for this domain.

  • Store an IAM user's access key id and secret in AWS Systems Manager Parameter Store and have each workload fetch them at startup with GetParameter.

    Why it is wrong: This is tempting because Parameter Store secures the value, but it still relies on long-lived user keys that are not automatically rotated, breaking the requirement.

  • An Amazon Cognito user pool app client with the OIDC provider enabled so the device receives user pool ID and access tokens.

    Why it is wrong: A user pool issues sign-in tokens, not AWS credentials; it is not needed when the OIDC token is exchanged directly through an identity pool for SDK calls.

  • Move the access key id and secret access key out of the image into encrypted ECS task environment variables, so the long lived keys are protected at rest but still read by the application.

    Why it is wrong: Encrypting the variables hides the keys at rest but they remain long lived static credentials that the application reads, so the core problem of embedded long lived keys is not solved.

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