KEY CONCEPTS
- AWS CodeBuild
- AWS CodeArtifact
- Amazon S3
- GitHub
- IAM
- Set Up Your Development Instance
Let's get started by launching an EC2 instance! This will be our virtual server in the cloud where we'll set up our CI/CD pipeline.
In this step, you're going to:
- Launch an EC2 instance using the AWS Management Console and ssh -i in your terminal.
- Understand the benefits of using EC2 for this project.
Troubleshoot common issues during instance launch.
Tools to install on your ec2Install Maven, Java, and Git on your EC2 instance.
Run these commands on the terminal in your EC2.
wget https://archive.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
sudo tar xzf apache-maven-3.5.2-bin.tar.gz -C /opt
echo 'export PATH=/opt/apache-maven-3.5.2/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
sudo dnf install -y java-1.8.0-amazon-corretto-devel
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto.x86_64
export PATH=$JAVA_HOME/jre/bin/:$PATH
sudo dnf update -y
sudo dnf install git -y
What is AWS CodeArtifact?
AWS CodeArtifact is like a secure, private locker for all your software packages and dependencies. Instead of having developers download packages from the public internet (which can be risky and unreliable), you store trusted versions in CodeArtifact.
Let's set up AWS CodeArtifact
a fully managed artifact repository service. This will help us securely store and share software packages used in our CI/CD pipeline.
In this step, you're going to:
- Set up a CodeArtifact repository to store your web app's packages.
- Create an IAM policy and role for CodeArtifact access.
- Configure Maven settings to use CodeArtifact.
- Build your web app with Maven and verify the connection with CodeArtifact.
Ready to dive in? Let's create our CodeBuild project!
What is AWS CodeBuild?
AWS CodeBuild is a fully build tool for your code. It takes your source code, compiles it, runs tests, and packages it up. Engineers love continuous integration tools like CodeBuild because you don't have to manually set up and manage any build servers yourself, and you only pay for the compute time you use for building your projects (instead of entire servers that are idle most of the time). Think of it as a super-efficient, scalable, and managed service that handles all the heavy lifting of building and testing your applications
In this step, you're going to:
- Create a new CodeBuild project
Connect CodeBuild to your GitHub Repository
To allow CodeBuild to access your private GitHub repository, we need to establish a connection using AWS CodeConnections.
In this step, you are going to:
- Set up a connection between your AWS account and GitHub using AWS CodeConnections
Finish Setting Up Your CodeBuild Project
Next, we need to define the environment where our builds will run. This includes the operating system, runtime, and compute resources.
In this step, you are going to:
- Configure CodeBuild's environment settings.
- Configure Amazon S3 to store build artifacts.
- Enable CloudWatch logs for monitoring build processes.
Run the Build and Troubleshoot Failures
Now that our CodeBuild project is fully configured, let's initiate our first build and see our CI pipeline in action!
In this step, you are going to:
- Start your first build in CodeBuild.
Troubleshoot a build failure by adding a buildspec.yml file to your web app repository.
Verify Successful Build and Artifacts
Now that we've fixed our CodeBuild setup, let's re-run the build process. We'll also check our S3 bucket to see if it's storing the build artifact correctly.
In this step, you are going toRe-run the build process in CodeBuild.
Troubleshoot a second build failure, this time by giving CodeBuild the permission to access CodeArtifact.
Run and verify a successful build!
Delete your resources
Now that we've configured our CI pipeline, it's time to clean up the resources we created. This is important to avoid getting charged for unused resources.
Resources to delete:
Delete the CodeBuild project.
Delete the S3 bucket.
Delete the EC2 instance.
Delete the IAM roles and policies.
Delete the CodeArtifact domain and repository.
Delete the CodeConnection connection
Delete your local file
Top comments (1)
keep it up 👏🏻 @kalsoom_ahmed_048978ab5ac