Cloud9 starter guide with Spring Boot
Tags: aws, cloud9, devops, sre
Published: 2023-09-04 19:23:36

AWS Cloud9 is a cloud-based integrated development environment (IDE) offering numerous advantages. It facilitates effortless code collaboration, making it ideal for distributed teams. With its preconfigured AWS tools and secure cloud environment, developers can enhance productivity, streamline workflows, and accelerate innovation.

Here are the top 5 advantages of AWS Cloud9:

- **Browser Accessibility Anywhere**: You can access it via a web browser from anywhere with an internet connection.
- **Real-Time Collaborative Coding**: It supports real-time collaborative coding, enhancing teamwork.
- **Direct AWS Terminal Access**: This unique feature allows direct terminal access to AWS, which I personally find very cool.
- **Serverless Development Support**: It supports serverless development, simplifying the process.
- **Rapid Project Start**: You can quickly bootstrap a new project with ease.

Let's initiate a Spring Boot project swiftly using AWS Cloud9:


![AWS Cloud9](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9wzbp8e4o3ajevxib3o.JPG)

[Cloud9]

1. Navigate to AWS Cloud9 -> Environments -> Create Environment.
2. Configure Environment Details:
   Choose "New EC2" as the environment type.
3. Choose the Platform:
    Opt for "Amazon Linux 2."
4. Define the Timeout Settings.
5. Specify Network Settings:
   Decide between using SSM (Systems Manager) or SSH.
6. Configure VPC and Tags.
7. You're all set! Click "Create" to begin.


![Cloud9 Environment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz9tlpfandho96cpyw0r.JPG)

[Cloud9 Environment]

Before launching Cloud9, it's crucial to ensure that the associated EC2 instance is up and running. Any issues with the EC2 instance can lead to problems with Cloud9, and more often than not, the most common reason for Cloud9 not loading is related to issues with the EC2 instance.


![Cloud9 related to EC2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97gmwbt8sxci4sswwv9g.JPG)

[Cloud9 associated EC2]

Click "Open," and you'll have your newly created AWS Cloud9 development environment.


![Coud9 - IDE](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2aefj591ngz28ofa7xw.JPG)

[IDE]

**Let's create our first Spring Boot project:**

1. Begin by creating a folder named "SpringBootMicroservice" using the following terminal commands:

```
mkdir SpringBootMicroservice
cd SpringBootMicroservice
```


![Terminal Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3sj0dj871hynhizwp2o.JPG)
[Terminal Output]

2.Utilize Spring Initializer to generate a Spring Boot project for "SpringBootMicroservice":

```
curl https://start.spring.io/starter.zip -o project.zip
unzip project.zip
rm project.zip
```


![Termina Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r0uxnlkh9hl55nvoh2w.JPG)
[Terminal Output]

3. Next, download and install Java with the following commands:

```
sudo yum update
sudo yum install java-17-amazon-corretto-devel
```


![Terminal Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6s5y8oilbrqyecs4n2q.JPG)
[Terminal Output]

Please note that Spring Boot's Gradle plugin requires Gradle 7.x (7.5 or later) or 8.x, and Java 17 or a higher version.

4. Now, proceed to create your Spring Boot project by creating the associated model, repository, and services components.


![Spring Boot Project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20kuna8zwhycb8110n9u.JPG)
[Spring Boot Project]

5. Let's proceed to build the project using Gradle.

Gradle is a widely adopted open-source build automation tool. It offers flexibility and efficiency in handling project dependencies, task definitions, and automating the build process.

To initiate the build process, execute the following command:

```
./gradlew build
```


![Build automation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzzj2md4kdmhxz7yrq77.JPG)

[Build automation]

That's it. We have successfully created a Spring Boot project in Cloud9.

Lastly, let's discuss Cloud9 pricing. There are no additional charges for using Cloud9 itself. Instead, you'll be billed for the services you utilize, such as EC2 instances, and so forth. If you're within the free tier for EC2, there will be absolutely no cost. A key reminder: always remember to shut down your EC2 instances when you've completed your work to avoid any unexpected charges.