You are planning to build a serverless application with microservices using AWS Code Build.
This application will be using AWS Lambda.
How will you specify AWS SAM CLI & Application package within the build spec file of an AWS CodeBuild?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer - A.
AWS SAM CLI needs to be installed during the install phase of AWS CodeBuild, while AWS SAM package needs to be specified in the Build section, creating a zip file of code & upload to Amazon S3.
Refer page 149 on the below link:
https://docs.aws.amazon.com/codepipeline/latest/userguide/codepipeline-user.pdfOption B is incorrect as AWS-sam-cli needs to be installed in the install phase & not in the pre-build phase.
Option C is incorrect as the sam package needs to be specified in the post-build section & not in the pre-build phase.
Option D is incorrect as AWS-sam-cli needs to be installed in the install phase & not in the pre-build phase.
sam package needs to be specified in the post-build section & not in the install phase.
For more information on using AWS SAM with AWS CodeBuild, refer to the following URLs-
https://aws.amazon.com/blogs/devops/building-and-testing-polyglot-applications-using-aws-codebuild/ https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-build.htmlAWS CodeBuild is a fully managed build service that compiles source code, runs tests, and produces software packages that are ready to deploy. AWS CodeBuild can be used to build serverless applications with microservices using AWS SAM CLI and Application package.
When building a serverless application with microservices using AWS CodeBuild, the AWS SAM CLI and Application package should be specified in the build spec file. The build spec file is a YAML-formatted file that contains the instructions for AWS CodeBuild to follow when building the application.
To specify the AWS SAM CLI and Application package within the build spec file of an AWS CodeBuild, the following steps can be followed:
Choose the appropriate phase in the build spec file where the AWS SAM CLI and Application package will be used. The options are install, pre_build, build, post_build.
Use the AWS SAM CLI command 'aws-sam-cli' to install it in the install phase or pre_build phase. The AWS SAM CLI is a tool that enables local development and testing of serverless applications defined with AWS SAM.
Use the 'sam package' command to package the AWS Lambda functions in the pre_build phase or build phase. This command creates an AWS CloudFormation template and packages the code and dependencies for deployment to Lambda.
Finally, ensure that the build spec file is saved and committed to version control for future reference.
Therefore, the correct answer to the question is option C: Use aws-sam-cli in the install phase & sam package in the pre_build phase of the BuildSpec file.