DEV Community

Cover image for Who Tests the Cloud? How I Built a Self-Checking Weather API on AWS (and Why Educloud Academy Made It Possible)
Numfor Precious
Numfor Precious

Posted on

Who Tests the Cloud? How I Built a Self-Checking Weather API on AWS (and Why Educloud Academy Made It Possible)

Five Lambda functions, one pipeline that refuses to ship broken code, and the course that took me from "I've heard of CI/CD" to "I built one."


One missing checkbox. That is all it took.

I ran cdk deploy, feeling great, and CloudFormation answered with a 403 Forbidden webhook error, then rolled my entire stack back. The culprit? My GitHub personal access token was missing a single webhook permission.

I stared at the screen and thought: if one tiny checkbox can undo everything, what else can slip through when nobody is checking?

Picture the worse version. It is Friday, 4:58 PM, and you push one tiny change. On Monday someone messages you: "The app has been returning errors since Friday evening." Most of us have been there, or watched a teammate live it. Here is the uncomfortable truth I learned during my internship at DIGISOL GROUP: the problem is rarely the bug. The problem is that nothing stands between the bug and the users.

This article is about building that "something." It is the story of a small weather API I built on AWS, a pipeline that automatically tests my code before it is allowed anywhere near production, and the learning platform that taught me how, Educloud Academy.

If you are a student or a young professional wondering how to get real, job-relevant cloud skills without getting lost in theory, stay with me. By the end you will know exactly what I built, why every service is there, what tripped me up, and why I think you should start your own learning path today.


The Mission: Code That Defends Itself

The course I followed is called "Unit Testing and CICD Deployment with Jest, GitHub and AWS CodePipeline." The promise is simple: build a serverless application, then build the machinery that tests and deploys it automatically, every time you push code.

My project does exactly that, in three layers:

  1. An application: a Weather API that can Create, Read, Update, Delete and List weather records (the classic "CRUDL").
  2. Infrastructure as code: the whole thing is defined in Python using the AWS Cloud Development Kit (CDK). No clicking around the console.
  3. A delivery pipeline: push to GitHub, and AWS automatically runs the tests, and only if they pass, deploys first to a dev environment and then to prod.

Here is the analogy that finally made it click for me, and it involves printing an exam paper. The project has three stack files, and I kept asking why on earth I could not put everything in one file like normal people:

  • lambda_stack is the master exam paper. It holds the actual Weather app.
  • pipeline_stage is the office photocopier. It stamps out one copy for practice (dev) and one for real users (prod), so I never write the code twice.
  • The main pipeline stack is the autopilot assistant inside AWS. It watches GitHub using a token kept in Secrets Manager.

And the stage_name ("dev" or "prod") travels through all three like a relay baton: from the main stack, into pipeline_stage, and finally into lambda_stack, where it ends up in every resource name. Once you deploy it once, your terminal can retire. git push does the rest.

 You push code ──► GitHub ──► CodePipeline
                                  │
                       ┌──────────▼───────────┐
                       │  Synth step           │
                       │  pip install          │
                       │  pytest   ◄── gate    │
                       │  cdk synth            │
                       └──────────┬───────────┘
                                  │ tests passed?
                       ┌──────────▼───────────┐
                       │  Deploy to DEV        │
                       └──────────┬───────────┘
                       ┌──────────▼───────────┐
                       │  Deploy to PROD       │
                       └──────────────────────┘
Enter fullscreen mode Exit fullscreen mode

The finished pipeline


Meet the Cast: Every Service and Why It Earned Its Seat

🔹 Amazon API Gateway: the front door

A Weather API needs an address that apps can call. API Gateway gives us a managed REST API with five routes:

Route Method Job
/create-weather POST Save a new weather record
/get-weather GET Fetch one record
/list-weathers GET Fetch them all
/update-weather PUT Change a record
/delete-weather DELETE Remove a record

The API in action.


Why API Gateway?

Because I did not want to run, patch or scale a web server. API Gateway handles routing, traffic and the public endpoint. I only describe the routes.

🔹 AWS Lambda: the workers

Behind every route sits its own Lambda function, written in Python 3.13. Each function does one thing. For example, the create function reads the request, generates a unique ID, and saves the record:

item = {
    "id": str(uuid.uuid4()),
    "town": body.get("town", "Unknown"),
    "weather": body.get("weather", "sunny"),
}
get_table().put_item(Item=item)
return {"statusCode": 201, "body": json.dumps(item)}
Enter fullscreen mode Exit fullscreen mode

The lambda function.

Why Lambda? Serverless means I pay only when the code actually runs, and I never think about servers. For a project like this, one that might receive ten requests a day or ten thousand, that is the perfect fit. And why five small functions instead of one big one? Because each can be tested, secured and changed on its own. A bug in "delete" cannot break "create."

🔹 Amazon DynamoDB: the memory

Weather records need to live somewhere. DynamoDB is a fast NoSQL database where each record is found by a key, here a simple string id.

The memory.

Why DynamoDB? Our access pattern is simple: "give me the record with this ID." That is exactly what DynamoDB is built for, with single-digit-millisecond lookups and zero database servers to manage. No schema migrations, no connection pools.

🔹 AWS CDK: the blueprint

This is the part that changed how I think. Instead of creating resources by hand, I wrote them as Python code:

table = dynamodb.Table(
    self,
    f"{stage_name}WeatherApiTable",
    table_name=f"{stage_name}weatherApiTable",
    partition_key=dynamodb.Attribute(
        name="id", type=dynamodb.AttributeType.STRING
    ),
    removal_policy=RemovalPolicy.DESTROY,
)
Enter fullscreen mode Exit fullscreen mode

The blueprint.

Why CDK? Three reasons:

  • Repeatable. The same code builds dev and prod. Only the stage_name changes, so the dev table is devweatherApiTable and the prod table is prodweatherApiTable. Same blueprint, two identical, separate worlds.
  • Reviewable. Infrastructure changes show up in Git like any other change.
  • Testable. (Hold that thought. This is where it gets exciting.)

One line I especially love is how permissions are granted:

table.grant_write_data(create_weather_lambda)
table.grant_read_data(get_weather_lambda)
Enter fullscreen mode Exit fullscreen mode

The "get" function can only read. The "create" function can only write. CDK generates the IAM permissions for me, which means least privilege by default, a security habit that employers love, handed to me in one line.

🔹 AWS CodePipeline: the conveyor belt

This is the automation. Defined in unit_testing_educloud_stack.py, the pipeline watches my GitHub repository's main branch. On every push it:

  1. Pulls the code.
  2. Installs dependencies.
  3. Runs python -m pytest.
  4. Runs cdk synth to produce the infrastructure template.
  5. Deploys the dev stage, then the prod stage.

Inside the Build stage.

Why CodePipeline? Because "it worked on my laptop" is not a deployment strategy. The pipeline is the single, consistent path to production. And the pipeline is self-mutating: if I change the pipeline's own code, it updates itself. There is no magic in that. The UpdatePipeline stage simply uses CloudFormation to update the pipeline. CodeBuild does not guess what to run either: it is a temporary container that executes the commands I listed, drops the compiled cdk.out files into an S3 bucket, and disappears while S3 carries them to the next stage.

Two things surprised me while preparing to present this project:

1. A green Build does not guarantee a green Dev. Build only proves the code works on paper. Dev is where reality hits: missing IAM permissions, KMS decryption blocks, artifact handoff mismatches, or CloudFormation discovering that a table name already exists in the account.

2. Do not run cdk deploy by hand once the pipeline is live. It updates AWS immediately and ignores GitHub, right up until your next git push. Then the self-mutating pipeline politely wipes out your unpushed local changes, because GitHub is the single source of truth. Be patient, and let the pipeline do its job.

🔹 AWS Secrets Manager: the vault

For CodePipeline to read my private GitHub repo, it needs a GitHub token. Pasting a token into code would be a security disaster. The course teaches you to store it in AWS Secrets Manager, so the pipeline fetches it securely at runtime and the secret never touches the repository.

The vault.

My own near-miss: my first deployment failed with that 403 webhook error because the token was missing one permission checkbox. The fix took seconds once I knew where to look: update the token in Secrets Manager and redeploy. Finding it took much longer. If you take one thing from this section, let it be this: when a pipeline cannot reach GitHub, check the token's permissions before you touch the code.

Why it matters: leaked keys on public repos are one of the most common ways beginners (and professionals!) get burned. Learning this in Module 1, before writing a single function, tells you how seriously the course takes real-world habits.


The Heart of It All: Two Kinds of Tests

This is the part of the project I am proudest of, and the reason for the course title.

Type 1: Testing the infrastructure itself

Wait, you can test your cloud setup? Yes. CDK can turn your code into a CloudFormation template, and then you can make assertions about it, without deploying anything:

def test_five_lambda_functions_created():
    app = core.App()
    stack = LambdaStack(app, "MyTestStack", stage_name="Dev")
    template = assertions.Template.from_stack(stack)
    template.resource_count_is("AWS::Lambda::Function", 5)
Enter fullscreen mode Exit fullscreen mode

This test says: "There must be exactly five Lambda functions." If a teammate accidentally deletes one, the build fails before anything reaches AWS. The same file checks the DynamoDB table name, the API Gateway name, and each function's properties and environment variables.

Infrastructure tests passing.

Imagine the peace of mind. Your infrastructure now has a safety net, and it runs in under a few seconds, for free.

Type 2: Testing the business logic

The Lambda functions talk to DynamoDB. But in a unit test, I do not want to hit a real database. It would be slow, cost money and fail when the internet does.

The solution is mocking: replace the database with a stand-in that behaves the way I tell it to.

@patch("src.get_weather.get_table")
def test_get_weather(mock_get_table):
    mock_get_table.return_value.get_item.return_value = {
        "Item": {"id": "1", "town": "Douala", "weather": "hot"}
    }
    result = get_weather({"pathParameters": {"id": "1"}})
    assert result["statusCode"] == 200
Enter fullscreen mode Exit fullscreen mode

Here I tell the fake database: "When asked for item 1, say it's hot in Douala." Then I check that the function responds with a 200. No AWS account needed, no network, no cost. The test runs in milliseconds.

Notice something small but clever in the handler code: the boto3 import and the table lookup live inside a tiny get_table() function. That is exactly what makes the mock possible. Good tests are often a design decision, not an afterthought.

The full test run.

The magic moment: connecting the two to the pipeline

Remember step 3 in the pipeline, python -m pytest? Because the tests run inside the pipeline, a failing test stops the deployment. Broken code cannot reach dev, and certainly cannot reach prod.

The pipeline saying no.

That is the answer to my Friday 4:58 PM nightmare. Now the pipeline works the weekend shift for me.


Lessons Learned (the honest ones)

Every project teaches you more through what went wrong than what went right. Here is my list.

1. Translate, don't just copy.
The course was taught in TypeScript with Jest. I rebuilt everything in Python with pytest and the CDK Python library. It forced me to understand each concept instead of memorising syntax. Tell-tale sign I learned it the hard way: a few function names in my stack still say cdk-typescript-create, a fossil from the original lesson. (They are on my cleanup list!) If you can port a lesson to another language, you have truly learned it.

2. Environment problems are part of the job.
On my Windows machine, the CDK's JSII runtime tried to write its package cache to a restricted AppData folder, and my tests failed before they even began. The fix was to point the cache into the project's own .pytest_cache folder with an environment variable at the top of the test file. Nobody puts "fighting your tooling" in a course, but it is half of real engineering.

3. Tests prove what you asked them to prove, nothing more.
My Lambda tests check that the response has the right shape and status code. That is a great start, but they mock the database, so they cannot prove my DynamoDB calls are correct against the real service. Unit tests are one layer of confidence. The next layers are integration tests and monitoring. Knowing the limits of a test is as valuable as writing one.

4. Defaults hide bugs.
My handlers fall back to defaults when input is missing, like an ID of "1". It makes demos smooth, but in a production system a missing ID should return a clear 400 Bad Request rather than quietly touching record 1. This is exactly what I would harden next.

5. Clean up as you learn.
My table uses RemovalPolicy.DESTROY, so deleting the stack deletes the data. Perfect for a learning project where I want to avoid leftover cloud bills; dangerous for production. I now ask "what happens when this is deleted?" about every resource I create.

6. Small functions, big confidence.
Splitting the API into five single-purpose Lambdas made each test trivial to write and each failure trivial to locate.


Key Takeaways

  • Automate the boring and the risky. If a human has to remember to run the tests, eventually they will forget. Put the tests in the pipeline.
  • Infrastructure is code, so test it like code. Template assertions catch mistakes in seconds, for free.
  • Mock the outside world. Fast, cheap, reliable unit tests need fakes in place of real databases.
  • Least privilege is a habit. One grant_read_data line beats a wildcard policy.
  • Never hard-code secrets. Use Secrets Manager from day one.
  • The best learning is building. I understood more by shipping this small project than from hours of passive reading.

Why I'm Telling You to Try Educloud Academy

I have saved this part for last, because it is the reason I could build any of this.

Plenty of tutorials show you a screenshot and say "click here." Educloud Academy teaches you to build the thing. The course I followed is structured as five modules and twenty lessons, moving in the exact order a real project unfolds:

Module What you do
1. Get Started Initialize the app, set your GitHub token in Secrets Manager, configure CodePipeline
2. Add Deployment Stages Create separate dev and prod stages
3. Build the Stack Define the DynamoDB table, API Gateway, Lambda functions and endpoints
4. Define Test Cases Write infrastructure and Lambda tests
5. Testing Run it all and watch the pipeline do its job

I will be honest about the start: Module 1 humbled me. I understood what CodePipeline was and why CI/CD matters, but I could not see how the CDK constructs fit together, and I seriously doubted myself. Then I went back, dropped the textbook jargon, and traced one piece at a time until it made human sense. That struggle is the point. The course is built so that you push through it with a working project at the end.

Here is what stood out to me, especially as a student:

  • It is project-based. You end with something real: a repository, a running pipeline, a portfolio piece you can show an interviewer.
  • It teaches the services employers actually use: Lambda, API Gateway, DynamoDB, Secrets Manager, CDK and CodePipeline are everyday tools in cloud teams.
  • It starts free. Module 1 is open, so you can try the first steps with zero risk before committing.
  • It is paced for humans. Intermediate level, clear lesson-by-lesson progress tracking, an AI tutor to ask when you are stuck, and lifetime access so you can come back whenever you need a refresher.

If you are a student wondering how to stand out, or a young professional trying to move from "I know the theory" to "I have deployed it," here is my honest advice: pick one project and finish it. Employers rarely ask what courses you watched. They ask what you built. This course hands you something to build.


Where This Fits, and Who Made It Possible

This pipeline is one chapter in a series of cloud projects I built during my internship at DIGISOL GROUP: a serverless Weather API with AWS SAM, a live weather dashboard on top of it, and a serverless e-commerce backend with single-table DynamoDB, DynamoDB Streams and SQS. Each one started with an Educloud Academy course and ended with something I could run, break and fix.

None of it happened alone:

  • Educloud Academy, founded by Ndimofor Ateh Rosius, for a platform where cloud skills are learned by building real systems, not by memorising slides.
  • DIGISOL GROUP for the engineering environment, the sprint autonomy and the space to make mistakes, debug in real time and take ownership of the work.
  • Josué Fotseu, my supervisor and mentor, whose code reviews pushed me to ask "why?" about every stage until I could explain the system to anyone, not just run it.

Your Turn

Start with Module 1 at educloud.academy. Do not just follow along: change the language, rename the resources, break a test on purpose and watch the pipeline refuse to deploy. That moment, when a red failed build protects you from your own mistake, is the one that makes everything click.

What was the last bug that slipped into production on you? Tell me in the comments. I would love to hear how a pipeline could have caught it.

Top comments (0)