0Pricing
Serverless Backend with AWS Lambda & API Gateway · 강의

CodeCommit과 CodeBuild

소스 제어에는 AWS CodeCommit을, 서버리스 코드를 컴파일하고 패키징하는 데는 AWS CodeBuild를 통합합니다.

CodeCommit과 CodeBuild은(는) CoddyKit의 무료 Serverless Backend with AWS Lambda & API Gateway 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Serverless Backend with AWS Lambda & API Gateway 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Serverless Backend with AWS Lambda & API Gateway 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

CI/CD for Serverless Intro

Welcome to the first lesson in our CI/CD for Serverless Applications course! Continuous Integration and Continuous Delivery (CI/CD) are crucial for modern software development.

In this lesson, we'll dive into two foundational AWS services: AWS CodeCommit for source control and AWS CodeBuild for compiling and packaging your serverless code.

What is AWS CodeCommit?

AWS CodeCommit is a fully managed source control service that hosts secure Git-based repositories. Think of it as AWS's version of GitHub or GitLab, but tightly integrated with other AWS services.

  • It's private: Your code stays within AWS.
  • It's scalable: Handles projects of any size.
  • It's Git-compatible: Use your existing Git tools and workflows.

It acts as the central hub for your application's source code.

Setting Up CodeCommit Repo

To start using CodeCommit, you first need to create a repository. You can do this via the AWS Management Console, AWS CLI, or SDKs.

Once created, you'll configure your local Git client to connect to it. This often involves setting up IAM credentials (HTTPS Git credentials) or SSH keys for authentication.

Cloning & Pushing Code

After setting up your credentials, you can clone your CodeCommit repository to your local machine and push changes just like any other Git repository.

Here's a basic sequence of commands you'd use:

git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyServerlessRepo
cd MyServerlessRepo
echo "print('Hello CI/CD!')" > app.py
git add app.py
git commit -m "Initial commit for Lambda function"
git push origin main

What is AWS CodeBuild?

AWS CodeBuild is a fully managed continuous integration service that compiles your source code, runs tests, and produces deployable software packages. It eliminates the need to provision, manage, and scale your own build servers.

  • No servers to manage: AWS handles the infrastructure.
  • Scales automatically: Builds run in parallel and scale as needed.
  • Pay-as-you-go: You only pay for the compute time used.

The Buildspec File

The core of a CodeBuild project is the buildspec.yml file. This YAML file defines the commands and actions CodeBuild performs during a build.

It specifies build commands, artifact (output) definitions, and caching instructions. It's placed at the root of your source repository.

Anatomy of a Buildspec

A buildspec.yml is organized into phases:

  • install: Install dependencies.
  • pre_build: Commands before build (e.g., login to Docker).
  • build: Actual build commands (e.g., compile code, run tests).
  • post_build: Commands after build (e.g., package artifacts).

Here's a simple example for a Python Lambda function:

version: 0.2

phases:
  install:
    commands:
      - echo "Installing dependencies..."
      - pip install --upgrade pip
      - pip install -r requirements.txt -t package/
  build:
    commands:
      - echo "Zipping deployment package..."
      - cd package
      - zip -r ../function.zip .
      - cd ..
      - zip -g function.zip app.py
artifacts:
  files:
    - function.zip
  discard-paths: yes

Creating a CodeBuild Project

To use CodeBuild, you create a build project. This involves:

  • Source: Pointing to your source code repository (e.g., CodeCommit).
  • Environment: Selecting an operating system, runtime, and compute type.
  • Buildspec: Specifying the buildspec.yml file.
  • Artifacts: Defining where to store build outputs (e.g., S3 bucket).

You'll also assign an IAM role to CodeBuild, granting it permissions to access your source, S3, and other necessary AWS services.

CodeCommit & CodeBuild Flow

The typical workflow for continuous integration using these services is:

  1. Developer pushes code changes to an AWS CodeCommit repository.
  2. CodeCommit can trigger an AWS CodeBuild project automatically (often via CodePipeline, which we'll cover next).
  3. CodeBuild fetches the latest code, executes the commands in buildspec.yml.
  4. CodeBuild produces artifacts (like a zipped Lambda function) and stores them in an S3 bucket, ready for deployment.

Quick Check

You've just learned about CodeCommit and CodeBuild. Let's test your understanding!

Recap & Next Steps

Great job! In this lesson, you learned about:

  • AWS CodeCommit: A managed Git repository service for secure source control.
  • AWS CodeBuild: A fully managed continuous integration service that compiles and packages your code.
  • The importance of the buildspec.yml file for defining build steps.

These two services form the backbone of your serverless CI/CD pipeline. Next, we'll see how AWS CodePipeline orchestrates these services for automated deployments!

자주 묻는 질문

“CodeCommit과 CodeBuild” 강의는 무료인가요?

네 — “CodeCommit과 CodeBuild” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Serverless Backend with AWS Lambda & API Gateway 강의 전체를 잠금 해제할 수 있습니다. Serverless Backend with AWS Lambda & API Gateway 강의에는 총 4개의 강의가 포함되어 있습니다.

“CodeCommit과 CodeBuild”에서 뭘 배우나요?

소스 제어에는 AWS CodeCommit을, 서버리스 코드를 컴파일하고 패키징하는 데는 AWS CodeBuild를 통합합니다. 브라우저에서 직접 실행하는 실습 코드로 Serverless Backend with AWS Lambda & API Gateway을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Serverless Backend with AWS Lambda & API Gateway을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Serverless Backend with AWS Lambda & API Gateway은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“CodeCommit과 CodeBuild” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Serverless Backend with AWS Lambda & API Gateway 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Serverless Backend with AWS Lambda & API Gateway 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. CodeCommit과 CodeBuild
  2. 배포를 위한 CodePipeline
  3. 서버리스 배포 자동화
  4. 카나리 및 롤백을 활용한 안전한 배포
← Serverless Backend with AWS Lambda & API Gateway(으)로 돌아가기