A social media app uses the AWS SDK for JavaScript in the browser to obtain user credentials from AWS STS. App assets are stored in an S3 bucket and delivered through a CloudFront distribution with the S3 bucket as the origin. Currently, the role credentials the app assumes are stored in plaintext inside a JSON file in the frontend code. The developer must remove hardcoded credentials while still allowing the app to obtain credentials. Which approach satisfies this requirement?
Choose an answer
Tap an option to check your answer.
Correct answer: Add a Lambda@Edge function to the CloudFront distribution and invoke it on viewer requests. Grant the function's execution role permission to call AWS STS. Move all SDK calls from the frontend into the Lambda@Edge function..
Why this is the answer
The correct option uses Lambda@Edge to securely obtain STS credentials. Lambda@Edge functions execute closer to the user, reducing latency, and can interact with AWS services like STS using an IAM role, eliminating the need for hardcoded credentials in the frontend. This approach centralizes credential management and enhances security. Incorrect options: CloudFront Functions are lightweight JavaScript functions that run at CloudFront edge locations, but they cannot make network calls to AWS services like STS. Storing credentials directly within a Lambda@Edge or CloudFront Function, even if not hardcoded in the frontend, still represents a security risk by embedding sensitive information directly into the function code. The best practice is to use the function's execution role for permissions.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed