AWS Certified Developer – Associate — Question 394
A company has an application that analyzes photographs. A developer is preparing the application for deployment to Amazon EC2 instances. The application's image analysis functions require a mix of GPU instances and CPU instances that run on Amazon Linux. The developer needs to add code to the application so that the functions can determine whether they are running on a GPU instance.
What should the functions do to obtain this information?
Answer options
- A. Call the DescribeInstances API operation and filter on the current instance ID. Examine the ElasticGpuAssociations property.
- B. Evaluate the GPU AVAILABLE environment variable.
- C. Call the DescribeElasticGpus API operation.
- D. Retrieve the instance type from the instance metadata.
Correct answer: D
Explanation
Querying the instance metadata (via the link-local address 169.254.169.254) allows the application to easily retrieve the instance type, from which it can determine if it is running on a GPU-enabled instance family. Making external API calls like DescribeInstances or DescribeElasticGpus is inefficient and requires extra IAM permissions, while there is no default GPU AVAILABLE environment variable provided by the Amazon Linux OS on EC2.