AWS Cloud Practitioner · Security and Compliance · medium

An application running on an Amazon EC2 instance needs temporary read access to an Amazon S3 bucket without storing long-term access keys on the filesystem. What should the administrator attach to the EC2 instance?

Published · Last updated · checked before publication — how we verify questions

Options

  • ARoot account access keys stored inside an environment variable file
  • BAn IAM user group with an inline S3 policy attached to the subnet
  • CAn AWS Key Management Service asymmetric key pair stored on the EBS volume
  • DAn IAM role with least-privilege S3 read permissions via an instance profileCorrect answer

Answer: D. An IAM role with least-privilege S3 read permissions via an instance profile

An IAM role attached to the EC2 instance through an instance profile is the AWS-recommended way to give applications access to other AWS services. The instance profile is the container that passes the role to the instance. The AWS SDK and CLI automatically retrieve temporary security credentials from the instance metadata service, and these credentials are rotated automatically before they expire, so no long-term access keys are ever stored on disk. Attaching a policy that allows only S3 read actions follows the least-privilege principle, which is a core part of the AWS shared responsibility model on the customer side. The most common trap is choosing an option that sounds like identity management but cannot actually be attached to a compute resource, such as groups, or reaching for access keys because they are familiar. Remember that roles provide temporary credentials, while IAM users and root keys are long-term credentials.

Why the other options are wrong

  • A. Root account access keys stored inside an environment variable file — Root account access keys are long-term credentials with unrestricted access to the entire account. Storing them in a file on an instance violates least privilege and the best practice of avoiding root keys, and it also contradicts the requirement of not storing long-term keys on the filesystem.
  • B. An IAM user group with an inline S3 policy attached to the subnet — An IAM group is a collection of IAM users used to apply permissions to people, and it cannot be assumed by or attached to an EC2 instance or a subnet. Subnets are networking constructs in a VPC and have no role in IAM authorization.
  • C. An AWS Key Management Service asymmetric key pair stored on the EBS volume — AWS KMS keys are used to encrypt and decrypt data and to sign or verify, not to authenticate an instance to S3 or grant it IAM permissions. A key pair stored on an EBS volume would also be a stored secret and would not provide temporary S3 access.

All Security and Compliance questions and the topic overview →

AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.