Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

Chapter 5: Amazon EC2 (Elastic Compute Cloud)

Come on, friends – now for the most important service in AWS: EC2. Today we will build our very first cloud server. In this chapter we follow one example: a dairy brand like Amul (sample data, for practice) wants to host its website on EC2. The size of the server (instance type), the OS (AMI), the key pair, the security group, launching, connecting with SSH, Elastic IP and the difference between stop and terminate – we will see all of it step by step. Begin with the planning exercise below. Use the optional launch lab after confirming your training account, resource choices, cost plan and cleanup steps.

In this chapter

  • Why EC2: cloud vs on-premises
  • AMI, instance type and key pair
  • Security groups, regions and AZs
  • Instance families and pricing models
  • Launching an instance step by step
  • SSH from Linux, macOS and Windows
  • Elastic IP and the instance lifecycle
  • EC2 best practices

Concepts in this chapter

  1. 5.1Why EC2? Cloud vs on-premises
  2. 5.2What is EC2? Key concepts
  3. 5.3How to launch an EC2 instance (console, step by step)
  4. 5.4Connecting to your instance
  5. 5.5Elastic IP (static public IP)
  6. 5.6Instance lifecycle: stop, reboot, hibernate, terminate
  7. 5.7EC2 best practices

Review and practice

  1. ★Common Mistakes I See Students Make
  2. ★Interview Questions
  3. ★Practice Questions and Lab Exercises

Follow a launch decision into a verified application

Follow a launch decision into a verified applicationImage and instance typeSoftware basis and capacityNetwork and identitiesPlan user and administrator pathsRunning instanceCheck initialization and storageUseful operationVerify, monitor and clean up
Read all steps
  1. Image and instance type

    Choose the approved starting image and compatible resource capabilities. The image and type are different decisions; neither contains a completed application operating plan.

  2. Network and identities

    Select the subnet, routes, address arrangement and security rules. Distinguish AWS API permissions from the operating-system account and the application workload role.

  3. Running instance

    Observe lifecycle state and the named status checks. Verify that initialization completed and that data is on the intended storage. Running does not prove the booking workflow works.

  4. Useful operation

    Test the intended sample booking operation and record the result. Use the resource list for monitoring and cleanup, including retained volumes, snapshots and addresses.

Give the workshop application a computer that stays available

A college workshop lets students reserve a machine for a practical session. At first, a student developer runs the booking application on a laptop. The application works while that laptop is powered on and connected. When its owner closes the lid or leaves campus, other students cannot reliably use it. The workshop needs a computer with an appropriate network connection, enough resources and a clear maintenance plan. Amazon EC2 is one way to provide that computer.

EC2 means Elastic Compute Cloud. It lets you provision computing capacity through AWS instead of first purchasing and installing a physical server yourself. You choose a configuration, launch an instance, install or supply your software and operate it for the required period. The instance is a particular running or stopped compute resource in your AWS account. It has an instance identifier that lets you distinguish it from other resources.

Provision means arranging a resource so it can be used. Launch means creating an instance from the chosen settings. Neither word means the booking application is automatically complete. A newly launched operating system still needs the right application, configuration, access and data. This distinction helps you understand the division of work: AWS provides the infrastructure service, while your team still makes decisions about the guest system and the application it runs.

For a beginner, picture a complete request. A student opens a booking page. The request reaches a permitted network endpoint, a web application processes it, and a data store records the booking. The instance supplies computing resources for some part of this work. It is not the same thing as the domain name, the application or the database. Those components may run together in a small lab, but they remain different responsibilities.

This chapter develops the decisions behind a first Linux instance. Its guided exercises include a planning exercise that creates no resources and an optional account-based observation lab. Launching resources requires an authorized training account and a cost plan. Read the cleanup steps before any launch so you know which resources are temporary and which data must be retained.

Understand the resources that execute an application

A processor executes instructions. Memory holds data and working state that programs need while running. Storage retains operating-system files, application files and other saved data. Network interfaces exchange information with other systems. An application uses all of these resources in different proportions. A simple booking form may use modest processor time, while a simulation or image-processing job may need much more.

An EC2 instance type describes a combination of resource capabilities. A virtual CPU, usually written vCPU, is a unit of processor capacity exposed to the instance. The exact relationship to physical cores and threads depends on the instance and processor design. Memory capacity is a separate property. Two types with similar vCPU counts can provide different memory, network or storage characteristics.

Most familiar EC2 learning examples use virtual machines. Virtualization allows infrastructure to present isolated computing environments on underlying hardware. AWS also offers specialized options, including bare-metal instances, so defining EC2 as only one kind of virtual machine is too narrow. The beginner task is to choose a supported configuration appropriate to the workload and understand the responsibilities exposed to the guest operating system.

Suppose the workshop app is slow. Buying more memory will not automatically repair a slow database query or a blocked network request. Likewise, adding processor capacity may not help a program waiting for storage. Resource selection begins with the workload: number and size of requests, memory use, data access and acceptable response time. Measure representative behavior before changing the configuration repeatedly.

Some instance families are designed for burstable workloads. They use credit mechanisms that affect sustained processor behavior and, depending on configuration, cost. That can suit an application with short peaks and long quiet periods, but it should not be confused with unlimited sustained performance. Read the chosen type’s characteristics rather than treating a small instance name as a universal recommendation.

Choose the starting software separately from the hardware shape

An Amazon Machine Image, or AMI, supplies information used to create and boot an instance. It includes the starting software image and block-device mapping information. An instance type supplies the resource characteristics. These choices answer different questions. The image describes the software starting point; the type describes the capacity and supported platform on which it will run.

In the workshop, imagine selecting an approved Linux image containing the operating system and then choosing a compatible type. Launching two instances from that image gives you two separate resources with the same starting software basis. Editing a file on the first instance does not automatically edit the second instance or the source image. Each running system has its own subsequent state.

Compatibility matters. An image built for one processor architecture cannot simply be used with an incompatible type. Availability is also regional: an AMI identifier refers to an image in its Region. Copying an identifier from a tutorial without checking Region, architecture and publisher can select the wrong starting point or fail to launch.

Use an image from a trusted, intended publisher and check its operating-system version, support policy and possible software charges. A familiar word in an image name is not enough to establish its origin. Public and marketplace images may include different software, licensing or configuration. The training exercise should identify the approved image choice, and students should record the image identifier actually used.

A custom image can make repeated launches more consistent, but it needs maintenance. If an image contains an old package or a mistaken configuration, every new instance launched from it can inherit that starting problem. A useful image-building process updates software, removes unintended sensitive material and verifies a clean launch. Capturing an image is therefore part of a reproducible workflow rather than a substitute for understanding its contents.

Place the instance in a Region, an Availability Zone and a subnet

A Region is an AWS geographic service area. Within a Region, Availability Zones provide distinct infrastructure locations designed to support fault isolation. A subnet is a range of network addresses in one Availability Zone. Selecting a subnet therefore also selects the Availability Zone for an instance launched into it. These are related location decisions at different levels.

Choose a Region based on the application’s users, available services, organizational requirements and cost considerations. For the workshop, a nearby Region may reduce network delay for its students, but proximity alone is not the whole decision. Required services and instance types must be available, and the institution’s data requirements must be considered. Keep all resources for the introductory lab in the intended Region unless the exercise explicitly needs more.

The VPC, or virtual private cloud, contains the network configuration used by the instance. A subnet belongs to that VPC. Its route-table association influences where network traffic can go. Selecting a subnet with a familiar name does not prove it provides the intended path. Inspect the actual association and relevant routes when connectivity matters.

One instance in one Availability Zone is a useful learning setup, but it is also a single application location. If the instance or its application fails, the booking service may stop. A more resilient design can use multiple instances across appropriate Zones, a load balancer and a data architecture that supports recovery. Merely placing one instance in AWS does not create that complete design.

Record the Region, instance identifier, VPC identifier, subnet identifier and Availability Zone in the lab notebook. A console set to a different Region can make a resource appear to be missing. Accurate identifiers also help when two resources have similar human-readable names. Names support people; service identifiers distinguish the actual resources.

Separate saved data from the lifetime of a running machine

A running process uses memory for its current work. Saved files require storage. Many EC2 instances use Amazon EBS volumes, which provide block storage attached to the instance. The operating system can place a filesystem on a block device and use it for directories and files. The root volume contains the operating system’s starting filesystem in a typical EBS-backed Linux setup.

An EBS volume has its own identity and configuration. Stopping an EBS-backed instance normally leaves its attached EBS data available for a later start. Termination is a different operation: volumes configured for deletion on termination are deleted with the instance. Inspect that setting for every important volume rather than assuming all disks are either always retained or always removed.

Some instance types provide instance-store storage associated with the underlying host. Its lifecycle differs from EBS. Data can be lost when the instance stops, terminates or experiences relevant hardware loss. Do not place the workshop’s only copy of booking records on temporary storage merely because it appears as a usable disk. Choose storage based on the data’s retention and recovery requirements.

Memory, an EBS volume and a snapshot are also different. Memory is active working state. A volume is a usable storage resource. A snapshot is a point-in-time backup representation used for recovery or creating volumes. The application’s consistency requirements still matter when taking backups. A stored snapshot does not prove that a database can be recovered to the required application state without the appropriate procedure.

For a small lab, you might keep a harmless note on the root EBS filesystem and observe that it remains after a planned stop and start. That teaches persistence across that specific transition. It does not justify skipping backups or keeping the only copy of important data on the instance. Explain exactly which lifecycle event your observation tested.

Decide how the application and administrator will reach the instance

The instance’s network interface receives addressing appropriate to its subnet and configuration. A private IPv4 address supports communication within the relevant routed private network. Public addressing can support a public path when the network and security configuration permit it. IPv6 is another addressing option when configured. An address by itself is not a guarantee of reachability.

For a simple direct public IPv4 connection, several pieces must agree: the intended public address association, subnet routing through an internet gateway, the security rules and the application listener. An instance can sit in a public subnet and still lack the necessary public address or allowed service. The operating system can also have its own firewall and binding configuration.

An automatically assigned public IPv4 address can change across a stop and start. An Elastic IP is an allocated public IPv4 resource that can provide a stable address association in an appropriate design. Stability is its addressing role; it does not make a stopped application available or duplicate the instance. Public IPv4 resources can also contribute to cost, so include them in the lab’s cost and cleanup review.

For a multi-instance application, a stable domain and load-balancer endpoint often provide the public entry point while application instances use private addresses. The exact architecture depends on the workload. Do not give every backend a public administrative path simply because a first tutorial used a directly reachable instance.

Keep application access and administrative access separate in your plan. Students using a booking page need the intended web protocol. An administrator may need an approved SSH or managed-session path. These are different audiences, ports, identities and operational needs. Draw both paths before creating rules so each permission has an explained purpose.

Use security groups to allow the intended connections

A security group controls permitted network traffic for associated resources and interfaces. Its inbound rules describe allowed incoming traffic, and its outbound rules describe allowed outgoing traffic. Rules consider properties such as protocol, port and source or destination. A rule is a network permission; it does not create a user account or start the application listening on the selected port.

For an SSH-based training path, restrict the administrative source to the approved origin for the lab. The source AWS receives may be the public outbound address of a home network, campus gateway or VPN rather than the laptop’s private Wi-Fi address. If the source changes, diagnose the new path and update the intended rule deliberately. Broadening access without understanding the source hides the actual issue.

Security groups are stateful. Related return traffic for allowed connections is handled through connection tracking, so a separate mirror rule is not normally needed merely for the reply. Network ACLs are a separate subnet-level control with different behavior. Route tables are separate again: allowing traffic does not supply a missing route, and a valid route does not override a denied connection.

For the booking application, write down each required connection as a sentence: the public entry point receives web requests; the application tier receives requests from its intended caller; the database receives its application connection. In a suitable architecture, security-group references can express relationships between tiers. The introductory lab can use a simpler setup while keeping the same principle of explaining every rule.

After changing a rule in your own lab, test the intended operation and record the result. A browser timeout, an SSH authentication rejection and an HTTP error indicate different stages. Opening an additional port will not correct a wrong Linux username or repair an application’s database query. Use the observation to choose the next check.

Distinguish AWS permissions from the account inside Linux

An AWS identity determines which AWS API operations a person or program may perform. A Linux account determines identity and permissions inside the guest operating system. Being allowed to launch an instance in the AWS console does not automatically mean every Linux account will accept your SSH key. Conversely, permission to log in to Linux does not automatically grant permission to create AWS resources.

The default login account depends on the selected image. Tutorials often show ec2-user for Amazon Linux and ubuntu for Ubuntu, but you should use the image’s documented connection instructions. A username identifies the intended operating-system account. The authentication method must match what that account and SSH server are configured to accept.

A key pair used for SSH has a public component and a private component. The remote account can recognize the public key, while the client proves possession of the corresponding private key during authentication. Keep the private key protected and available through the approved client configuration. It is not a file that students should paste into a website or include in a public source repository.

An application running on EC2 may also need to call another AWS service. An IAM role attached through the appropriate instance-profile mechanism can supply temporary credentials to that application through the supported credential process. This avoids distributing a person’s long-lived access keys into every instance. The role’s policy should permit the actions and resources the application needs.

For example, the booking application might need to read a particular configuration object. Its operating-system permissions control reading local files and running processes; its IAM permissions control the AWS API request. A failure at either boundary needs the corresponding evidence. Naming both identities in your architecture notes prevents treating every access-denied message as the same kind of problem.

Choose a connection method with clear prerequisites

Traditional SSH is one connection option for a Linux instance. Other options include managed connection workflows such as EC2 Instance Connect and Systems Manager Session Manager, where supported and configured. Each method has prerequisites. A button in the console is not evidence that the instance already has the required software, identity permissions and network access for that method.

For SSH, confirm the intended host address, account name, private-key configuration and network route. Verify the remote host identity using the lab’s trusted information. A changed host-key warning should be investigated because the destination may have changed or the instance may have been replaced. Removing the warning without understanding it discards a useful identity check.

For a managed-session method, inspect its documented requirements rather than opening an inbound SSH rule automatically. The instance may need a suitable agent, an IAM role and connectivity to service endpoints. The person initiating the session also needs the appropriate AWS permissions. The resulting access can have different logging and operational controls from a direct SSH connection.

After connecting, run a harmless identity check such as hostname, whoami and pwd. These reveal which machine, account and working directory your terminal is using. Keep a local terminal and a remote terminal clearly labeled when copying files or comparing results. Many beginner mistakes come from running the right command on the wrong machine.

The main course explains the options so you can choose the one intended by your training environment. Do not combine pieces from incompatible connection tutorials without checking their assumptions. A private-only instance reached through a managed service has a different access design from a directly reachable public SSH lab.

Make startup configuration understandable and repeatable

User data is information supplied with an instance launch for the guest to interpret. On supported Linux images, cloud-init commonly processes startup configuration and scripts. You might use it to install an approved package, create a harmless configuration file or start an application. The instance reaching a running state does not prove these application-setup steps finished successfully.

For the workshop, separate the operating-system launch from application readiness. The machine can boot while a package download fails or a script encounters a syntax error. Inspect the initialization result and appropriate logs, including cloud-init output where the selected image uses it. A known application response is stronger evidence of readiness than assuming the script must have worked.

Default first-launch behavior is not the same as running a script on every reboot. Configuration can change that behavior, so understand the image and initialization mechanism being used. Avoid putting long-lived secrets in user data. Keep bootstrap instructions small enough to review and make repeated execution behave deliberately rather than creating duplicate users, files or database rows.

Instance metadata supplies information about the instance and its environment. IMDSv2 uses a session-token flow for access. Use supported software and the account’s intended metadata settings. A failed old metadata command may indicate an incompatible access method, not missing instance information. Metadata and application credentials require appropriate handling; the beginner verification exercise can use console identifiers without retrieving credential material.

Read the named health check and verify the useful operation

An EC2 instance has a lifecycle state such as pending, running or stopped. It also has status-check results. These describe different observations. Running means the instance is in that lifecycle state; it does not establish that the workshop booking application can accept a reservation. Read each check’s name and scope before deciding what has been proved.

Current EC2 documentation distinguishes system, instance, attached-EBS, application and performance check types. The availability and configuration of a type matter: application checks are opt-in, and performance checks apply to supported accelerated instance types. Avoid memorizing a fixed passing-check count from an old screenshot as the definition of a healthy application.

The workshop should test a useful operation. Can a student read available sessions? Can an authorized test user submit a harmless booking? Can the application retrieve that booking afterward? These checks exercise more of the workflow than merely receiving a response from the operating system. An HTTP check that requests one health path still proves only what that path actually tests.

Monitoring then follows the requirements over time. Processor load, storage behavior, network traffic, application errors and response time can provide different evidence. A high processor reading during a scheduled calculation might be expected. Repeated booking failures at low processor usage could point elsewhere. Define what a good result means before choosing an alarm threshold.

Keep timestamps and resource identifiers with observations. If one instance is replaced, yesterday’s logs may belong to the old instance. If requests pass through a load balancer, identify which target handled the failed request. Useful monitoring connects symptoms to the actual resources and operations involved.

Predict the effects of reboot, stop, start and terminate

Reboot restarts the operating system on the instance through the relevant EC2 operation. Stop and start are a different lifecycle transition for supported EBS-backed instances. Termination ends the instance permanently. These actions have different effects on availability, memory, storage and addressing. Choose the action based on the intended result rather than treating all three as interchangeable ways to refresh a server.

A reboot interrupts active work while the operating system restarts. Programs need to start again according to their configuration. Unsaved memory state is not the same as a saved file. The workshop application should be able to recover through its normal service startup and data-storage design, but that is something to configure and test.

Stopping an ordinary EBS-backed instance releases its running compute allocation while preserving retained EBS storage. A later start can place it on different underlying hardware. Its automatically assigned public IPv4 can change. Record the current address after start before trying the old connection command. The instance identifier and retained storage provide a different form of continuity from the public address.

Instance-store data needs special attention because it does not provide EBS-style persistence across stop and start. Hibernate is another supported option for qualifying configurations and has its own prerequisites and behavior. Do not assume every instance can hibernate or that it is equivalent to an ordinary stop. The introductory lab uses only the transition explicitly approved by its instructions.

Termination cannot be undone to recover that same instance. Volumes marked for deletion on termination are deleted. Other allocated resources may remain, including retained volumes, snapshots or addresses. Before terminating a lab, identify which data must be kept and verify the recovery method. Afterward, inspect the associated resources rather than treating a terminated state as proof that every resource and charge disappeared.

Estimate the whole lab instead of one hourly number

Compute usage is one part of a possible EC2 bill. Storage, public IPv4 addresses, snapshots, data transfer, software licensing and connected services can contribute as well. The applicable amounts depend on Region, selected resources, account arrangements and actual usage. Use the current pricing pages and your account’s billing information rather than copying an old tutorial’s cost claim.

Start with a resource list. For a simple exercise, record the instance type and planned running time, root volume type and capacity, public-address arrangement and any snapshot you intend to retain. If the architecture includes a NAT gateway or load balancer, list it separately. An application can stop while these other resources remain allocated.

Use a transparent worksheet. Write the applicable compute rate multiplied by the expected running duration, then list the storage and address estimates using their own pricing units. State any assumptions, such as the absence of significant data transfer. This is an estimate of a defined exercise, not a guarantee of the final bill. Compare it with actual usage after the lab.

Free Tier terms depend on the account’s program and eligibility. Newer credit and free-plan arrangements differ from the older twelve-month model. Check the actual credit balance, expiry, eligible resources and plan behavior in the training account. Do not assume that selecting a familiar small type grants every student a fixed number of free hours.

Set up the training account’s intended spending visibility before creating resources. A budget notification is a signal for action; it is not generally a universal hard stop on every possible charge. Schedule a cleanup review and verify that resources no longer needed have been removed or released. Retained EBS volumes can continue costing money while their instance is stopped.

Planning lab: design the instance without launching it

This exercise needs only a notebook and the relevant documentation. The workshop has a small booking application used during practical classes. The first training version serves harmless sample sessions, and the lab can tolerate downtime. Important institutional booking records are outside this exercise. Your task is to produce an explainable launch plan before touching a launch button.

  1. Write the application’s responsibilities. Distinguish serving the page, processing a booking and storing the result. Decide which parts the learning instance will run. State that combining them is a training simplification if a later architecture will separate them.

  2. Select an approved Linux image and a compatible instance family or type for the training requirements. Record the architecture and publisher. Explain the difference between the starting image and the resource capacity rather than simply copying their names.

  3. Choose the intended Region and training subnet. Record how the subnet’s Availability Zone follows from that choice. Draw the intended user path and administrative path. Identify which route and address assumptions each path requires.

  4. Write a security-rule table with purpose, protocol, destination port and permitted source. Administrative access should have an explained narrow source or use the intended managed-session design. A web rule should correspond to a service you actually plan to run.

  5. List storage resources and their retention. Decide which sample file will be used to demonstrate persistence. Record the root volume’s deletion-on-termination behavior and whether any additional volume or snapshot is planned.

  6. Choose a connection method and list its prerequisites. Identify the AWS permissions needed by the person and the operating-system account used inside Linux. If the application needs another AWS service, describe its intended role permissions separately.

  7. Prepare the cost worksheet and cleanup list. Assign a purpose and an end condition to every resource. Another student should be able to determine which items are temporary without guessing from their names.

Review the plan with a classmate. Ask them to explain how a browser request reaches the application and how an administrator reaches the operating system. If either explanation relies on an unstated default, add the missing assumption. A good plan exposes the decisions that a console wizard might otherwise hide behind preselected options.

The expected deliverable is a resource diagram, a rule table, a cost estimate and a cleanup checklist. There is no expected AWS bill or instance identifier because this exercise creates no resources. Its value is learning to predict a configuration before observing it.

Optional launch lab: observe one approved training instance

Use this exercise only in an authorized training account with an agreed resource choice and cost allowance. The planning lab should already identify the image, type, subnet and connection method. Do not substitute a production account or a shared instance just because it is available. Keep the application data harmless and limited to this exercise.

  1. Confirm the account and Region in the console. Open EC2 and start the instance-launch workflow. Give the instance a useful name tag, such as a workshop learning label, while remembering that the actual instance identifier is the service-level identity.

  2. Select the approved AMI and compatible instance type. Review the publisher, architecture and storage requirements. If the expected image or type is unavailable, resolve the mismatch instead of choosing an unrelated image with a similar name.

  3. Configure the intended connection method. For the SSH route, select the approved key-pair arrangement and protect the private component. For a managed method, confirm its prerequisites. Do not assume a key pair and an IAM role are interchangeable.

  4. Inspect the network settings. Select the planned VPC and subnet, address arrangement and security group. Review the actual rules and sources. Check that the path in your diagram corresponds to these settings.

  5. Review storage capacity, type and deletion behavior. Keep the exercise within the approved plan. If user data is used, keep its purpose simple and review it before launch. Never paste unknown initialization commands merely because a tutorial says they are convenient.

  6. Review the complete summary and launch the intended number of instances. Record the new instance identifier. Observe pending and running states and read the named status checks. Allow application initialization to finish before testing its result.

  7. Connect through the approved method. Run the harmless observation commands below. Compare the guest’s view with the console: operating-system identity, network interface and mounted filesystem describe different parts of the instance.

hostname
whoami
pwd
cat /etc/os-release
ip -brief address
df -h .

The exact output depends on the chosen image and configuration. The operating-system release should match the intended distribution. The account name should match the connection method’s selected account. The address displayed inside Linux may be private even when the console shows a public IPv4 association. The filesystem capacity should be interpreted separately from the instance’s memory size.

Create a small note only in a fresh directory owned by the connected training user. Record the directory path and its contents. If your instructor’s plan includes a stop/start observation, save the note on the intended EBS filesystem, stop through the approved EC2 control, and reconnect using the current address after start. Read the note again and compare the instance identifier and address values.

The expected observation is specific: the retained EBS note can survive the tested transition, while an automatically assigned public address may change. Do not infer that all storage types survive every lifecycle event. If the note is missing, first confirm the instance, account, filesystem and exact path before concluding that EC2 discarded it.

Record your actual observations beside the predicted results. Include the instance identifier, storage type and transition tested so another student can tell exactly what your experiment demonstrated.

Close the lab with data and resource checks

Begin cleanup by reading the resource list created before launch. Decide whether any lab output needs to be retained and verify that its saved copy can be read. Do not keep an entire instance indefinitely merely because the location of one useful note is unclear. Equally, do not terminate first and then discover that an essential file existed only on a volume configured for deletion.

Terminate the intended disposable instance when that is the approved end condition. Verify its identifier before taking the action and confirm the resulting state afterward. Inspect the associated EBS volumes and their deletion behavior. Review snapshots and allocated addresses separately. Release or remove only resources created for this exercise that are no longer needed; shared resources have their own owners and lifecycle.

If the lab used additional components such as a load balancer or NAT gateway, stopping the instance does not clean up those components. If it created a dedicated security group, check for remaining associations before removing it. Keep the cleanup reasoning tied to the recorded resources rather than searching for objects whose names merely look similar.

Finally, review usage and billing information with its reporting delay in mind. A recent cleanup may not immediately remove all earlier usage from a dashboard. The aim is to account for what was created, what remains allocated and what charges relate to the completed exercise. Save the notebook as evidence for the next lab.

Use the first failed observation to choose the next check

If you cannot find the instance, confirm account, Region and filters before assuming it was deleted. If it remains pending or reports a launch problem, inspect the specific console or API message. Capacity, compatibility, permissions and account constraints are different causes. Changing several unrelated settings at once makes it harder to understand which condition mattered.

If a connection times out, check the current destination, intended route and permitted source. If the SSH server answers but rejects authentication, investigate account and key configuration. If a managed session is unavailable, inspect its agent, role and endpoint prerequisites. These paths should be evaluated according to the method selected in the plan.

If the web service works locally but not from the intended client, compare the listener binding, host firewall and outside path. If HTTP answers with an application error, find the component that generated it and inspect its logs and dependencies. A status code is useful evidence that some web component responded; it is not a diagnosis by itself.

Write a short incident note containing the expected operation, actual result, resource identifiers, timestamp and next targeted test. This makes troubleshooting teachable. Another student can follow the reasoning and decide whether the next test supports or rejects the explanation.

Interview questions with explained answers

Explain the difference between an AMI, an instance type and an instance.

The AMI supplies the starting software image and related launch information. The instance type describes resource capabilities and compatibility. An instance is the particular resource created from the selected launch configuration. Several instances can share an image while having their own identities and later changes.

An instance is running. Can you conclude that the booking application works?

No. Running is a lifecycle state. I would inspect the relevant status checks and test the application’s intended operation. A passing check has a defined scope; an application may answer a health path while a booking dependency still fails. The useful operation needs its own verification.

What remains important after stopping an EBS-backed learning instance?

Retained EBS volumes and other allocated resources still need management and can incur costs. On a later start, an automatically assigned public IPv4 may change. I would verify the current address, service startup and retained data. I would not treat stop as permanent cleanup or a guarantee of zero charges.

How does an IAM role differ from the Linux account used for SSH?

The role provides AWS permissions through the supported temporary-credential mechanism for the workload. The Linux account identifies a user inside the guest operating system. They control different boundaries. A program can have permission to read a local file while lacking permission for an AWS API request, or the reverse.

Does an Elastic IP make a single instance highly available?

No. It provides a stable public IPv4 resource for an appropriate association. The application still depends on functioning compute, storage, network paths and software. Availability requires an architecture and recovery plan; a predictable address does not keep a stopped process serving requests.

How would you avoid turning a first EC2 lab into an unexplained bill?

I would identify the account’s actual plan and eligibility, list every planned resource, estimate its relevant cost and set up the intended spending visibility. I would record a cleanup plan before launch, inspect retained resources afterward and compare actual usage with the estimate. I would not rely on an old universal Free Tier claim.

Choose the explanation that fits the evidence

  1. The AWS console permits instance creation, but SSH rejects the username. Is the first likely check the AWS launch permission or the selected guest account and key?

    Answer and reasoning

    Inspect the guest account and authentication configuration after confirming that the SSH service answered. AWS API permissions and operating-system authentication are separate. A successful launch does not make every guest username valid.

  2. A retained EBS note survives stop/start, but the old public IPv4 no longer connects. Does the changed address prove that the note was deleted?

    Answer and reasoning

    No. Address association and retained EBS data have different lifecycle behavior. Read the instance’s current address and reconnect through the intended path before checking the saved note.

  3. A launch script failed to download a package, but the instance entered running state. Which conclusion fits: the application is definitely ready, or guest initialization needs its own verification?

    Answer and reasoning

    Initialization needs its own verification. Inspect the relevant logs and expected application result. A running instance can still have incomplete software setup.

  4. You terminate the instance while a separately retained snapshot remains. Must all storage-related charges immediately stop?

    Answer and reasoning

    No. A retained resource has its own storage and billing lifecycle. Review the lab’s resource list and keep or remove it according to its purpose and recovery requirements.

Revision cards for the launch plan

Image and capacity
An AMI is the software starting point; an instance type supplies resource characteristics. Check their compatibility and Region.
Location and network
The subnet is in one Availability Zone and belongs to a VPC. Routes and permissions determine the intended communication paths.
Two identity boundaries
AWS identities control API actions. Guest accounts control operating-system access. Workload roles and SSH key pairs solve different problems.
Useful health evidence
Read the named check and its scope. Verify a meaningful application operation instead of relying only on a running state.
Lifecycle and data
Reboot, stop/start and terminate have different effects. Know the storage type and deletion settings before choosing an action.
Complete cleanup
Account for instances, volumes, snapshots, addresses and any supporting services. Stopping one resource does not remove all the others.

Primary references

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Texas Solar Co is a solar energy business in Austin. Carlos Ramirez looks after its IT and cloud work. They count money in USD and run their AWS resources in the us-east-2 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 12

Easy Port for SSH

Security group rules need the right port.

Which TCP port must the security group open for SSH?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy List your EC2 instances

Before changing anything, see what is running and in which state.

Show details of all EC2 instances of Texas Solar Co in us-east-2.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Start an instance

Start it again in the morning when the team needs it.

Start the instance i-001510d5221111a2b.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Stop an instance

A stopped instance does not charge for compute, only for its disks.

Stop the instance i-001510d5221111a2b.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Connect to an EC2 server

SSH with a key file is the standard way to log in to a Linux EC2 instance.

Log in to the server 13.91.20.5 as ec2-user using the key texassolar-key.pem.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Create a security group

A security group is the firewall around your instance.

Create a security group named texassolar-web-sg with description "Web servers" in vpc-0225e01510deadbee.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Open port 80 to the world

Visitors can reach your website only if the security group allows HTTP.

Allow inbound TCP port 80 from 0.0.0.0/0 on security group sg-011225c015104c3b2.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Create a key pair

You need a key pair to SSH into new Linux instances.

Create a key pair named texassolar-key.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Launch one EC2 instance

Launching from the CLI is repeatable and fast, and the same command works in scripts.

Launch 1 instance from AMI ami-0111aad201d10abcd, type t3.micro, key pair texassolar-key, security group sg-011225c015104c3b2.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Monthly server cost

Estimate before you launch.

An instance costs USD 0.0416 per hour and runs 24×7 for 30 days. What is the bill in USD? (two decimals)

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Hard Resize an instance (vertical scaling)

When the server is too small, change its type while it is stopped.

The stopped instance i-001510d5221111a2b needs more power. Change its instance type to t3.large.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Allow SSH only from the office

Opening SSH to everyone invites attacks. Allow only your office IP (/32).

On sg-011225c015104c3b2, allow inbound TCP port 22 only from the office IP 49.36.8.10.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.