3.1 - Deploying with Elastic Beanstalk and SAM

AWS Certified Developer Associate objective 3.1 covers deploying applications with managed tools. AWS Elastic Beanstalk deploys and manages a web app by handling capacity, load balancing, scaling and health monitoring, so you upload code and it provisions the environment. To add custom software packages, OS settings or commands to a Beanstalk environment, you place configuration files in the .ebextensions folder of the application bundle. For serverless deployments, an AWS SAM template can publish a new Lambda version and shift traffic gradually using AutoPublishAlias with a DeploymentPreference such as canary or linear, integrating with CodeDeploy. You should also know Beanstalk deployment policies (all-at-once, rolling, immutable, blue-green) and SAM transforms. Expect scenario questions that describe managed web-app deployment, customising an environment, or gradual Lambda traffic shifting, and ask which tool or mechanism - Elastic Beanstalk, .ebextensions or SAM AutoPublishAlias - applies.

Memory hook
Managed web-app deploy (capacity, LB, scaling) = Elastic Beanstalk. Custom packages/OS settings for Beanstalk = .ebextensions files. Publish a Lambda version + shift traffic gradually = SAM AutoPublishAlias with DeploymentPreference.

Practice questions

1. Which service deploys and manages a web app by handling capacity, load balancing, and health from your uploaded code, with minimal configuration?

  • AWS CloudFormation
  • AWS Elastic Beanstalk (correct answer)
  • AWS CodeCommit
  • Amazon EC2 Auto Scaling

Elastic Beanstalk is a PaaS that provisions and manages the environment (EC2, ELB, Auto Scaling, health) from your code; you keep full control of resources but skip the manual setup.

2. Which file defines a build's phases and commands for AWS CodeBuild?

  • template.yaml
  • appspec.yml
  • Dockerfile
  • buildspec.yml (correct answer)

CodeBuild reads buildspec.yml (install/pre_build/build/post_build phases, artifacts). appspec.yml is for CodeDeploy; template.yaml is CloudFormation/SAM.

3. Which service orchestrates source, build, and deploy stages into an automated release pipeline?

  • AWS CodeArtifact
  • AWS CodePipeline (correct answer)
  • Amazon CodeGuru
  • AWS CodeCommit

CodePipeline models continuous delivery as stages (source -> build -> deploy...) integrating CodeCommit/GitHub, CodeBuild, and CodeDeploy or CloudFormation, triggering automatically on changes.

4. A team wants the same Lambda code promoted through dev, test, and prod without editing code, changing only settings per stage. What should they use?

  • Separate hard-coded functions per stage
  • One function with no configuration
  • Environment variables (and aliases) per stage (correct answer)
  • A single shared production role

Environment variables externalize per-stage settings (table names, endpoints) so the same artifact runs in each stage; aliases/versions distinguish stages cleanly.

5. A CloudFormation template must reference a security group ID created by a separate networking stack. Which mechanism links them?

  • Export the value and use Fn::ImportValue (correct answer)
  • Copy the ID into a hard-coded stack parameter
  • Use a DependsOn attribute across stacks
  • Enable drift detection on both stacks

A stack exports an output value; another stack imports it with Fn::ImportValue. This cross-stack reference keeps stacks decoupled and prevents deleting an exported resource still in use.

6. A CloudFormation update might change or replace critical resources. What lets a developer preview exactly what will happen before applying it?

  • A stack policy denying all updates
  • Enabling termination protection on the stack
  • A change set generated from the new template (correct answer)
  • A DeletionPolicy of Retain on every resource

A change set shows the proposed additions, modifications, and (importantly) resource replacements before you execute it, so you can catch destructive changes. Stack policies and termination protection restrict actions but do not preview diffs.

Related objectives