🌐 Setting Up a Web Application on AWS

Welcome to this detailed walkthrough on deploying a web application using AWS services. This guide will help you set up IAM, Cloud9, CodeCommit, CodeArtifact, and CodeBuild to build and deploy your applications efficiently.


πŸš€ Step 1: Create an IAM User with Administrator Access

Securely manage your AWS resources by creating a dedicated IAM user.

Instructions:

  1. Sign in to the AWS Management Console with your root account.
  2. Navigate to the IAM console.
  3. Go to Users > Add user and configure:
    • User name: e.g., admin-user
    • Enable Programmatic access and AWS Management Console access.
    • Attach the AdministratorAccess policy.
  4. Download the credentials CSV file.
  5. Log out and log in using the newly created IAM user.

:::tip πŸ’‘ Using an IAM user minimizes security risks compared to using the root account. :::

:::danger ⚠️ Never use the root account for regular operations. :::


πŸ–₯️ Step 2: Set Up a Cloud9 Environment

AWS Cloud9 provides a cloud-based IDE for developing applications directly within the AWS ecosystem.

Instructions:

  1. Open the Cloud9 console and click Create environment.
  2. Configure your environment:
    • Name: NextWorkIDE
    • Instance type: t2.micro
    • Platform: Amazon Linux 2
  3. Click Create environment and wait for the setup to complete.

:::info πŸ’‘ t2.micro is free-tier eligible, making it ideal for development. :::


β˜• Step 3: Install Maven and Java

Ensure your Cloud9 environment has the necessary tools installed.

Instructions:

  1. Open the Cloud9 terminal.
  2. Install Java and Maven by running:
sudo yum install -y java-1.8.0-openjdk
sudo yum install -y maven
  1. Verify the installations:
java -version
mvn -version

πŸ—ƒοΈ Step 4: Create a CodeCommit Repository

AWS CodeCommit is a secure, scalable, and Git-based source control service.

Instructions:

  1. Open the CodeCommit console.
  2. Click Create repository and configure:
    • Name: nextwork-web-project
  3. Clone the repository into your Cloud9 environment:
git clone https://git-codecommit.<region>.amazonaws.com/v1/repos/nextwork-web-project

πŸ“¦ Step 5: Set Up CodeArtifact

AWS CodeArtifact simplifies dependency management with a fully managed package repository service.

Instructions:

  1. Open the CodeArtifact console.
  2. Create a Domain and Repository:
    • Domain Name: nextwork
    • Repository Name: nextwork-packages
  3. Configure your Maven settings file (~/.m2/settings.xml) to use CodeArtifact:
<settings>
  <profiles>
    <profile>
      <id>codeartifact</id>
      <repositories>
        <repository>
          <id>codeartifact</id>
          <url>https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/nextwork/nextwork-packages</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>codeartifact</activeProfile>
  </activeProfiles>
</settings>

:::tip πŸ’‘ CodeArtifact integrates seamlessly with Maven, npm, and other package managers. :::


βœ… Step 6: Test CodeArtifact Connection

Verify that your project connects successfully to CodeArtifact.

Instructions:

  1. Navigate to your project directory.
  2. Run the following command:
mvn compile

πŸ—‚οΈ Step 7: Create an S3 Bucket for Build Artifacts

AWS S3 will be used to store build outputs generated by CodeBuild.

Instructions:

  1. Open the S3 console.
  2. Click Create bucket:
    • Bucket Name: nextwork-build-artifacts
    • Ensure the bucket is in the same region as your other AWS resources.

:::danger ⚠️ S3 bucket names must be globally unique. :::


πŸ› οΈ Step 8: Set Up CodeBuild

AWS CodeBuild compiles your code and produces build artifacts.

Instructions:

  1. Open the CodeBuild console and click Create project.
  2. Configure your build project:
    • Name: nextwork-web-build
    • Source: CodeCommit repository (nextwork-web-project)
    • Add the following Buildspec commands:
version: 0.2
phases:
  build:
    commands:
      - mvn clean package
artifacts:
  files:
    - target/*.jar
  1. Specify your S3 bucket for build artifacts.

πŸŽ‰ Conclusion

Congratulations! You have successfully set up a web application using IAM, Cloud9, CodeCommit, CodeArtifact, and CodeBuild. This pipeline ensures a secure and scalable environment for your applications.

For more information, refer to the AWS Documentation.

πŸ“§ Contact

For questions or feedback, reach out:

πŸ“¨ Email: projects@briankimemia.is-a.dev 🌐 Portfolio: Brian Kimemia GitHub: BrianKN019


Thank you for exploring this project! Let’s innovate and build secure AWS solutions together. πŸš€