Soru

Zorluk: KolayAWS Serverless Application Model (SAM)

A developer is configuring a deployment template for a new serverless application using the AWS Serverless Application Model (SAM). The template contains the following partial structure:

yaml
Transform: AWS::Serverless-2016-10-31
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs18.x
CodeUri: ./src

Which two steps or configurations are required to successfully deploy and run this serverless application? (Select two.)

  1. The template must declare the Transform header at the root level of the template file to instruct CloudFormation on how to process SAM-specific resources.Cevap
  2. The local function code located in the './src' directory must be packaged and uploaded to an Amazon S3 bucket prior to deploying the CloudFormation stack.Cevap
  3. C
    The template must list the Lambda function resource under the Globals section instead of the Resources section.
  4. D
    The API Gateway event source must be configured with a custom integration rather than a proxy integration to allow SAM to automatically map HTTP header values.
  5. E
    The Lambda function's IAM trust policy must explicitly grant permissions to retrieve runtime configuration secrets from AWS Secrets Manager.

Cevap

The configurations required are: (1) declaring the Transform header at the root level of the template file, and (2) packaging and uploading the local function code in the './src' directory to an Amazon S3 bucket.
The correct answer states that the Transform declaration must be at the root of the template file to instruct CloudFormation how to parse the SAM shorthand syntax, and that local function artifacts in the source directory must be zipped and uploaded to an S3 bucket prior to CloudFormation execution.

Adım Adım Çözüm

1
Analyze template syntax and transformation requirement.
Identify that the 'Transform: AWS::Serverless-2016-10-31' line is required at the root of the template.
This header informs AWS CloudFormation that it must parse the template using the Serverless transform to expand SAM resources into standard CloudFormation resources.
2
Analyze code deployment requirements.
Confirm that local files specified by 'CodeUri: ./src' must be packaged.
CloudFormation requires function code to be hosted in an Amazon S3 bucket. The packaging phase zips the local code directory, uploads it, and replaces the local path with the S3 URI.

Anahtar Kavram

AWS SAM templates require a root-level transform declaration to be parsed by AWS CloudFormation, and local deployment artifacts must be packaged and uploaded to S3.
Tahmini Süre:1m 0s
Bu soruyu puanla