All practice questions
1542 questions
A developer is attempting to deploy a serverless application using a template file named template.yaml. The file contains the following code:
yaml
Resources:
ProcessOrderFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs18.x
CodeUri: ./src
Events:
PostOrder:
Type: Api
Properties:
Path: /orders
Method: post
When deploying this template directly via AWS CloudFormation, the deployment fails with the error message: `Template format error: Unrecognized resource type: AWS::Serverless::Function`.
Which of the following additions to the template will resolve this error?
A logistics company is designing a REST API in Amazon API Gateway to allow partner clients to retrieve shipment data. Partners authenticate against an external OAuth 2.0 Identity Provider (IdP) and receive a JWT access token containing custom scopes like `shipments:read`. The developer wants to authenticate the tokens and enforce access control using these custom scopes at the API Gateway level with minimal custom code. Which two configuration steps should the developer perform to meet these requirements? (Select TWO.)
Select all that apply
A developer is deploying a Python application to Amazon ECS on AWS Fargate. The application uses the AWS SDK for Python (Boto3) to upload objects to an Amazon S3 bucket. During local testing, the developer initialized the S3 client by passing a specific profile name from their local AWS CLI configuration file. In production, the Fargate task is assigned an ECS Task Role with the required S3 permissions, but the application fails to start due to a client initialization error. Which action should the developer take to resolve this issue?
A developer is building a serverless web application. The frontend, hosted on a static website in an Amazon S3 bucket, needs to call a secure backend API hosted on Amazon API Gateway. The API has a resource with `OPTIONS` and `POST` methods. The `POST` method is integrated with an AWS Lambda function using a Lambda custom integration (`AWS` integration type). To secure the API, the developer configures an Amazon Cognito User Pool authorizer and applies it to both the `OPTIONS` and `POST` methods. During testing, the frontend application fails to make requests, and the browser console displays a CORS error during the preflight phase. Additionally, the developer notes that the Lambda function cannot access the Cognito group membership claims of the authenticated user to perform fine-grained authorization. How should the developer resolve these issues?
An operations team manages a production application infrastructure stack deployed via AWS CloudFormation. The stack consists of an Amazon ECS service, an Application Load Balancer (ALB), and an Amazon DynamoDB table. During a previous template update, a resource configuration error caused a failure, leaving the stack stuck in the `UPDATE_ROLLBACK_FAILED` state. Additionally, a drift detection scan indicates that another team member manually modified the ALB's security group out-of-band to allow traffic from a new partner IP range. The team must successfully deploy the new application updates while preserving the manual security group modifications. Which combination of actions should the team take to meet these requirements? (Select TWO.)
Select all that apply
A developer is building a high-security microservice that processes sensitive transaction payloads. The application uses client-side envelope encryption with an AWS KMS customer managed key. The developer must ensure that:
1. The encrypted transaction payloads are cryptographically bound to a specific and to prevent decryption under any other context.
2. All cryptographic operations are logged in AWS CloudTrail with these context details for compliance auditing.
Which two actions must the developer take to implement this encryption workflow?
Select all that apply
A developer is implementing Attribute-Based Access Control (ABAC) in an AWS account. The developer configures an IAM role named `ProjectRunnerRole` with the following trust policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:user/AppDeveloper"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"aws:RequestTag/Project": "Phoenix",
"aws:RequestTag/CostCenter": "1001"
}
}
}
]
}
An IAM user named `AppDeveloper` in the same account attempts to assume this role by calling the `sts:AssumeRole` API and passing the session tags `Project=Phoenix` and `CostCenter=1001`. The request fails with an `AccessDenied` error. Which TWO of the following configurations are required to resolve this error and successfully allow the user to assume the role?
Select all that apply
A developer is configuring a release pipeline in AWS CodePipeline. The pipeline must retrieve a database password that requires automatic weekly rotation, and it must assume an IAM role in a target AWS account to deploy resources. Which of the following configuration steps are correct? (Select TWO.)
Select all that apply
An organization is deploying a Node.js web application to a single-instance environment on AWS Elastic Beanstalk. The application must store local application log files in a custom directory on the host Amazon EC2 instance. Additionally, the application needs to retrieve database credentials dynamically at runtime from AWS Systems Manager Parameter Store.
Which two actions must a developer take to meet these requirements?
Select all that apply
An enterprise web application requires external partner users to authenticate using their corporate SAML Identity Provider (IdP). Once authenticated, users must be able to invoke private API endpoints hosted on Amazon API Gateway and upload large log files directly to a specific folder in an Amazon S3 bucket. The S3 folder path must be isolated per partner organization based on a SAML assertion attribute named `partnerId`.
Which combination of configuration steps should a developer implement to meet these requirements with the least operational overhead? (Select TWO.)
Select all that apply
A developer is configuring a continuous delivery pipeline in AWS CodePipeline within AWS Account A (Tooling Account). The pipeline must build and deploy a serverless application to AWS Account B (Production Account) using AWS CloudFormation. The deployment process requires a sensitive API authentication token that is generated during the build stage and must be rotated automatically on a weekly schedule. The deployment must adhere to the principle of least privilege. Which combination of configuration steps will meet these requirements?
A developer is configuring a continuous release pipeline in AWS CodePipeline for a web application. The pipeline must include a manual approval stage before deploying the application to production, which should notify the operations team. Additionally, the subsequent build and deployment stage in AWS CodeBuild requires a database API key that must be rotated automatically every 30 days. Which combination of steps should the developer perform to meet these requirements securely? (Select TWO.)
Select all that apply
A developer is writing a backup utility that must encrypt database export files, each approximately in size, before uploading them to an Amazon S3 bucket. The utility must use client-side envelope encryption with an AWS Key Management Service (AWS KMS) customer managed key.
Which two steps must the developer implement in the utility's code to encrypt the files securely and prepare them for storage?
Select all that apply
A developer has configured an AWS Lambda function in Account A () to retrieve configuration files from a secured Amazon S3 bucket in the same account. The developer created an IAM role named `LambdaS3ReaderRole` with the following trust policy and permissions policy, and assigned it as the function's execution role:
Trust Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Permissions Policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::app-config-bucket-1111/*"
}
]
}
During local testing, the developer used their own IAM user access keys, which had administrative privileges. Before deploying to the Lambda environment, the developer committed the following code:
python
import boto3
import os
def lambda_handler(event, context):
# Initialize the S3 client
s3_client = boto3.client(
's3',
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'AKIAIOSFODNN7EXAMPLE'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
)
try:
response = s3_client.get_object(
Bucket='app-config-bucket-1111',
Key='settings.json'
)
return response['Body'].read().decode('utf-8')
except Exception as e:
print(f"Error: {str(e)}")
raise e
After deploying the Lambda function, the execution fails with an `AccessDenied` error when trying to retrieve the S3 object. The developer verifies that the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are not set in the Lambda function's configuration.
Which of the following options explains the cause of this authorization failure, and describes the correct way to resolve it?
A developer is testing a Java application locally on their workstation. The application publishes messages to an Amazon SNS topic using the AWS SDK for Java v2. The SDK client is initialized as follows:
java
SnsClient snsClient = SnsClient.builder()
.region(Region.US_EAST_1)
.build();
The developer's workstation has a shared AWS credentials file (`~/.aws/credentials`) containing a `[default]` profile with expired credentials and a `[dev]` profile with valid credentials. In the local IDE run configuration, the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are set to temporary credentials from an older session that has since expired. When the application runs, it fails with an expired token error.
Which of the following configuration steps must the developer perform to ensure the application successfully authenticates using the valid credentials from the `[dev]` profile? (Select TWO.)
Select all that apply
An HR management application named StaffSync records employee clock-in and clock-out events to an Amazon DynamoDB table. During the start of a morning shift, hundreds of employees clock in at the exact same minute. The application code makes direct write requests using a custom HTTP client without retry logic. This results in unhandled ProvisionedThroughputExceededException errors and application crashes, even though the table's total provisioned write capacity is not fully exhausted.
Which of the following is the most effective developer-centric solution to resolve these application crashes during brief write spikes?
A developer is deploying a Go web application to Amazon ECS using the EC2 launch type. The application is instrumented with the AWS X-Ray SDK for Go to trace incoming HTTP requests and downstream calls to Amazon DynamoDB. The ECS task definition is configured with the awsvpc network mode and currently contains only the application container. During testing, no trace data is appearing in the AWS X-Ray console. When inspecting the container logs, the developer finds multiple errors stating that the application is unable to connect to the X-Ray daemon at 127.0.0.1:2000. Which of the following actions should the developer take to resolve this issue? (Select TWO.)
Select all that apply
An agricultural IoT platform named AgriGrow records hourly soil telemetry data from millions of sensors deployed across global farms. The data is written to an Amazon DynamoDB table with a partition key of `FarmID` (UUID) and a sort key of `Timestamp` (ISO 8601 string). During a sudden regional weather event, the platform experiences a massive surge in sensor writes. The application starts receiving `ProvisionedThroughputExceededException` errors. CloudWatch metrics indicate that the table's total consumed Write Capacity Units (WCUs) are far below the total provisioned write capacity. The developer finds that a single large farm has thousands of active sensors writing simultaneously, creating a hot partition. The telemetry client currently fails immediately when a write is throttled. Which TWO actions should the developer take to resolve the write throttling and minimize client-side errors? (Select TWO.)
Select all that apply
A developer is configuring an AWS CodeBuild project to package a web application. The build process requires retrieving a database connection string from AWS Systems Manager Parameter Store and using a custom IAM role to allow CodeBuild to write the build logs to an Amazon CloudWatch Logs log group. During the first build run, the build fails immediately before the install phase with an error stating that CodeBuild is not authorized to assume the service role. Additionally, the application fails to build because the connection string path is being treated as a literal string rather than retrieving the actual database connection string value. Which of the following actions should the developer take to resolve these issues? (Select TWO.)
Select all that apply
A developer is troubleshooting a local Node.js application that uses the AWS SDK for JavaScript (v3) to query an Amazon DynamoDB table. The local development machine has the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` set to credentials of a retired testing account, which causes authentication failures. The developer has a local shared credentials file (`~/.aws/credentials`) with a profile named `local-dev` that contains active credentials for the development environment. The client is initialized in the code as follows:
javascript
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
const client = new DynamoDBClient({});
Which of the following actions will resolve this credential resolution issue and ensure the application authenticates using the `local-dev` profile? (Select TWO.)
Select all that apply