Topic 1 Question #1
A company has an AWS Lambda function that creates image thumbnails from larger images. The Lambda function needs read and write access to an Amazon S3 bucket in the same AWS account.Which solutions will provide the Lambda function this access? (Choose two.)
Answer: CD
This question tests core IAM and serverless security concepts from the SCS-C02 certification, specifically secure access configuration for Lambda to S3 in the same AWS account. The correct solutions follow AWS security best practices of using temporary, automatically managed credentials instead of long-term access keys, and least-privilege permission scoping. Both option C and D use Lambda execution roles, which are the AWS-recommended identity for Lambda functions to access other AWS services, and implement valid permission models for S3 access, either via identity-based policies attached to the role, or resource-based policies attached to the S3 bucket that grant access to the role principal.
Option Analysis:
A. Incorrect. Storing long-term IAM user access keys in Lambda environment variables violates AWS IAM security best practices tested in the SCS-C02 exam. This approach introduces unnecessary risk of credential exposure, requires manual credential rotation, and is redundant, as Lambda natively supports temporary credentials via execution roles.
B. Incorrect. EC2 key pairs are designed for SSH authentication to EC2 instances, not for authenticating requests to Amazon S3. S3 uses IAM identities for access control, so EC2 private keys have no valid use case for S3 access, making this option technically invalid.
C. Correct. Lambda execution roles are the standard, AWS-recommended mechanism for granting Lambda functions permissions to interact with other AWS services. Attaching an identity-based IAM policy with the required S3 read/write permissions directly to the Lambda execution role uses automatically rotated temporary credentials, follows least-privilege principles, and eliminates manual credential management, aligning with SCS-C02 secure IAM configuration requirements.
D. Correct. S3 supports resource-based bucket policies that can grant access to specific IAM principals, including Lambda execution roles. When you specify the Lambda execution role as the principal in the S3 bucket policy with the required S3 permissions, Lambda uses the execution role's temporary credentials to authenticate to S3. This is a valid, secure configuration, often used when organizations prefer to centralize S3 access controls in bucket policies, which is a core S3 security concept tested in the exam.
E. Incorrect. Security groups are stateful network firewalls that control traffic flow for resources, not IAM access control mechanisms for S3. S3 bucket policies cannot natively filter access based on security group IDs, and security groups do not grant IAM permissions to S3, so this option is invalid for the stated use case.
Key Concepts:
1. Lambda Execution Roles: IAM roles that Lambda assumes when running function code, providing temporary, automatically rotated credentials for accessing other AWS services. This eliminates the need for hardcoded long-term credentials, a core security best practice for serverless workloads.
2. S3 Access Permission Models: S3 access can be granted via two valid models: identity-based policies attached to IAM principals (roles, users, groups), or resource-based bucket policies attached directly to S3 buckets that specify the allowed principal and actions. Both models are valid for same-account access use cases.
3. IAM Credential Best Practice: Long-term IAM user access keys are not recommended for service-to-service access. Temporary credentials via IAM roles reduce the risk of credential leakage and eliminate manual rotation overhead, a core identity security concept tested in the SCS-C02 exam.
References:
AWS Lambda Execution Role, https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html
Using identity-based policies with Amazon S3, https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-iam-policies.html