All practice questions
1542 questions
A developer is deploying an application on an Amazon EC2 instance. The application is designed to read messages from an Amazon SQS queue named `orders-queue` and write the processed items to an Amazon DynamoDB table named `orders-table`. The developer wants to configure the necessary permissions by following security best practices and avoiding hardcoded credentials. Which two configurations are required to meet these requirements? (Select TWO.)
Select all that apply
An application running in Amazon ECS container tasks writes structured JSON logs to Amazon CloudWatch Logs. A sample log event is:
{
"eventType": "DatabaseError",
"details": {
"duration": 4500,
"status": "failed"
}
}
A developer wants to create a CloudWatch Metric Filter to monitor events where the event type is "DatabaseError" and the nested query duration is greater than milliseconds. The developer initially configures a metric filter with the pattern `[eventType = "DatabaseError", details.duration > 4000]`, but notices that the metric is not being published and no matches are found. Which of the following actions must the developer take to resolve this issue and successfully monitor the database errors? (Select TWO.)
Select all that apply
A developer is implementing fine-grained access control for a mobile application. Users authenticate via an Amazon Cognito User Pool, and the application needs to write user-specific profile data to an Amazon DynamoDB table named `UserProfiles`. The table's partition key is `UserId` (String). The developer created an Amazon Cognito Identity Pool to provide temporary AWS credentials to authenticated users and attached an IAM policy to the authenticated role that uses the `dynamodb:LeadingKeys` condition. However, when the application attempts to write data to the DynamoDB table, the API calls fail with an `AccessDeniedException` error. Which two actions must the developer take to resolve these authorization failures?
Select all that apply
A developer uses AWS SAM to deploy a serverless application. The template defines an `AWS::Serverless::Function` triggered by an API Gateway HTTP API event source, and a custom `AWS::IAM::Role` for the execution role. The deployment completes successfully. However, when the API is invoked, the client receives a ` Bad Gateway` error. The CloudWatch logs show that the Lambda service is unable to assume the configured execution role, and the function is not executed.
Here is a portion of the template:
yaml
Resources:
ProcessOrderFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: index.handler
Runtime: nodejs18.x
Role: !GetAtt ExecutionRole.Arn
Events:
CreateOrder:
Type: Api
Properties:
Path: /orders
Method: post
ExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: apigateway.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: WriteLogs
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: '*'
The handler code in `src/index.js` is defined as:
javascript
exports.handler = async (event) => {
return "Order successfully processed!";
};
Which TWO modifications are required to resolve both the execution role assumption issue and the ` Bad Gateway` error? (Select TWO.)
Select all that apply
A developer needs to deploy a new version of a critical web application. The deployment must satisfy the following constraints:
- The application must maintain of its serving capacity throughout the deployment.
- The deployment must have zero downtime.
- The deployment must not modify the existing production instances until the new version is fully verified.
- Rollbacks must be fast and have minimal impact on the active production environment if the new version fails verification.
Which two deployment strategies will satisfy these requirements? (Select two.)
Select all that apply
An organization is transitioning their microservices to Amazon ECS and plans to use AWS CodeDeploy for automated blue/green deployments. To ensure zero downtime, the deployment workflow must execute validation tests against the replacement task set on a secondary port before shifting any production traffic. Furthermore, AWS CodeDeploy must be authorized to interact with the ECS cluster and load balancer during the deployment execution.
Which TWO configuration actions should the developer perform to support this deployment flow?
Select all that apply
A developer is troubleshooting an application that writes space-delimited log events to an Amazon CloudWatch Logs log group. A sample log event is:
`2026-07-14T12:00:00Z INFO 192.168.1.50 GET /index.html 200 125`
The fields in the log event represent the timestamp, severity, client IP address, HTTP method, resource path, status code, and response time in milliseconds, in that order.
The developer wants to create a CloudWatch Logs metric filter that counts all requests where either the status code is or the response time is greater than .
Which of the following filter patterns must the developer use to correctly implement this metric filter?
An organization hosts a web application on an AWS Elastic Beanstalk environment. The operations team needs to deploy a minor software update. Due to strict AWS account limits, the environment cannot launch any additional Amazon EC2 instances during the deployment. The application must remain online and accessible to users, but it can tolerate running at a minimum of of its total instance capacity during the deployment. Which Elastic Beanstalk deployment policy should the developer configure to meet these requirements?
A developer is configuring a rolling update deployment for an Amazon ECS service. The service has a desired task count of 12. To ensure high availability and prevent performance degradation under peak load, the service must maintain 100% of its desired capacity at all times during the deployment. Furthermore, due to CPU and memory constraints on the underlying container instances, the deployment can run at most 3 additional tasks concurrently. Which parameters for minimum healthy percent and maximum percent should the developer configure for the ECS service?
A developer is writing an AWS SAM template for a serverless application. The application contains a Lambda function (`ProcessOrdersFunction`) that must execute with a custom IAM role to comply with strict organizational security requirements. The developer defines the custom role and the function in the SAM template as follows:
yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: apigateway.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: DynamoDBWriteAccess
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:PutItem
Resource: !GetAtt OrdersTable.Arn
ProcessOrdersFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: index.handler
Runtime: nodejs18.x
Role: !GetAtt LambdaExecutionRole.Arn
OrdersTable:
Type: AWS::Serverless::SimpleTable
During deployment, the stack is created successfully. However, when the client application triggers the Lambda function, the function fails to execute, and the logs indicate that the execution role cannot be assumed. What is the root cause of this execution failure?
A developer is configuring an AWS CodeDeploy deployment group to perform a blue/green deployment for an Amazon ECS service. The developer wants to run validation tests against the replacement task set using a test listener before routing production traffic. The deployment fails during the validation phase. Upon reviewing the logs, the developer discovers that the AppSpec file specifies an invalid lifecycle hook for the ECS compute platform, and CodeDeploy is unable to invoke the validation Lambda function due to incorrect IAM permissions. Which combination of configurations will correctly resolve these issues?
An operations team is migrating a legacy provisioning stack to a serverless model. A team member creates a new template file containing an `AWS::Serverless::Function` resource:
yaml
AWSTemplateFormatVersion: '2010-09-09'
Resources:
RetrieveInventoryFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs20.x
CodeUri: ./src
Environment:
Variables:
DB_PASSWORD: '{{resolve:ssm-secure:InventoryDBPassword}}'
The database password requires automated rotation every 30 days. When attempting to create the stack, AWS CloudFormation fails with a validation error stating that the `AWS::Serverless::Function` resource type is unrecognized.
Which TWO actions should the team take to successfully deploy the template and retrieve the database credentials securely?
Select all that apply
A developer is designing a deployment pipeline for a critical microservice on AWS. The deployment process must ensure zero downtime, allow testing of the new application version with a small fraction of production traffic before shifting all traffic, and support automatic rollback if CloudWatch alarms detect errors.
Which two deployment strategies or configurations will satisfy these requirements?
Select all that apply
A developer is building a mobile health-tracking application. Users will log in using an external OpenID Connect (OIDC) compliant identity provider. After logging in, the mobile application must upload raw telemetry log files directly to a private Amazon S3 bucket, and invoke a private REST API hosted on Amazon API Gateway to fetch user profile data. Which TWO Amazon Cognito configurations are required to support this architecture?
Select all that apply
A sports streaming application named FanStream logs viewer chat messages during live events. The chat messages are written to an Amazon DynamoDB table with EventID as the partition key and Timestamp as the sort key. During highly anticipated matches, the application experiences frequent ProvisionedThroughputExceededException errors on write operations, even though the total consumed write throughput is well below the table's provisioned capacity. Which of the following actions should the developer take to resolve this issue? (Select TWO.)
Select all that apply
An e-commerce application deployed on Amazon ECS writes structured JSON logs to Amazon CloudWatch Logs. A developer needs to create a CloudWatch metric filter to count the occurrences of HTTP 504 Gateway Timeout errors. A sample log event is:
{
"request": {
"path": "/checkout",
"responseCode": 504
}
}
Which filter pattern must the developer use to correctly match this log event?
A developer is configuring the `appspec.yml` file for an AWS Lambda deployment using AWS CodeDeploy. The deployment needs to shift traffic to a new version of a function. The developer wants to run validation tests before the traffic shift starts, and a notification function after all traffic has successfully shifted. The developer begins drafting the AppSpec file as follows:
yaml
version: 0.0
Resources:
- MyLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Name: "MyLambdaFunction"
Alias: "live"
CurrentVersion: "1"
TargetVersion: "2"
Hooks:
- Hook_1: "ValidationLambdaFunction"
- Hook_2: "NotificationLambdaFunction"
Which of the following lifecycle hooks are valid replacements for `Hook_1` and `Hook_2` to meet these requirements? (Select TWO.)
Select all that apply
A developer uses AWS SAM to build and deploy a serverless microservice. The SAM template defines a Lambda function triggered by an API Gateway event using the following template definition:
yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
SubmitFeedbackFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: app.handler
Runtime: nodejs18.x
Events:
PostFeedback:
Type: Api
Properties:
Path: /feedback
Method: post
The Lambda function's handler code is implemented as follows:
javascript
exports.handler = async (event) => {
const feedbackText = event.feedback;
return {
message: `Feedback received: ${feedbackText}`
};
};
When clients send a POST request with the JSON payload `{"feedback": "Great service!"}`, the response from the API is ` Bad Gateway` and the Lambda logs show that `feedbackText` is undefined.
Which explanation best identifies the root cause of this failure, and how should it be resolved?
A developer is updating a critical AWS Lambda function using AWS CodeDeploy. The deployment must route of the production traffic to the new version of the function first. The deployment must then automatically shift the remaining of the traffic to the new version after exactly minutes, provided that no CloudWatch alarms are triggered during this window.
Which AWS CodeDeploy deployment configuration should the developer choose to satisfy these requirements?
A developer is deploying a containerized application on Amazon ECS (Fargate). The application needs to read messages from an Amazon SQS queue and write items to an Amazon DynamoDB table. During deployment, the developer notices that the container starts up successfully but fails with an AccessDenied error when attempting to write to the DynamoDB table. Which of the following configurations will resolve this authorization issue while following the principle of least privilege?