AWS Builder Center
AWS Cloud Fundamentals: Infrastructure, Security & EC2

AWS Cloud Fundamentals: Infrastructure, Security & EC2

Explore AWS cloud fundamentals, including Regions, Availability Zones, EC2, IAM security, the Shared Responsibility Model, and cloud architecture. Learn how AWS infrastructure works through practical examples, CLI commands, and essential cloud operations concepts.

Series: Skill Builder Digital Classroom - AWS Cloud Technical Essentials (11 articles)

  1. 1
    AWS Cloud Fundamentals: Infrastructure, Security & EC2 This article

Everything in the Cloud is an API Call: A First-Principles Guide to AWS Infrastructure, Security, and Compute

Most engineers treat the cloud like magic until the bill arrives or a production server goes dark at 2:00 AM.

Strip away the marketing gloss and the 200+ service acronyms, and Amazon Web Services (AWS) reduces down to two foundational truths:

  1. The cloud is still physical hardware concrete, fiber-optic cables, and silicon organized into fault-tolerant clusters.
  1. Every piece of AWS infrastructure is provisioned, secured, and mutated through authenticated, authorized API calls.
When you understand those two truths, you stop memorizing console clicks and start thinking like an operator and systems architect.

While going through Module 1 of AWS Cloud Technical Essentials on AWS Skill Builder I documented both the core architectural models and the Day-1 production runbooks that separate resilient systems from fragile proof-of-concepts. Whether you are deploying a corporate employee directory, evaluating cloud trade-offs, or debugging a broken deployment, these are the first principles you cannot afford to skip.



AWS cloud architecture diagram showing a developer accessing AWS services through an API. Inside the


Note on Practical Examples: The scenarios, cost projections, CLI commands, IAM policies, and EC2 configurations presented in this article are illustrative educational examples intended to explain AWS concepts and recommended practices. They do not represent personally verified deployments, performance benchmarks, or production-tested configurations. Actual results may vary depending on the AWS environment, workload, and configuration. Readers should review, customize, and validate all examples before applying them to real-world infrastructure.

1. The Real Value of Cloud: Eliminating "Undifferentiated Heavy Lifting"

Imagine your engineering team needs to test a new application feature in a Quality Assurance (QA) environment that mirrors production by Friday afternoon.

In a traditional on-premises deployment, creating that QA environment is a supply-chain problem. You submit a purchase order, wait six weeks for physical servers to clear customs, rack and stack hardware, run copper and fiber cabling, provision redundant power, and install operating systems. While your developers wait for sheet metal, your time-to-market bleeds.

In a cloud deployment, infrastructure becomes software. You provision an entire environment through infrastructure APIs and automated templates in four minutes, run your integration tests for two hours, and tear it down before dinner. And if you operate legacy mainframes or local databases that must stay on-site while extending compute into the cloud, a hybrid deployment bridges the two worlds.

AWS calls racking servers, patching hypervisors, and replacing failed RAID drives "undifferentiated heavy lifting." Your customers never buy your product because of how neatly you labeled the patch panels in your server closet. They buy your product for your code, your speed, and your business logic.

Side-by-side diagram comparing on-premises infrastructure with AWS Cloud. The left column shows phys


Moving to the cloud unlocks six specific operational advantages:

  • Pay-as-you-go pricing: Stop paying for idle server racks waiting for a once-a-quarter traffic spike. Pay only for the services and resources you provision and consume under their pricing models.
  • Massive economies of scale: AWS aggregates hardware procurement and power usage across millions of active customers, passing down lower unit economics than almost any single enterprise can negotiate alone.
  • Stop guessing capacity: Over-provision on-premises hardware, and you burn capital. Under-provision, and your site crashes during peak load. Cloud elasticity lets you scale out or scale in automatically based on real-time metrics.
  • Speed and agility: Provisioning compute in minutes rather than months lowers the cost of curiosity. Engineering teams can experiment, benchmark, and ship without waiting on hardware queues.
  • Realize cost savings: Trade upfront capital expenditure (CapEx) locked in depreciating data centers for variable operational expenditure (OpEx) provided you enforce disciplined cost governance.
  • Go global in minutes: Deploy workloads across AWS Regions worldwide to place your application milliseconds away from your end users.
Consulting Trade-Off: Cloud OpEx vs. Unmanaged Spend (The FinOps Reality)

The Executive Trap: Moving to the cloud does not automatically guarantee lower infrastructure costs. Consider an organization migrating 50 oversized, always-on virtual machines from an on-premises environment to Amazon EC2. Without workload assessment, instance right-sizing, or appropriate pricing strategies, the organization could end up paying more than expected. Effective cloud cost optimization requires aligning compute capacity, utilization patterns, and pricing models with actual business needs.

How Architects Advise Stakeholders: Cloud economics only beat on-premises economics when you pair elasticity with automated governance:


Consulting Projection: If an organization runs a 50-instance non-production fleet 24/7 on On-Demand pricing, automating stop/start schedules via EventBridge + Systems Manager alongside Compute Savings Plans on steady-state nodes typically yields a ~40–70% compute reduction the single fastest first win in a FinOps review.


2. The Anatomy of AWS Global Infrastructure

Suppose you are storing employee profile photos for a corporate directory application. If those photos live on a single server under your desk and the power supply catches fire, your company directory is gone.

When you upload those photos to AWS, they do not float in an abstract ether they land on physical drives inside hardened facilities. To protect your application against everything from backhoes slicing fiber lines to regional floods, AWS organizes its physical footprint into a three-tier nested hierarchy:

  1. Data Centers: Secure, unmarked physical facilities housing thousands of servers, storage arrays, and redundant networking gear. Customers never choose a specific data center directly.
  1. Availability Zones (AZs): One or more discrete data centers with independent power, cooling, and networking, physically separated by meaningful distance (up to 60 miles / 100 km apart) so a single local disaster cannot take down two AZs simultaneously, yet connected via high-speed, ultra-low-latency private fiber links (e.g.,  us-east-1a ,  sa-east-1b ).
Regions: Geographically isolated areas around the world consisting of three or more Availability Zones (e.g., Northern Virginia as  us-east-1 , Tokyo as  ap-northeast-1 ). Cross-Region data replication is never automatic unless you explicitly configure it or use a service feature built for it.
AWS infrastructure hierarchy diagram showing the us-east-1 Region containing three isolated Availabi


How Solutions Architects Choose a Region (The 4-Pillar Filter)

When stakeholders ask, "Which AWS Region should host our new workload?", evaluate the decision in this strict order:

  1. Compliance (The Binary Filter): Laws beat physics. If GDPR, RBI data localization mandates, or healthcare regulations require citizen data to remain inside a sovereign boundary, your list of eligible Regions narrows immediately. If it isn't legal, nothing else matters.
  1. Latency (The Physics Filter): No cloud engineer can negotiate with the speed of light in fiber. If 90% of your active users are in Oregon, hosting your transactional database in São Paulo ( sa-east-1 ) injects roughly 160–180 ms of unavoidable round-trip network latency on every query. Put your compute close to your users.
  1. Service Availability (The Feature Filter): AWS does not launch every new service or instance family in every Region on day one. Before locking in a Region, verify that every service your architecture relies on (such as specific Bedrock models, VPC Lattice, or Graviton4 instances) is live there.
  1. Pricing (The Economic Filter): AWS pricing varies across Regions due to differences in local infrastructure and operating costs, including land, fiber connectivity, electricity, and taxes. For example, a Linux-based Amazon EC2  t3.micro  On-Demand instance costs approximately $0.0168 per hour in São Paulo ( sa-east-1 ), compared with $0.0104 per hour in Northern Virginia ( us-east-1 ) or Ohio ( us-east-2 )—a difference of approximately 61.5%. Actual pricing differences depend on instance type, operating system, and purchasing model. Before selecting a Region, compare current costs using the AWS Pricing Calculator while accounting for latency, compliance, and service availability.

Service Scope and Edge Caching

To architect resilient systems, you must know the blast radius scope of every AWS resource you provision:

  • Zonal Resources: An Amazon EC2 instance or an Amazon EBS volume lives inside a single Availability Zone. If  us-east-1a  experiences an outage and your only EC2 server lives there, your application goes down unless you architect across multiple AZs behind an Elastic Load Balancer.
  • Regional Services: Standard Amazon S3 buckets and Amazon DynamoDB tables operate at Regional scope. Behind the scenes, AWS automatically replicates your objects and records across multiple Availability Zones within that Region no extra configuration required.
  • Global and Edge Services: Services like AWS IAM, Amazon Route 53, and Amazon CloudFront operate globally. CloudFront uses a worldwide network of Edge Locations and Regional Edge Caches so a user in Sydney does not have to wait for a TCP handshake and asset download all the way from an origin server in London.

AWS CloudFront architecture diagram showing how edge caching reduces latency between an Amazon S3 or



Consulting Trade-Off: Single-AZ vs. Multi-AZ vs. Multi-Region Decision Matrix

High availability is not free. Every nine of uptime you add multiplies both infrastructure cost and operational complexity. When advising stakeholders, frame the architecture choice around Recovery Time Objective (RTO) how fast you recover and Recovery Point Objective (RPO) how much data you can afford to lose:


Advisory Pattern: Moving from a single-AZ architecture to a Multi-AZ design using an Application Load Balancer, an Auto Scaling Group, and Amazon RDS Multi-AZ can improve application availability and resilience against infrastructure failures. However, achieving specific Recovery Time Objectives (RTOs) and Recovery Point Objectives (RPOs) requires careful architecture design, appropriate failover mechanisms, application-level testing, and cost evaluation. Multi-AZ is a valuable resilience strategy, but it does not guarantee uninterrupted application availability or zero data loss under every failure scenario.


3. Interacting with AWS: Console, CLI, and SDKs

When you own a physical server in a closet, you manage it with a crash cart, a keyboard, and a monitor. When your infrastructure is virtual, every action creating a bucket, launching a server, attaching a firewall is an HTTPS request sent to an AWS Application Programming Interface (API) endpoint.

AWS gives you three native ways to construct and sign those API calls:





Instead of clicking through five screens in the browser to list your storage buckets, a single AWS CLI command hits the S3 endpoint and returns structured data:


Bash
aws s3api list-buckets

And inside a Python Flask application, you can inspect or manipulate your virtual machines in four lines of code using the AWS SDK for Python ( boto3 ):


Python
import boto3

ec2 = boto3.client('ec2', region_name='us-east-1')
response = ec2.describe_instances()
print(response)

Behind the scenes,  boto3  locates your credentials, serializes your request, signs it cryptographically using AWS Signature Version 4 (SigV4), sends it over TLS to the regional EC2 API endpoint, and parses the returned XML/JSON into a Python dictionary.

🔧 In Practice (Cloud Ops): Why ClickOps Fails During an Audit—And the CLI Triage Pattern

Imagine a security auditor asks you: "Give me a list of every currently running EC2 instance in  us-east-1 , its Instance ID, its Private IP, and the IAM Instance Profile attached to it—right now."

Consider an AWS account containing 80 EC2 instances. Manually inspecting each instance through the AWS Management Console can be repetitive and time-consuming. A Cloud Ops engineer can instead use the AWS CLI with server-side filtering ( --filters ) and JMESPath queries ( --query ) to retrieve the relevant instance details in a structured table.


Bash
aws ec2 describe-instances \
--region us-east-1 \
--filters "Name=instance-state-name,Values=running" \
--query "Reservations[].Instances[].{ID:InstanceId,Type:InstanceType,PrivateIP:PrivateIpAddress,IAMProfile:IamInstanceProfile.Arn}" \
--output table

Output:


Plaintext
-------------------------------------------------------------------------------------------------------------
| DescribeInstances |
+----------------------+----------------------------------------------------------+---------------+---------+
| ID | IAMProfile | PrivateIP | Type |
+----------------------+----------------------------------------------------------+---------------+---------+
| i-0a1b2c3d4e5f6g7h8 | arn:aws:iam::123456789012:instance-profile/EmpWebAppRole| 10.0.1.42 | t3.micro|
| i-0987654321fedcba0 | None | 10.0.2.19 | t3.small|
+----------------------+----------------------------------------------------------+---------------+---------+

In this illustrative output, the second EC2 instance has  None  under  IAMProfile , indicating that no IAM Instance Profile is attached. This is not automatically a security vulnerability, but it warrants further review if the workload requires AWS API access. Engineers can investigate whether the instance uses an appropriate authentication mechanism instead of relying on static credentials.

Cloud Ops Efficiency: Automating EC2 Inventory and IAM Visibility
Consider a regional fleet of 80 EC2 instances. Manually inspecting each instance through the AWS Management Console can become repetitive, time-consuming, and prone to oversight.
A more scalable approach is to use  aws ec2 describe-instances  with server-side filtering ( --filters ) and JMESPath queries ( --query ) to retrieve a structured inventory of running instances, including their Instance IDs, private IP addresses, instance types, and attached IAM Instance Profiles.
This approach reduces manual inspection, improves consistency, and makes it easier to identify instances without an attached IAM Instance Profile for further security review. Rather than relying on individual Console checks, cloud operations teams can integrate these commands into repeatable auditing and infrastructure governance workflows.
Operational Takeaway: CLI-based inventory queries provide a repeatable way to assess EC2 configurations at scale, improving visibility and reducing manual effort without requiring instance-by-instance Console inspection.


4. Security and the Shared Responsibility Model

Who is responsible for security in AWS you or Amazon?

Both. And misunderstanding where Amazon's job ends and yours begins is the root cause of almost every major cloud data breach.

Think of AWS as a master contractor that builds a high-security apartment building. The builder is responsible for making sure the concrete foundation won't crack, the perimeter fence is guarded 24/7, and the structural walls are fireproof. That is Security OF the Cloud.

Once you lease an apartment inside that building, it is your job to lock your front door, decide who gets a spare key, and bolt your safe to the floor. If you leave your front door wide open with a neon sign pointing to your wallet, you cannot blame the building architect. That is Security IN the Cloud.

  • AWS Responsibility (Security OF the Cloud): Physical security of data centers, biometric access controls, global fiber infrastructure, physical servers, storage drives (including physical destruction of decommissioned drives), host operating systems, and the Nitro virtualization hypervisor.
  • Customer Responsibility (Security IN the Cloud): Guest OS patching on EC2, application code security, IAM least-privilege policies, Security Group firewall rules, encryption key management, and public/private access settings on storage buckets.
Crucially, this boundary line is not fixed it shifts upward or downward depending on the service abstraction you choose:

  • Infrastructure Services (IaaS e.g., Amazon EC2): You rent virtualized hardware. You are responsible for patching Linux/Windows, hardening SSH, configuring host firewalls, and managing the application runtime.
  • Container & Platform Services (e.g., AWS Fargate, Amazon RDS): AWS takes over host OS patching and database engine maintenance; you remain responsible for network rules, database user permissions, and schema/data encryption.
  • Abstracted Services (SaaS/Serverless e.g., Amazon S3, DynamoDB): AWS manages the hardware, the OS, and the storage platform. Your job narrows down to three critical levers: data classification, encryption settings, and access policies.

AWS Shared Responsibility Model diagram illustrating the division of cloud security responsibilities

Consulting Trade-Off: Moving Up the Shared Responsibility Stack to Cut Operational Overhead

When advising lean engineering teams (fewer than 15 developers), every hour spent patching Linux kernels on EC2 or managing custom database failover scripts is an hour stolen from core product features.

Advisory Scenario: For a lean engineering team running self-managed PostgreSQL on Amazon EC2, migrating to Amazon RDS Multi-AZ can reduce operational overhead by shifting underlying OS maintenance, database infrastructure management, automated backups, and failover orchestration to AWS. Although Multi-AZ deployments introduce additional infrastructure costs, they can improve database availability and allow engineers to focus more on application development and optimization. From a compliance perspective, AWS-managed infrastructure controls and available audit documentation can help support SOC 2 readiness, while the organization remains responsible for its own security configurations, access controls, and compliance requirements.
Consulting Takeaway: Evaluate the additional managed-service costs against potential reductions in maintenance effort, operational risk, and downtime. Actual financial benefits should be validated using workload-specific pricing and engineering effort estimates.


5. Identity is the New Perimeter: Root User & AWS IAM

In a traditional data center, your security perimeter was a physical firewall at the edge of the building. In the cloud, where every resource is reachable via an HTTPS API endpoint, identity is the perimeter.

When you first create an AWS account with an email address and password, you log in as the AWS Account Root User.

The root user is a break-glass superuser. It has unrestricted access to every resource and billing setting in the account, and it cannot be restricted by ordinary identity-based IAM policies. A compromised root account is an existential business event.


Root User Hardening Checklist (Day 0 Mandatory)

  1. Enforce Phishing-Resistant Multi-Factor Authentication (MFA): Immediately bind a hardware FIDO2 security key, passkey, or virtual authenticator app to the root user.
  1. Delete Root Access Keys: The root user should never have programmatic  AWS_ACCESS_KEY_ID  and  AWS_SECRET_ACCESS_KEY  pairs. If any exist, deactivate and delete them immediately.
  1. Lock Root Away and Use Federated Admin Access: Configure AWS IAM Identity Center with temporary credentials for daily administrative work. Only log in as root for the handful of account-level tasks that strictly require it (such as changing the account support plan or closing the account).

How AWS Identity and Access Management (IAM) Works

Every time an AWS API call hits an endpoint, AWS enforces a strict two-stage gate:

  • Authentication ("Who are you?"): Validates identity via passwords, MFA tokens, or cryptographic SigV4 signatures generated from access keys or temporary session tokens.
  • Authorization ("What are you allowed to do?"): Evaluates every applicable policy attached to the caller and the target resource. By default, all requests are implicitly denied.
Architectural Boundary Note: AWS IAM controls access to AWS infrastructure and APIs. Never create IAM Users for the thousands of customers logging into your web or mobile app. For customer-facing application authentication, use Amazon Cognito or an OIDC identity provider.

IAM gives you four core building blocks:

  1. IAM Users: Long-term identities representing a specific person or legacy service within a single account. New users start with zero permissions. (Modern best practice: avoid long-term IAM Users for humans; use federated roles via IAM Identity Center instead).
  1. IAM Groups: Logical collections of IAM Users (e.g.,  NetworkAdmins ,  QA-Engineers ). Never attach policies directly to individual users; attach policies to Groups or Roles so permissions scale cleanly.
  1. IAM Policies: JSON documents that define explicit  Allow  or  Deny  rules using four primary elements:  Effect ,  Action ,  Resource , and  Condition .
Here is a real-world Data Perimeter Guardrail Policy. It uses an explicit  Deny  with a  Condition  block to ensure that even if an engineer or application has  s3:*  permissions, they are blocked from reading or writing to any S3 bucket owned by an external AWS account (preventing data exfiltration to an attacker's S3 bucket):


JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyS3AccessOutsideMyBoundary",
"Effect": "Deny",
"Action": [
"s3:*"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:ResourceAccount": [
"222222222222"
]
}
}
}
]
}

  1. **IAM Roles (The Secret to Zero-Hardcoded-Key Architecture):**Suppose your Python Employee Directory app running on an EC2 instance needs to upload profile photos to an S3 bucket and write employee records to DynamoDB. Should you create an IAM User, generate permanent  AWS_ACCESS_KEY_ID  and  AWS_SECRET_ACCESS_KEY  strings, and paste them into a  .env  file on the server?
Never. Static keys sitting on disk inevitably leak into Git commits, application logs, or AMI snapshots.

Instead, you create an IAM Role ( EmployeeWebAppRole ) with two parts:

  • A Permissions Policy granting least-privilege access to your specific S3 bucket and DynamoDB table.
  • A Trust Policy allowing the EC2 service principal ( ec2.amazonaws.com ) to assume the role.
When you attach that role to your EC2 instance via an Instance Profile, the AWS Security Token Service (AWS STS) automatically delivers short-lived, rotating temporary credentials ( AccessKeyId ,  SecretAccessKey , and  SessionToken ) to the instance's local metadata endpoint. The AWS SDK ( boto3 ) fetches and refreshes those credentials automatically in memory zero secrets stored in your code.

AWS architecture diagram illustrating how an Employee Directory application running on Amazon EC2 se

In Practice (Cloud Ops): The 5-Step  AccessDenied  Troubleshooting Runbook

In production Cloud Ops,  "An error occurred (AccessDenied) when calling the PutObject operation"  is one of the most frequent tickets you will face. Even if an engineer swears "I attached  AmazonS3FullAccess  to the role!", AWS evaluates policies in a strict precedence hierarchy where a single explicit Deny overrides every Allow.

When debugging an IAM  AccessDenied  error, run this exact 5-step diagnostic checklist:


Plaintext
[API Request Fails with AccessDenied]
│
▼
Step 1: Verify Caller Identity ──► Run `aws sts get-caller-identity` on the host.
│ Are you actually running as the Role you think you are?
▼
Step 2: Check for Explicit Deny ─► Did an Organization SCP, Resource Control Policy (RCP),
│ or IAM Policy Condition (e.g., MFA, SourceIP, ResourceAccount) fire?
▼
Step 3: Check Permissions Boundary ─► Does the Role have a Permissions Boundary attached?
│ (Effective permissions = Intersection of Boundary AND Identity Policy).
▼
Step 4: Check Resource Policy ───► Does the target S3 Bucket Policy or KMS Key Policy have an
│ explicit Deny or missing cross-account trust?
▼
Step 5: Check KMS Encryption ────► CRITICAL TRAP: If the S3 bucket uses SSE-KMS with a Customer Managed Key,
`s3:PutObject` is NOT enough! The IAM Role also needs `kms:GenerateDataKey`
and `kms:Decrypt` on the KMS key ARN.

Fast CLI Verification: Instead of guessing which policy blocked the call, simulate the exact API action from your terminal using the IAM Policy Simulator CLI:


Bash
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::123456789012:role/EmployeeWebAppRole \
--action-names s3:PutObject kms:GenerateDataKey \
--resource-arns arn:aws:s3:::corp-emp-photos-prod/* \
--query "EvaluationResults[].{Action:EvalActionName,Decision:EvalDecision,MatchedStatements:MatchedStatements}" \
--output table

Runbook Impact: Following this structured 5-step evaluation process, supported by  aws iam simulate-principal-policy , helps Cloud Ops teams troubleshoot  AccessDenied  errors more systematically instead of relying on trial-and-error Console checks. By verifying caller identity, evaluating explicit denies, reviewing permissions boundaries and resource policies, and checking KMS permissions, engineers can narrow down potential causes, identify missing permissions such as  kms:GenerateDataKey , and investigate restrictions imposed by AWS Organizations Service Control Policies (SCPs).
Operational Takeaway: A repeatable IAM troubleshooting runbook reduces guesswork, promotes consistent security investigations, and helps engineers identify authorization issues without weakening least-privilege controls.


6. Putting It All Together: Bootstrapping the Employee Directory App on EC2

In the final demonstration of Module 1, theory meets execution. To get the Employee Directory application running on Amazon EC2, we configure four foundational layers:

  1. Compute & AMI: Select an Amazon Linux 2023 Amazon Machine Image (AMI) which provides the base operating system root volume and an instance type (such as  t3.micro ) that defines your virtual CPU ( vCPU ), memory, and network bandwidth.
  1. Network & Firewall: Launch the instance inside a Virtual Private Cloud (VPC) public subnet and attach a Security Group a stateful virtual firewall operating at the instance network interface ( ENI ) level—allowing inbound HTTP traffic on TCP port  80 . (Note: Because Security Groups are stateful, if inbound traffic on port 80 is allowed, the return response traffic back to the client is automatically permitted regardless of outbound rules).
  1. Identity (IAM Instance Profile): Attach the  EmployeeWebAppRole  so the Flask application can authenticate API calls to S3 and DynamoDB using temporary STS credentials.
  1. Automated Bootstrapping via User Data: Instead of SSHing into the server and installing packages by hand, supply a bash script in the EC2 User Data field. When the instance boots for the very first time, the  cloud-init  daemon executes this script as  root .



Important Note: Amazon Linux 2 vs. Amazon Linux 2023 Compatibility
The original AWS Cloud Technical Essentials course demonstrations used Amazon Linux 2. According to the course's March 15, 2023 update, the default EC2 Amazon Machine Image (AMI) selection changed to Amazon Linux 2023.
Because of differences between these operating system versions, the original User Data script shown in the older course videos may fail when executed on an Amazon Linux 2023 instance, preventing the Employee Directory application from launching successfully.
When following those demonstrations, there are two approaches:
  1. Amazon Linux 2: Select the Amazon Linux 2 AMI and use the original User Data script provided in the course.
  1. Amazon Linux 2023: Select the Amazon Linux 2023 AMI and use an updated User Data script compatible with that operating system.
The example below is intended for Amazon Linux 2023. Review its configuration, replace the required placeholders, and validate the script before deploying the application.
Here is the clean, newline-corrected Amazon Linux 2023 User Data bootstrap script for the lab demonstration (notice how fixing missing line breaks prevents shell syntax failures during boot):


Bash
#!/bin/bash -ex
wget https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/FlaskApp.zip
unzip FlaskApp.zip
cd FlaskApp/
dnf -y install python3-pip stress
pip3 install -r requirements.txt
export PHOTOS_BUCKET=${SUB_PHOTOS_BUCKET}
export AWS_DEFAULT_REGION=<INSERT REGION HERE>
export DYNAMO_MODE=on
FLASK_APP=application.py /usr/local/bin/flask run --host=0.0.0.0 --port=80

When the instance launches,  cloud-init  downloads the application archive, installs  python3-pip  and  stress , installs the Python dependencies, exports the runtime environment variables, and binds the Flask server to  0.0.0.0:80 .
Implementation Strategy (Situation → Action → Expected Outcome): Manual SSH-based package installation can introduce configuration inconsistencies, while storing static AWS credentials on instances creates unnecessary security risks → Automate first-boot provisioning using a properly formatted  cloud-init  User Data script and attach an IAM Instance Profile to provide temporary, automatically rotated AWS credentials → Expected Outcome: A repeatable, hands-off initial deployment process that avoids hardcoded AWS access keys, reduces manual configuration effort, and improves consistency across EC2 launches.



The Takeaway

Great cloud engineering isn't about memorizing 200 AWS service icons or clicking through wizards faster than the next person. It is about mastering the primitives and proving you can operate them under pressure:

  • Let AWS handle the undifferentiated heavy lifting, and move up the Shared Responsibility stack whenever managed services save more in engineering hours than they cost in infrastructure fees.
  • Choose Regions deliberately using the 4-Pillar Filter: Compliance first, Latency second, Service Availability third, and Pricing fourth.
  • Kill ClickOps early: Use the AWS CLI for rapid, repeatable auditing and Terraform for version-controlled infrastructure provisioning.
  • Treat identity as your perimeter: Lock away the Root User behind hardware MFA, enforce least privilege, use IAM Roles with temporary STS credentials, and know how to systematically debug  AccessDenied  policies and silent  cloud-init  failures.
The cloud is not magic. It is physical hardware wrapped in authenticated API calls—and understanding both layers is how you build systems that stay up, pass audits, and scale without burning cash.


Hire Me For:

  • AWS Cloud Ops (Remote): Day-1 operational runbooks, IAM  AccessDenied  & KMS triage, IMDSv2/IAM data-perimeter hardening, zero-SSH Systems Manager operations, Terraform IaC, and Linux/VPC break-fix post-mortems.
  • Cloud Consulting & Technical Writing: FinOps compute trade-off analysis, Single-AZ → Multi-AZ resilience decision matrices, Shared Responsibility modernization roadmaps, and deep-dive technical content that translates cloud architecture into clear business outcomes.

Open to Cloud Ops Remote and technical writing projects.

Series: Skill Builder Digital Classroom - AWS Cloud Technical Essentials (11 articles)

  1. 1
    AWS Cloud Fundamentals: Infrastructure, Security & EC2 This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article