Misc Flashcards
How can you Enable the X-Ray daemon on Beanstalk?
Include the xray-daemon.config configuration file in the .ebextensions directory of your source code.
In Amazon API Gateway, API keys by themselves do not grant access to execute an API. What else needs to be done to grant access? What error do they get if this is not done?
The API keys need to be associated with a usage plan, and that usage plan then determines which API stages and methods the API key can access. If the API key is not associated with a usage plan, it will not have permission to access any of the resources, which will result in a “403 Forbidden” error
What API call do you use to associate API Gateway keys with a usage plan?
Associate the API keys for users with the intended usage plan using the CreateUsagePlanKey operation
What should be done to only allow authorized clients to invalidate an API Gateway cache entry when submitting API requests? (TWO things)
- The client must send a request which contains the Cache-Control: max-age=0 header.
- Tick the Require Authorization checkbox in the Cache Settings of your API via the console.
If you have applications running outside of an AWS environment that need programmatic access to AWS resources, how do you do it?
Go to the AWS Console and create a new IAM user with programmatic access. In the application server, create the credentials file at ~/.aws/credentials with the access keys of the IAM user.
What Gateway response types are associated with the HTTP 504 error in API Gateway?
INTEGRATION_FAILURE – The gateway response for an integration failed error. If the response type is unspecified, this response defaults to the DEFAULT_5XX type.
INTEGRATION_TIMEOUT – The gateway response for an integration timed out error. If the response type is unspecified, this response defaults to the DEFAULT_5XX type.
How can you ensure that all objects in your S3 bucket are encrypted at rest using server-side encryption with AWS KMS keys?
Add a bucket policy which denies any s3:PutObject action unless the request includes the x-amz-server-side-encryption-aws-kms-key-id header.
How can you monitor the responsiveness of your API calls as well as the underlying Lambda function?
Using CloudWatch:
- Monitor the IntegrationLatency metrics to measure the responsiveness of the backend.
– Monitor the Latency metrics to measure the overall responsiveness of your API calls.
If you need server-side encryption for all of the objects that are stored in a bucket, how can you do it with amazon-managed keys? Can you use customer-provided keys?
- Use a bucket policy to deny permissions to upload an object unless the request includes the x-amz-server-side-encryption header to request server-side encryption.
- Yes: if you chose to use server-side encryption with customer-provided encryption keys (SSE-C), you must provide encryption key information using the following request headers: x-amz-server-side-encryption-customer-algorithm, x-amz-server-side-encryption-customer-key,
x-amz-server-side-encryption-customer-key-MD5
What are the three settings to enable CloudWatch to evaluate when to change the alarm state?
– Period is the length of time to evaluate the metric or expression to create each individual data point for an alarm. It is expressed in seconds. If you choose one minute as the period, there is one datapoint every minute.
– Evaluation Period is the number of the most recent periods, or data points, to evaluate when determining alarm state.
– Datapoints to Alarm is the number of data points within the evaluation period that must be breaching to cause the alarm to go to the ALARM state. The breaching data points do not have to be consecutive, they just must all be within the last number of data points equal to Evaluation Period.
In a system using CloudFront, how can you redirect requests , such as to display region-specific information?
Implement a CloudFront function that returns the appropriate URL based on the CloudFront-Viewer-Country. Configure the distribution to trigger the function on Viewer request events.
With ECS, how can you allow containers to access ports on the host container instance to send or receive traffic using port mapping?
Using the task definition. Port mappings are specified as part of the container definition which can be configured in the task definition.
What environment variables does AWS Lambda use to facilitate communication with the X-Ray daemon and configure the X-Ray SDK?
_X_AMZN_TRACE_ID: Contains the tracing header, which includes the sampling decision, trace ID, and parent segment ID. If Lambda receives a tracing header when your function is invoked, that header will be used to populate the _X_AMZN_TRACE_ID environment variable. If a tracing header was not received, Lambda will generate one for you.
AWS_XRAY_CONTEXT_MISSING: The X-Ray SDK uses this variable to determine its behavior in the event that your function tries to record X-Ray data, but a tracing header is not available. Lambda sets this value to LOG_ERROR by default.
AWS_XRAY_DAEMON_ADDRESS: This environment variable exposes the X-Ray daemon’s address in the following format: IP_ADDRESS:PORT. You can use the X-Ray daemon’s address to send trace data to the X-Ray daemon directly without using the X-Ray SDK.
How can a client using API gateway fetch the latest data from your endpoints every time a request is sent and invalidate the existing cache.
The client must send a request that contains the Cache-Control: max-age=0 header.
While using SAM locally, how can you provide permissions to interact with other AWS services?
- Use the aws configure command with the –profile parameter to add a named profile with the sandbox AWS account’s credentials.
- Run the function using sam local invoke with the –profile parameter.
An application scans the entire DynamoDB table to return requested data. How can performance be improved cheaply?
Use Query operations instead of Scan and reduce the page size. (DAX can be more expensive)
When should you choose Memcached over Redis ?
- You need the simplest model possible.
– You need to run large nodes with multiple cores or threads.
– You need the ability to scale out and in, adding and removing nodes as demand on your system increases and decreases.
– You need to cache objects, such as a database.
How can you detect new entries in a DynamoDB table and automatically trigger a Lambda function to run?
Enable DynamoDB Streams to detect the new entries and automatically trigger the Lambda function.
What format does the output need to be that is returned from a Lambda proxy integration backend with API Gateway? What happens if it is the wrong format?
JSON
You’d get a 502 error in the API Gateway
What is the default for Lambda total concurrent executions across all functions within a given region? How can it be increased?
1000
Request AWS to increase the limit of your concurrent executions
How can you estimate the concurrent executions used by your Lambda function and whether the limit needs to be increased?
concurrent executions = (invocations per second) x (average execution duration in seconds). If this is > 1000 then you need to ask AWS to increase it.
How can you authenticate and authorize users for the premium pay-wall content on your website backed by S3?
Use Lambda@Edge. For example, you can trigger a Lambda function to authorize each viewer request by calling authentication and user management service such as Amazon Cognito.
What is appspec.yml for?
In CodeDeploy - it defines how a deployment happens
Where can CodeDeploy deploy to?
EC2 Instances
On-prem servers
Lambda Functions
ECS
What kinds of deployments can be performed with Code Deploy for EC2/On-prem?
In-place
Blue-green
For CodeDeploy on EC2 to work, what has to be running and where?
The CodeDeploy agent must be running on the EC2/on-prem instances
With CodeDeploy for EC2, what does EC2 need to have sufficient access to?
S3, because the deployment bundles are stored there