Tüm alıştırma soruları

782 soru

Soru 1Soru

A healthcare startup collects continuous heart rate data from thousands of wearable medical patches. The patches stream telemetry data to an Amazon Kinesis Data Stream that has 1212 shards. The stream is experiencing periodic `ProvisionedThroughputExceededException` errors during peak hours, and analysis reveals that a single shard is receiving over 80%80\% of the traffic because the developer chose `device_manufacturer` as the partition key. Which of the following changes to the partition key should the developer implement to resolve the throttling and distribute the load evenly across all shards?

Cevabı ve açıklamayı göster

Cevap: Change the partition key to a high-entropy value such as a combination of device_id and the telemetry timestamp.

Cevap

Change the partition key to a high-entropy value such as a combination of device_id and the telemetry timestamp.
The correct answer resolves partition hotness by switching to a key with high entropy. By combining the unique device identifier with the event timestamp, the developer ensures a uniform distribution of hashed keys across the 1212 shards, mitigating ProvisionedThroughputExceededException errors.

Adım Adım Çözüm

1
Analyze the distribution of records across the Kinesis shards.
Identify that the current key (device_manufacturer) has low entropy, resulting in a hot shard receiving 80%80\% of the data stream traffic.
Uneven write distribution is the primary cause of ProvisionedThroughputExceededException errors when overall capacity is sufficient but partition key cardinality is low.
2
Select a partition key strategy with high cardinality.
Choose a key combining device_id and the telemetry timestamp, which provides high entropy.
A high-entropy partition key ensures that the MD5 hashing algorithm evenly hashes payloads across the 1212 available shards, maximizing write throughput.

Anahtar Kavram

Selecting high-entropy partition keys to prevent hot shards in Kinesis Data Streams.

Alternatif Yöntem

Using an explicit hash key (ExplicitHashKey) in the PutRecord/PutRecords API calls to directly assign records to specific shards.
Tahmini Süre:1m 30s
Soru 2Soru

A developer is deploying a Java application to an Amazon ECS cluster running on AWS Fargate. The application uses the AWS SDK for Java to write logs to an Amazon CloudWatch Logs group. The ECS task is configured with an IAM task role that has the necessary permissions to write to CloudWatch. However, the container definition also contains the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, which contain temporary credentials used during a previous CI/CD test run. When the application runs, it fails to write logs and throws an ExpiredTokenException. Which action should the developer take to resolve this issue?

Cevabı ve açıklamayı göster

Cevap: Remove the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables from the ECS container definition.

Cevap

Remove the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables from the ECS container definition.
The correct answer is to remove the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables from the ECS container definition. In the AWS SDK default credential provider chain, environment variables have higher precedence than ECS container credentials. If these environment variables are set (even with expired credentials), the SDK will attempt to use them, resulting in an ExpiredTokenException. Removing them allows the SDK chain to fall back to the ECS container credentials provider, which retrieves the credentials associated with the ECS task role.

Adım Adım Çözüm

1
Analyze the AWS SDK default credential provider chain precedence.
The SDK checks environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) before it checks the container credentials provider.
Understanding the order of precedence in the SDK is necessary to identify why the expired credentials in the environment variables are being selected over the valid task role.
2
Identify the root cause of the ExpiredTokenException.
The environment variables contain expired temporary credentials, which block the SDK from reaching the container credentials provider.
Since the environment variables are set, the SDK uses them and fails immediately rather than falling back to the task role credentials.
3
Determine the resolution method.
Remove the expired credential environment variables from the container configuration.
By removing these environment variables, the default credential provider chain will successfully fall back to the ECS task role credentials retrieved from the container metadata URI.

Anahtar Kavram

AWS SDK Default Credential Provider Chain Precedence
Soru 3Soru

A developer is migrating a backend AWS Lambda function from a Lambda custom (non-proxy) integration to a Lambda proxy integration on an Amazon API Gateway REST API. Under the custom integration, the Lambda function received a pre-mapped JSON payload containing query parameters and headers, and it returned a simple JSON object:

`{ "status": "success", "data": { "userId": 101 } }`

After configuring the API Gateway to use Lambda Proxy Integration, clients receive a 502 Bad Gateway error on all API requests. Additionally, the Lambda function execution logs show errors indicating that the incoming event format is unexpected.

Which of the following modifications must the developer make to resolve these errors?

Cevabı ve açıklamayı göster

Cevap: Modify the Lambda function to parse the incoming request body from the event.body property, and update the function's return statement to return a JSON object with statusCode and a stringified JSON body.

Cevap

Modify the Lambda function to parse the incoming request body from the event.body property, and update the function's return statement to return a JSON object with statusCode and a stringified JSON body.
The correct option is to modify the Lambda function to parse the incoming request body from the event.body property and return a JSON object with statusCode and a stringified JSON body. This is because Lambda proxy integration passes the entire HTTP request wrapper where the request body is stringified, and requires the response to conform strictly to a response format containing statusCode and body fields.

Adım Adım Çözüm

1
Understand the difference between Lambda custom integration and Lambda proxy integration input events.
In custom integrations, API Gateway maps parameters and payload before invoking Lambda. In proxy integrations, API Gateway passes the raw request inside an event object, where the body is a stringified JSON in the event.body property.
This explains why the Lambda function logged unexpected event format errors after the integration type was changed to proxy.
2
Understand the difference in response expectations for Lambda proxy integration.
Lambda proxy integration requires the backend function to return a specific JSON response containing at least statusCode (an integer) and body (a string representing the response payload).
If the backend returns a custom JSON object or a raw string instead of this expected format, API Gateway cannot parse it and yields a 502 Bad Gateway error.
3
Implement code changes in the Lambda function to parse the input and format the output correctly.
The function parses event.body for incoming parameters and returns an object such as { statusCode: 200, body: JSON.stringify({ status: 'success', data: { userId: 101 } }) }.
This matches the input and output requirements for Lambda proxy integration and resolves both the execution logs error and the 502 Bad Gateway response.

Anahtar Kavram

The primary difference in payload structure and response contract between API Gateway Lambda Proxy and Lambda Custom (non-proxy) integrations.
Tahmini Süre:2m 0s
Soru 4Soru

A developer is building a document processing application that must secure sensitive PDF documents before uploading them to a third-party storage service. The average size of each document is 15 MB15\text{ MB}. To meet security requirements, the developer must encrypt the documents client-side using an AWS KMS Customer Managed Key (CMK) while minimizing latency and network overhead. Which approach should the developer implement to encrypt these documents securely and efficiently?

Cevabı ve açıklamayı göster

Cevap: Call the KMS GenerateDataKey API with the CMK to obtain a plaintext data key and an encrypted data key. Encrypt the document locally using the plaintext data key, delete the plaintext key from memory, and store the encrypted data key alongside the encrypted document.

Cevap

Call the KMS GenerateDataKey API with the CMK to obtain a plaintext data key and an encrypted data key. Encrypt the document locally using the plaintext data key, delete the plaintext key from memory, and store the encrypted data key alongside the encrypted document.
The correct approach is to call the KMS GenerateDataKey API to obtain both a plaintext data key and an encrypted data key. The plaintext key is used to encrypt the document locally, and is then discarded from memory. The encrypted data key is stored alongside the encrypted document so that it can be decrypted later using the Decrypt API. This utilizes envelope encryption, which is necessary because the documents exceed the size limit of the direct KMS Encrypt API.

Adım Adım Çözüm

1
Evaluate the file size (15 MB15\text{ MB}) against AWS KMS direct encryption payload limits.
Since the direct KMS Encrypt API has a strict limit of 4 KB4\text{ KB}, direct encryption is not possible. Envelope encryption must be used.
To select the appropriate KMS workflow based on payload size constraints.
2
Determine the most efficient API call for obtaining data keys for client-side envelope encryption.
GenerateDataKey returns both the plaintext key (for local encryption) and the encrypted key (for storage) in a single network request.
To minimize latency and network calls during document upload processing.
3
Validate security best practices for handling the generated plaintext data key.
Once the document is encrypted locally with the plaintext key, the plaintext key is deleted from application memory, and the encrypted key is packaged with the ciphertext.
To ensure the plaintext key is not exposed or leaked.

Anahtar Kavram

Client-side envelope encryption workflow using AWS KMS GenerateDataKey API
Tahmini Süre:2m 0s
Soru 5Soru

A company is developing a desktop-based administration client that must allow authenticated internal users to upload system logs directly to a secure Amazon S3 bucket. The developer wants to manage user registration, sign-in, and password recovery natively within the client, while ensuring that the desktop application receives temporary, limited-privilege AWS credentials to perform the S3 uploads without embedding long-term AWS access keys.

Which architecture should the developer implement to meet these requirements?

Cevabı ve açıklamayı göster

Cevap: Use an Amazon Cognito User Pool to manage user authentication, and use an Amazon Cognito Identity Pool to exchange the User Pool identity tokens for temporary AWS IAM credentials that authorize writing to the Amazon S3 bucket.

Cevap

Use an Amazon Cognito User Pool to manage user authentication, and use an Amazon Cognito Identity Pool to exchange the User Pool identity tokens for temporary AWS IAM credentials that authorize writing to the Amazon S3 bucket.
The correct architecture uses a Cognito User Pool to authenticate the desktop client users (handling registration, login, etc.) and generate JWT identity tokens. The client then passes this token to a Cognito Identity Pool, which validates it and returns temporary, restricted AWS IAM credentials. The desktop client can then use these credentials to upload files directly to S3.

Adım Adım Çözüm

1
Configure an Amazon Cognito User Pool.
Creates a user directory that handles user sign-up, sign-in, password reset, and produces JWT tokens (ID, Access, and Refresh tokens) upon successful authentication.
Required to handle native user authentication and directory management.
2
Configure an Amazon Cognito Identity Pool (Federated Identities) and associate it with the User Pool as an identity provider.
Allows the application to exchange the ID token issued by the User Pool for temporary AWS credentials.
Provides the mechanism to federate Cognito User Pool users into AWS IAM roles.
3
Define an IAM Role for authenticated users with a trust policy for Cognito Identity Pools and a permissions policy allowing S3 put-object actions.
Ensures that users mapped by the Identity Pool receive credentials scoped strictly to write to the designated S3 bucket.
Enforces least-privilege access for the S3 bucket operations.

Anahtar Kavram

Amazon Cognito User Pools vs Identity Pools
Soru 6Soru

A developer is deploying a containerized application to Amazon Elastic Container Service (Amazon ECS) on AWS Fargate. The application needs to retrieve data from an Amazon DynamoDB table. The developer creates an IAM role named AppDynamoDBRole with a permissions policy that allows dynamodb:GetItem and dynamodb:Query operations, and configures the task definition's taskRoleArn parameter to point to this role. The trust policy for AppDynamoDBRole is configured as follows:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ecs.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}

When the containerized application runs, it fails to authenticate with DynamoDB, and the container logs show an authorization error when attempting to assume the task role. Which of the following modifications to the configuration will resolve this issue?

Cevabı ve açıklamayı göster

Cevap: Change the Service value under the Principal block in the trust policy from ecs.amazonaws.com to ecs-tasks.amazonaws.com.

Cevap

Change the Service value under the Principal block in the trust policy from ecs.amazonaws.com to ecs-tasks.amazonaws.com.
The correct option is changing the Service principal to ecs-tasks.amazonaws.com. When configuring an ECS task definition, the taskRoleArn parameter allows containerized applications to make authorized AWS API calls. To enable this, the ECS agent must assume the designated IAM role. The trust relationship policy of the IAM role must explicitly allow the ECS tasks service principal (ecs-tasks.amazonaws.com) to perform the sts:AssumeRole action.

Adım Adım Çözüm

1
Examine the trust policy of the IAM role to determine who is permitted to assume it.
The current trust policy permits the ecs.amazonaws.com service principal to assume the role.
This determines if the correct AWS service or identity has been granted trust.
2
Identify the service principal responsible for launching and executing ECS tasks.
ECS tasks run under the ecs-tasks.amazonaws.com service principal, whereas service-level control plane operations run under ecs.amazonaws.com.
The correct service principal must match the specific entity requesting the sts:AssumeRole action.
3
Update the trust policy to authorize the ecs-tasks.amazonaws.com service principal.
The ECS agent can now successfully assume the AppDynamoDBRole on behalf of the containerized application.
This establishes a valid trust relationship, resolving the authorization error.

Anahtar Kavram

IAM trust policies for Amazon ECS tasks must trust the ecs-tasks.amazonaws.com service principal to allow the ECS agent to assume the task role on behalf of containers.
Tahmini Süre:2m 0s
Soru 7Soru

A developer is testing a Go microservice locally. The microservice uses the AWS SDK for Go v2 to retrieve parameter configurations from Amazon Systems Manager (SSM) Parameter Store using the following initialization code:

go
// WARNING: Do not hardcode credentials in production.
// This code relies on the default credential provider chain.
cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
}
client := ssm.NewFromConfig(cfg)

The application runs inside a local Docker container as a non-root user `appuser` (home directory `/home/appuser`). To supply AWS credentials to the container, the developer ran the container with the environment variable `AWS_PROFILE=dev-profile` and mounted the host's `~/.aws/credentials` file to `/home/appuser/.aws/credentials`.

On the host machine, the AWS CLI configurations are:

`~/.aws/config`:
ini
[profile dev-profile]
role_arn = arn:aws:iam::123456789012:role/DevDeveloperRole
source_profile = base-profile

`~/.aws/credentials` (using placeholder credentials for security):
ini
[base-profile]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

When the application runs in the container, it fails with the error `operation error SSM: GetParameter, failed to resolve credentials`. However, running `aws ssm get-parameter --name /app/config --profile dev-profile` directly on the host machine succeeds.

Which of the following is the root cause of this credential resolution failure?

Cevabı ve açıklamayı göster

Cevap: The `dev-profile` profile relies on a role assumption chain defined in the host's `~/.aws/config` file, which was not mounted into the container, preventing the SDK from locating the profile configuration.

Cevap

The credential resolution failure is caused by the missing configuration file inside the container. The profile `dev-profile` is defined in the host's `~/.aws/config` file (which references `role_arn` and `source_profile`). Because only the `~/.aws/credentials` file was mounted to the container, the AWS SDK inside the container could not locate the definition for `dev-profile` and therefore could not resolve the credentials.
The correct answer points out that the profile configuration (`dev-profile`) specifying role-chaining parameters (`role_arn` and `source_profile`) resides in the host's `~/.aws/config` file. If only the `~/.aws/credentials` file is mounted to the container, the SDK cannot resolve the `dev-profile` name to its role assumption configuration, causing credential resolution to fail.

Adım Adım Çözüm

1
Analyze how the AWS SDK for Go v2 resolves credentials.
The SDK looks at environment variables like `AWS_PROFILE` and then checks the shared configuration file (`~/.aws/config`) and credentials file (`~/.aws/credentials`) in the user's home directory.
Understanding the credential resolution chain helps pinpoint where the lookup breaks.
2
Examine the volume mounts defined for the Docker container.
Only `~/.aws/credentials` is mounted to `/home/appuser/.aws/credentials`. The `~/.aws/config` file is not mounted.
This shows that the containerized SDK only has access to the credentials file and not the configuration file.
3
Evaluate the profile configuration structure.
The target profile `dev-profile` is configured in `~/.aws/config` using `role_arn` and `source_profile`. The credentials for `base-profile` are in `~/.aws/credentials`.
Because the SDK in the container lacks the config file, it cannot read the definition for `dev-profile`, preventing it from understanding that it must assume a role using the `base-profile` credentials.

Anahtar Kavram

Credential File vs Configuration File in AWS SDK Profile Resolution

Alternatif Yöntem

Instead of mounting individual files, the developer can mount the entire `~/.aws` directory to `/home/appuser/.aws` in the container. This ensures both `config` and `credentials` files are accessible, permitting the SDK to chain profiles successfully.
Tahmini Süre:2m 30s
Soru 8Soru

A developer is managing an AWS CloudFormation stack for a production application. After a failed update to an Amazon RDS database instance, the stack is stuck in the UPDATE_ROLLBACK_FAILED state. The developer discovers that another team member had previously made manual, out-of-band configuration changes to the database instance directly in the AWS Console. How should the developer resolve this situation and successfully perform the stack update?

Cevabı ve açıklamayı göster

Cevap: Identify the manual changes, use the CloudFormation console or CLI to run the ContinueUpdateRollback action to return the stack to a stable state, update the template to reflect the actual resource configuration, and then perform the update.

Cevap

To resolve an UPDATE_ROLLBACK_FAILED state caused by out-of-band changes, the developer must run the ContinueUpdateRollback action to stabilize the stack, align the template with the actual resource state, and then perform the update.
Executing the ContinueUpdateRollback action is the standard AWS procedure to recover a stack from the UPDATE_ROLLBACK_FAILED state. Once the stack is stabilized to UPDATE_ROLLBACK_COMPLETE, the developer can align the template with the actual drifted state of the database and safely run the update.

Adım Adım Çözüm

1
Identify manual configuration changes that caused the rollback failure.
Find the drift or discrepancy between the template and the actual resource state.
Manual out-of-band changes prevent CloudFormation from rolling back resources to their expected state.
2
Execute the ContinueUpdateRollback operation via the CLI or AWS Console.
The stack transitions from UPDATE_ROLLBACK_FAILED to UPDATE_ROLLBACK_COMPLETE.
This action bypasses or retries the failed rollback step, bringing the stack back to a stable state where updates are permitted.
3
Align the template with the actual configuration of the resources and redeploy.
The stack is successfully updated with no configuration drift.
Ensuring the template matches the real-world state prevents future update or rollback failures.

Anahtar Kavram

Resolving CloudFormation stack update rollback failures caused by resource drift
Tahmini Süre:1m 30s
Soru 9Soru

A developer is troubleshooting an authorization issue with a REST API in Amazon API Gateway. The API uses a custom Lambda authorizer with caching enabled, and the cache key is set to the Authorization header. When a client sends a request to GET /orders/101 with a valid token, the request succeeds. However, when the same client immediately sends a request to GET /orders/202 using the same token, the client receives a 403 Forbidden error with the message 'User is not authorized to access this resource'. The developer verifies that the client has valid permissions for both order resources. What is the root cause of this authorization failure, and how should it be resolved?

Cevabı ve açıklamayı göster

Cevap: The Lambda authorizer returned a resource ARN specific to the first request's path, which was cached. Subsequent requests for different paths with the same token reuse the cached policy and are denied. To resolve this, configure the Lambda authorizer to return a wildcard resource ARN covering all paths, or disable caching.

Cevap

The Lambda authorizer returned a resource ARN specific to the first request's path, which was cached. Subsequent requests for different paths with the same token reuse the cached policy and are denied. To resolve this, configure the Lambda authorizer to return a wildcard resource ARN covering all paths, or disable caching.
When caching is enabled, API Gateway caches the policy returned by the Lambda authorizer using the cache key (the token). If the policy specifies a resource-specific ARN (like the path of the first request), any subsequent requests to a different path with the same token will use the cached policy and fail with a 403 Forbidden error because that path is not allowed in the policy. Returning a wildcard ARN or disabling caching resolves this issue.

Adım Adım Çözüm

1
Analyze the symptoms of the authorization failure where the first request succeeds but the subsequent request with the same token to a different path fails with a 403 Forbidden error.
Identify that the Lambda authorizer has caching enabled with the Authorization header as the cache key.
This helps narrow down the problem to how API Gateway caches and evaluates the IAM policy returned by the Lambda authorizer.
2
Examine how API Gateway caches policies based on the custom Lambda authorizer configuration.
The authorizer returns a policy containing the resource ARN for the specific path of the first request (/orders/101), which is then cached by API Gateway for that authorization token.
API Gateway uses the cached policy for all subsequent requests containing the same token during the TTL period, without invoking the Lambda function again.
3
Determine how the cached policy affects the second request (GET /orders/202).
Because the cached policy only allows access to the resource ARN for /orders/101, API Gateway denies access to /orders/202 and returns a 403 Forbidden error.
This confirms that the narrow resource scope in the cached policy is the root cause of the authorization failure.
4
Formulate the resolution to fix the authorization issue.
Modify the Lambda authorizer code to return a wildcard resource ARN (e.g., /orders/*) so that the cached policy permits access to all relevant paths, or disable caching if granular per-path verification is required on every request.
This ensures that either the cached policy is broad enough to cover all client requests or that the authorizer runs on every request to generate a precise policy.

Anahtar Kavram

API Gateway custom Lambda authorizer policy caching and resource ARN validation.
Soru 10Soru

A developer is troubleshooting an application named PixelStream that uploads high-resolution images. The application stores metadata in an Amazon DynamoDB table where the partition key is set to the upload date (formatted as YYYY-MM-DD). During peak hours, the application frequently encounters ProvisionedThroughputExceededException errors even though the table's overall consumed throughput is well below the provisioned write capacity limit. What is the most effective way to resolve this throughput issue?

Cevabı ve açıklamayı göster

Cevap: Redesign the partition key schema to use a more granular attribute, such as a unique Image ID, to distribute write requests evenly across partitions.

Cevap

Redesign the partition key schema to use a more granular attribute, such as a unique Image ID, to distribute write requests evenly across partitions.
Redesigning the partition key schema to use a high-cardinality attribute, such as a unique Image ID, spreads write operations across multiple physical partitions, preventing any single partition from exceeding its individual throughput limits.

Adım Adım Çözüm

1
Analyze the table schema and error behavior.
Identify that the partition key is the upload date, which has very low cardinality and results in all writes for a given day hitting the same partition.
This confirms that the ProvisionedThroughputExceededException is caused by a hot partition key rather than exceeding the table's total capacity.
2
Determine the solution for even data distribution.
Select a partition key with high cardinality, such as a unique Image ID.
High-cardinality keys distribute write requests evenly across physical partitions, resolving partition-level write limits.

Anahtar Kavram

Selecting a partition key with high cardinality to distribute write requests evenly and avoid hot partition bottlenecks.
Tahmini Süre:1m 0s
Soru 11Soru

A developer is troubleshooting a CI/CD pipeline in AWS CodePipeline that deploys infrastructure using AWS CloudFormation. During the initial deployment of a new stack, the deployment stage failed due to an invalid parameter value, leaving the CloudFormation stack in the ROLLBACK_COMPLETE state. After correcting the parameter value in the template and pushing the fix to the source repository, the pipeline runs again but the CloudFormation deploy stage fails immediately, indicating that the stack cannot be updated. Which action must the developer perform to successfully deploy the stack through the pipeline?

Cevabı ve açıklamayı göster

Cevap: Delete the existing CloudFormation stack manually or via the AWS CLI, and then trigger the pipeline again.

Cevap

Delete the existing CloudFormation stack manually or via the AWS CLI, and then trigger the pipeline again.
The correct answer is to delete the existing CloudFormation stack manually or via the AWS CLI, and then trigger the pipeline again. When a CloudFormation stack fails during its initial creation, it goes into the ROLLBACK_COMPLETE state. CloudFormation does not allow updates to a stack that has never been successfully created. Therefore, to proceed, the developer must delete the failed stack, which removes it, allowing the pipeline's subsequent run to perform a successful create operation.

Adım Adım Çözüm

1
Identify the current status of the CloudFormation stack from the AWS CloudFormation console or CLI.
The stack is found to be in the ROLLBACK_COMPLETE state due to a failed initial creation.
Understanding the exact failure state is necessary because different rollback states (e.g., ROLLBACK_COMPLETE vs UPDATE_ROLLBACK_COMPLETE) have different recovery paths.
2
Determine the supported actions for a stack in the ROLLBACK_COMPLETE state.
A stack in ROLLBACK_COMPLETE cannot be updated; it can only be deleted.
This determines that attempting to push template updates through the pipeline directly will continue to fail, as the pipeline will attempt to perform a stack update action.
3
Delete the failed stack and re-run the pipeline.
The pipeline runs successfully and creates the stack from scratch with the corrected template.
Deleting the stack removes the blocked state, allowing the pipeline's CloudFormation action to execute a clean stack creation.

Anahtar Kavram

Handling CloudFormation initial creation failures and the ROLLBACK_COMPLETE state in CI/CD pipelines.
Soru 12Soru

An application running inside an Amazon ECS task on AWS Fargate in Account A (111111111111111111111111) needs to write objects to an Amazon S3 bucket located in Account B (222222222222222222222222). The developer wants the application to temporarily assume an IAM role named CrossAccountS3Writer in Account B. The ECS task definition is configured with an ECS Task Role named ECSTaskRole.

The trust policy of the CrossAccountS3Writer role in Account B contains the following statement:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111111111111:role/ECSTaskRole"
},
"Action": "sts:AssumeRole"
}
]
}

When the application execution code attempts to call the sts:AssumeRole API, it fails with an AccessDenied error. How should the developer resolve this authorization failure?

Cevabı ve açıklamayı göster

Cevap: Attach an identity-based policy to ECSTaskRole in Account A that grants the sts:AssumeRole permission targeting the Amazon Resource Name (ARN) of the CrossAccountS3Writer role in Account B.

Cevap

Attach an identity-based policy to ECSTaskRole in Account A that grants the sts:AssumeRole permission targeting the Amazon Resource Name (ARN) of the CrossAccountS3Writer role in Account B.
For cross-account role assumption, AWS IAM requires a bilateral handshake: the trusting role (in Account B) must specify the external principal in its trust policy, and the trusted principal (in Account A) must have an identity-based policy that grants permission to call 'sts:AssumeRole' on the target role's ARN. Since the trust policy in Account B is already correctly configured, adding the 'sts:AssumeRole' permission to the ECSTaskRole in Account A completes this handshake and resolves the AccessDenied error.

Adım Adım Çözüm

1
Analyze the error context and the resource policy configuration.
The application inside the ECS task is trying to assume the CrossAccountS3Writer role in Account B, but the AssumeRole request is denied.
Establishing cross-account delegation requires explicit authorization in both accounts: a trust relationship in the receiving account (Account B) and an identity-based grant in the initiating account (Account A).
2
Examine the trust policy of the target role (CrossAccountS3Writer) in Account B.
The trust policy correctly allows the identity 'arn:aws:iam::111111111111:role/ECSTaskRole' to call 'sts:AssumeRole'.
This confirms that Account B is configured properly to trust the ECS Task Role from Account A.
3
Determine the missing permission in the initiating account (Account A).
The ECS Task Role (ECSTaskRole) itself does not have a policy permitting it to invoke 'sts:AssumeRole' on the destination role.
IAM identities require explicit permission to call 'sts:AssumeRole' on a resource in another account, even if that resource trusts them.
4
Select the correct action to resolve the authorization failure.
Add an identity-based policy to 'ECSTaskRole' with an 'Allow' effect on the 'sts:AssumeRole' action, specifying the ARN of the target role in Account B as the resource.
This satisfies the cross-account delegation requirements by authorizing the ECS Task Role to perform the assume-role request.

Anahtar Kavram

Cross-Account IAM Delegation and ECS Task Roles
Soru 13Soru

A developer has configured an AWS Lambda function written in Python to process events from an Amazon SQS queue and write the results to an Amazon DynamoDB table. Active tracing is enabled on both the SQS queue and the Lambda function. When reviewing the AWS X-Ray console, the developer observes that the service map shows the SQS queue and the Lambda function, but the downstream calls to DynamoDB are missing from the trace. Which action should the developer take to trace the downstream DynamoDB calls in AWS X-Ray?

Cevabı ve açıklamayı göster

Cevap: Import the AWS X-Ray SDK in the Lambda function code and invoke the patch_all() function before initializing the Boto3 client.

Cevap

Import the AWS X-Ray SDK in the Lambda function code and invoke the patch_all() function before initializing the Boto3 client.
The correct answer is to import the AWS X-Ray SDK and run the patch_all() function. When running a Python Lambda function with active tracing enabled, downstream SDK calls are not traced by default unless the Boto3 library is instrumented. Patching the library automatically wraps Boto3 clients so that downstream calls (like DynamoDB operations) are recorded as subsegments in the X-Ray trace.

Adım Adım Çözüm

1
Identify that the Lambda function has active tracing enabled but downstream calls to DynamoDB are not being recorded.
The Lambda function segment is present, but DynamoDB subsegments are missing.
Active tracing on Lambda only traces the Lambda execution itself, not downstream SDK calls by default.
2
Instrument the Boto3 library using the AWS X-Ray SDK for Python.
The Boto3 clients will automatically generate and propagate subsegment details for downstream API calls.
Patching is the standard method in the Python AWS X-Ray SDK to instrument supported libraries like Boto3 without modifying client invocation syntax.

Anahtar Kavram

AWS SDK client instrumentation using the X-Ray SDK to trace downstream AWS service calls.
Soru 14Soru

A developer is troubleshooting an AWS Lambda function with a configured timeout of 10 seconds. The function is occasionally failing to process incoming payloads. The developer wants to configure an Amazon CloudWatch Logs metric filter to count how many times the function executions are terminated due to timeouts, and to trigger an alarm. The application code is designed to log custom execution details in JSON format, including `{ "execution_time_ms": 10500, "status": "success" }`, at the end of the handler execution. Which configuration should the developer implement to reliably monitor these execution timeouts?

Cevabı ve açıklamayı göster

Cevap: Create a metric filter on the log group with the pattern "Task timed out" and create a CloudWatch alarm based on this metric.

Cevap

Create a metric filter on the log group with the pattern "Task timed out" and create a CloudWatch alarm based on this metric.
When a Lambda function times out, the Lambda service halts execution immediately. This prevents the custom application code from completing and writing any custom JSON log events. Instead, the service writes a message containing 'Task timed out' to the log stream. Therefore, a metric filter targeting this literal string is the only reliable way to count timeouts.

Adım Adım Çözüm

1
Analyze Lambda execution behavior during a timeout
When a Lambda function reaches its configured timeout limit (10 seconds in this scenario), the AWS Lambda service terminates the execution container immediately.
This shows that any application-level code designed to run at the end of the handler (such as writing a custom JSON log with execution metrics) is never executed.
2
Identify the log event recorded during a timeout
The AWS Lambda service runtime writes a platform-generated log line to the log stream, containing the phrase: 'Task timed out after 10.00 seconds'.
To reliably track timeouts, the metric filter must search for this platform-generated text rather than custom JSON properties that are only written upon successful handler execution.
3
Select the correct CloudWatch Logs Metric Filter syntax
The literal pattern "Task timed out" is used to match the platform log event. An alarm is then associated with this metric to trigger notifications or scaling actions.
This correctly targets the service-level error message and tracks execution failures accurately.

Anahtar Kavram

AWS Lambda platform logging on execution timeouts vs application-level logs, and correct CloudWatch metric filter string matching.
Tahmini Süre:1m 30s
Soru 15Soru

A developer is designing a web application dashboard for a smart home IoT system. The application needs to allow users to sign in using their email and password or their social identity provider. Once authenticated, the web application must securely download and upload user-specific configuration files directly from an Amazon S3 bucket. Additionally, the application must invoke backend REST API endpoints hosted on Amazon API Gateway, which should only be accessible to authenticated users.

Which Cognito configuration should the developer choose to satisfy these requirements with the least operational overhead?

Cevabı ve açıklamayı göster

Cevap: Configure a Cognito User Pool to handle registration, login, and social identity provider federation. Secure the API Gateway REST API with a Cognito Authorizer using the User Pool ID token. Configure a Cognito Identity Pool with the User Pool as an identity provider to obtain temporary AWS credentials for S3 access.

Cevap

Configure a Cognito User Pool to handle registration, login, and social identity provider federation. Secure the API Gateway REST API with a Cognito Authorizer using the User Pool ID token. Configure a Cognito Identity Pool with the User Pool as an identity provider to obtain temporary AWS credentials for S3 access.
The correct approach uses an Amazon Cognito User Pool to manage authentication (handling registration, local credentials, and social provider federation) and uses the resulting JSON Web Token (JWT) ID token to authorize API requests via the built-in API Gateway Cognito Authorizer. To access AWS resources like Amazon S3, a Cognito Identity Pool is required to exchange the User Pool tokens for temporary AWS IAM credentials.

Adım Adım Çözüm

1
Select Cognito User Pools for user sign-in and management.
Users can register, sign in, and federate through social identity providers to receive JWT tokens.
Cognito User Pools serve as the user directory and handle the authentication flow.
2
Integrate API Gateway with the Cognito User Pool.
API Gateway uses a native Cognito Authorizer to validate incoming ID tokens directly.
This secures the REST API without requiring custom Lambda code or credentials exchange for API calls.
3
Configure a Cognito Identity Pool with the User Pool as a provider.
The client application exchanges the User Pool token for temporary AWS IAM credentials.
These temporary credentials allow the client application to directly and securely upload files to Amazon S3.

Anahtar Kavram

Distinction between Cognito User Pools (authentication and user directory) and Cognito Identity Pools (authorization and temporary AWS credentials exchange), as well as integrating User Pools with API Gateway Cognito Authorizers.
Tahmini Süre:1m 30s
Soru 16Soru

A developer is deploying an application on an Amazon EC2 instance. The application is configured to read configuration templates from an Amazon S3 bucket. The developer creates an IAM role named `AppConfigReadRole` with an attached policy that allows `s3:GetObject` on the target bucket. However, the application fails to retrieve the templates and receives an 'Access Denied' error. The developer inspects the trust policy of `AppConfigReadRole` and finds the following document:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}

Which of the following modifications to the trust policy will resolve the Access Denied error and allow the EC2 instance to assume the role?

Cevabı ve açıklamayı göster

Cevap: Change the principal service in the trust policy from `lambda.amazonaws.com` to `ec2.amazonaws.com`.

Cevap

Changing the service principal in the trust policy from `lambda.amazonaws.com` to `ec2.amazonaws.com`.
The trust policy of an IAM role determines which principals are allowed to assume it. For an application running on an Amazon EC2 instance to assume a role via an instance profile, the role's trust policy must specify the EC2 service principal (`ec2.amazonaws.com`) under the `Principal.Service` key, along with the `sts:AssumeRole` action. The original policy mistakenly trusted the Lambda service principal (`lambda.amazonaws.com`), which prevented the EC2 instance from assuming the role.

Adım Adım Çözüm

1
Identify the compute environment where the application is running.
The application is running on an Amazon EC2 instance.
Understanding the host environment determines which AWS service principal needs permission to assume the IAM role.
2
Examine the trust policy of the `AppConfigReadRole` IAM role.
The principal is currently set to `lambda.amazonaws.com`.
An incorrect principal in a trust policy prevents the target service (EC2) from obtaining temporary credentials to assume the role.
3
Update the trust policy principal to match the hosting service.
Replace `lambda.amazonaws.com` with `ec2.amazonaws.com` in the trust policy.
This configures the role to trust the EC2 service, allowing the EC2 instance profile to successfully assume the role and access the S3 bucket.

Anahtar Kavram

IAM Role Trust Policies vs Permission Policies for EC2 Instances
Soru 17Soru

A logistics tracking application named LogiRoute writes real-time status updates for packages to an Amazon DynamoDB table. During peak delivery hours, the application occasionally encounters ProvisionedThroughputExceededException errors when writing updates, causing the tracking requests to fail immediately. Monitoring metrics show that the table's total consumed write capacity remains well below its provisioned write capacity limit. Investigations reveal that the application's HTTP library is configured to disable automatic retries for all backend calls. How should the developer resolve these transient errors while minimizing cost?

Cevabı ve açıklamayı göster

Cevap: Configure the AWS SDK client to use exponential backoff and jitter for handling transient write errors.

Cevap

Configure the AWS SDK client to use exponential backoff and jitter for handling transient write errors.
Configuring the AWS SDK client to use exponential backoff and jitter is the standard best practice for resolving transient ProvisionedThroughputExceededException errors when the overall capacity is sufficient. This allows the application to retry requests after a progressively longer, randomized delay, smoothing out traffic spikes and avoiding errors for the end user without increasing provisioned throughput costs.

Adım Adım Çözüm

1
Analyze the error message and CloudWatch metrics.
Identify that the ProvisionedThroughputExceededException errors are transient and occurring even though the total consumed capacity is below provisioned limits.
This indicates that overall capacity is sufficient, but temporary bursts or micro-bursts are causing brief throttling.
2
Identify the application-side behavior.
Determine that automatic retries are disabled, causing the application to fail immediately upon receiving the exception.
AWS SDKs by default implement retry logic, but disabling or misconfiguring it causes immediate failures on transient errors.
3
Implement retry logic with backoff and jitter.
Configure the AWS SDK client to retry throttled requests using exponential backoff and randomized jitter delays.
This spreads out the retry attempts, preventing them from hitting the database simultaneously and successfully completing the writes once the transient spike subsides.

Anahtar Kavram

Handling DynamoDB transient throttling errors using SDK retries with exponential backoff and jitter.
Tahmini Süre:1m 30s
Soru 18Soru

A developer is deploying a critical update to a serverless API backend running on AWS Lambda. The application handles high-velocity flash sales where traffic spikes instantly. To eliminate cold start latencies, the developer configures Provisioned Concurrency for the Lambda function. The API backend is integrated with an Amazon API Gateway HTTP API.

During deployment, the developer uploads the new function code, publishes Version 22 of the function, and associates Provisioned Concurrency with Version 22. However, when testing the API Gateway endpoint that routes traffic to the function using the LATEST\text{LATEST} identifier, clients still experience significant cold start latencies, and CloudWatch metrics show that the provisioned concurrency is not being utilized.

What should the developer do to ensure that the API Gateway endpoint utilizes the provisioned concurrency?

Cevabı ve açıklamayı göster

Cevap: Update the API Gateway integration to target a specific Lambda alias or a published function version that has Provisioned Concurrency configured, rather than targeting the LATEST\text{LATEST} identifier.

Cevap

Update the API Gateway integration to target a specific Lambda alias or a published function version that has Provisioned Concurrency configured, rather than targeting the LATEST\text{LATEST} identifier.
Provisioned Concurrency initializes a specified number of execution environments so that they are prepared to respond immediately to your function's invocations. However, AWS Lambda does not allow you to configure Provisioned Concurrency on the LATEST\text{LATEST} version of a function, and any invocations that target the LATEST\text{LATEST} identifier directly or through an alias pointing to LATEST\text{LATEST} will not utilize provisioned concurrency. Therefore, the API Gateway integration must be updated to target a published version or an alias pointing to a published version (such as Version 22) that has Provisioned Concurrency configured.

Adım Adım Çözüm

1
Analyze the invocation path of the AWS Lambda function from API Gateway.
Identify that the API Gateway endpoint targets the LATEST\text{LATEST} identifier of the Lambda function.
To determine why the configured Provisioned Concurrency is not being utilized during invocation.
2
Review the AWS Lambda Provisioned Concurrency specifications and restrictions.
Understand that Provisioned Concurrency cannot be associated with or invoked through the LATEST\text{LATEST} identifier; it must be mapped to a specific published version or alias.
To identify the root cause of the cold start latency despite configuration.
3
Modify the routing configuration of the API Gateway and the Lambda function targeting.
Update the API Gateway integration target to point to a Lambda alias (e.g., pointing to Version 22) or directly to Version 22, which has Provisioned Concurrency active.
To route incoming API Gateway traffic to the pre-warmed execution environments.

Anahtar Kavram

AWS Lambda Provisioned Concurrency Routing and Versioning Rules
Tahmini Süre:2m 0s
Soru 19Soru

A team of developers is deploying a backend processing application. An AWS Lambda function is configured to run inside a private VPC subnet to securely query an Amazon RDS PostgreSQL database located in another private subnet. The function must also download configuration files from Amazon S3 and make HTTP POST requests to an external, third-party payment processing API on the public internet. Which network configuration should the developer implement to enable these connections while minimizing data transfer costs and maintaining a secure architecture?

Cevabı ve açıklamayı göster

Cevap: Deploy the Lambda function in the private subnets. Create a Gateway VPC Endpoint for Amazon S3, and configure a NAT Gateway in a public subnet to route outbound traffic to the public internet.

Cevap

Deploy the Lambda function in the private subnets, configure a Gateway VPC Endpoint for Amazon S3, and deploy a NAT Gateway in a public subnet to route outbound public internet traffic.
Deploying the Lambda function in private subnets allows it to access the private RDS database securely. Using a Gateway VPC Endpoint for S3 is a cost-effective choice since Gateway Endpoints do not incur hourly or data processing charges, unlike Interface Endpoints. A NAT Gateway deployed in a public subnet is required to route outbound public internet traffic for the Lambda function in the private subnet.

Adım Adım Çözüm

1
Analyze the destination targets and security requirements.
The RDS database is private (requires private subnet association), S3 is an AWS service (can use a VPC endpoint), and the payment API is on the public internet (requires a NAT Gateway or NAT instance for private resources).
To determine the networking components needed for the VPC.
2
Determine the most cost-effective and secure way to access Amazon S3.
A Gateway VPC Endpoint is free and routes traffic directly to S3 without going through the NAT Gateway, saving data processing fees.
To minimize data transfer costs as requested.
3
Configure the route table for the private subnets where the Lambda function resides.
Add a route directing 0.0.0.0/00.0.0.0/0 traffic to the NAT Gateway in the public subnet.
To enable outbound internet access to the payment gateway API.

Anahtar Kavram

VPC networking for AWS Lambda, including NAT Gateway and VPC Endpoints.
Tahmini Süre:1m 30s
Soru 20Soru

A developer is designing a real-time inventory management microservice that uses an Amazon DynamoDB table. The application needs to support the following operations during peak traffic:

* 1010 `TransactWriteItems` operations per second. Each transaction contains two write actions: one writes a new item of 3.5 KB3.5\text{ KB}, and another updates an existing item resulting in a final size of 1.5 KB1.5\text{ KB}.
* 1515 standard `PutItem` operations per second, with an average item size of 4.5 KB4.5\text{ KB}.
* 4040 `TransactGetItems` operations per second. Each transaction reads a single item of 6 KB6\text{ KB}.

To ensure optimal performance, scalability, and security under the AWS shared responsibility model, which capacity provisioning and development strategy should the developer implement?

Cevabı ve açıklamayı göster

Cevap: Provision 195195 Write Capacity Units (WCUs) and 160160 Read Capacity Units (RCUs). Configure the application to use the default credential provider chain and retrieve items using Query or TransactGetItems operations instead of Scan.

Cevap

Provision 195195 Write Capacity Units (WCUs) and 160160 Read Capacity Units (RCUs). Configure the application to use the default credential provider chain and retrieve items using Query or TransactGetItems operations instead of Scan.
The correct strategy provisions 195195 WCUs and 160160 RCUs, uses the default credential provider chain for secure authentication, and retrieves specific items efficiently via Query or TransactGetItems instead of Scan. The Write Capacity Unit (WCU) calculation is as follows: The TransactWriteItems workload consists of 1010 operations/second. Each operation has two write actions: a new item of 3.5 KB3.5\text{ KB} (rounded up to 4 KB4\text{ KB}, costing 4 WCUs×24\text{ WCUs} \times 2 for transactional writes = 8 WCUs8\text{ WCUs}) and an update resulting in a 1.5 KB1.5\text{ KB} item (rounded up to 2 KB2\text{ KB}, costing 2 WCUs×22\text{ WCUs} \times 2 for transactional writes = 4 WCUs4\text{ WCUs}). This totals 12 WCUs12\text{ WCUs} per transaction, or 120 WCUs120\text{ WCUs} for 1010 transactions/second. The standard PutItem workload consists of 1515 operations/second of 4.5 KB4.5\text{ KB} (rounded up to 5 KB5\text{ KB}, costing 5 WCUs5\text{ WCUs}). This consumes 75 WCUs75\text{ WCUs}. Summing these values gives 195 WCUs195\text{ WCUs}. The Read Capacity Unit (RCU) calculation is as follows: The TransactGetItems workload consists of 4040 operations/second. Each transaction reads one 6 KB6\text{ KB} item (rounded up to the nearest 4 KB4\text{ KB} boundary, which is 8 KB8\text{ KB}, consuming 2 RCUs2\text{ RCUs}). Since transactional reads consume double the RCUs of strongly consistent reads, each transaction costs 4 RCUs4\text{ RCUs}, totaling 160 RCUs160\text{ RCUs} for 4040 operations/second.

Adım Adım Çözüm

1
Calculate the Write Capacity Units (WCUs) required for the 1010 TransactWriteItems operations per second.
120120 WCUs
Each transaction contains two write actions. Action 1 (3.5 KB3.5\text{ KB}) is rounded up to 4 KB4\text{ KB} and multiplied by 22 for transaction writes, yielding 8 WCUs8\text{ WCUs}. Action 2 (1.5 KB1.5\text{ KB}) is rounded up to 2 KB2\text{ KB} and multiplied by 22, yielding 4 WCUs4\text{ WCUs}. Total per transaction is 12 WCUs12\text{ WCUs}. For 10 operations/sec10\text{ operations/sec}, this consumes 10×12=120 WCUs10 \times 12 = 120\text{ WCUs}.
2
Calculate the WCUs required for the 1515 standard PutItem operations per second.
7575 WCUs
Each standard write of 4.5 KB4.5\text{ KB} is rounded up to 5 KB5\text{ KB} and consumes 5 WCUs5\text{ WCUs}. For 15 operations/sec15\text{ operations/sec}, this consumes 15×5=75 WCUs15 \times 5 = 75\text{ WCUs}.
3
Sum the WCU requirements to find the total provisioned WCU.
195195 WCUs
Combining the transactional writes (120 WCUs120\text{ WCUs}) and standard writes (75 WCUs75\text{ WCUs}) yields a total required write capacity of 195 WCUs195\text{ WCUs}.
4
Calculate the Read Capacity Units (RCUs) required for the 4040 TransactGetItems operations per second.
160160 RCUs
Transactional reads are strongly consistent and consume double the capacity of standard strongly consistent reads. Reading a 6 KB6\text{ KB} item requires rounding up to the nearest 4 KB4\text{ KB} boundary (8 KB8\text{ KB}), consuming 2 RCUs2\text{ RCUs} for a standard strongly consistent read. Doubling this for the transaction results in 4 RCUs4\text{ RCUs} per operation. For 40 operations/sec40\text{ operations/sec}, this consumes 40×4=160 RCUs40 \times 4 = 160\text{ RCUs}.
5
Evaluate the architectural and security configurations.
Use the default credential provider chain and query/retrieve items directly rather than scanning.
Hardcoding credentials violates security best practices, and using Scan operations instead of Query or specific read APIs is highly inefficient and consumes excess RCUs.

Anahtar Kavram

DynamoDB capacity calculation for transactional and standard operations combined with security and query optimization
Tahmini Süre:3m 0s
Sayfa 1 / 40Sonraki