Coder Social home page Coder Social logo

timurgaleev / ecs-spring-boot-rds-tf Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 7.0 97.99 MB

AWS infrastructure for spring-boot app via Terraform and CI/CD via Jenkins

Dockerfile 1.18% HCL 82.03% Java 13.54% HTML 3.25%
spring boot spring-boot docker terraform ecs ecr aws alb rds

ecs-spring-boot-rds-tf's Introduction

CI/CD spring application linked MySQL(RDS) via Jenkins pipeline to AWS cloud(ECS)

In Jenkins (Install required plugins (if not already installed))

  1. Add AWS Credentials to Jenkins From the home screen, hit the Credentials link in the left-side bar.
  2. Determine where you want to put your credentials. If unsure, go into the Global credentials. You may want to do some reading on credential management for a production/widespread use.
  3. Click the Add Credentials link in the left-side navigation.
  4. For Kind, select AWS Credentials.
  5. Enter the Access ID and Secret Access Key for the AWS user that has access to the ECR repository.
  6. In the Advanced button, specify an ID that will make sense to you (so you don’t have to remember a randomly generated UUID).

Terraform The first thing we’ll do is specify the provider. This can be done in different ways but here we’re telling Terraform our provider is AWS and that it can find our credentials in $HOME/.aws/credentials which is the default location for AWS credentials on Mac and Linux.

To get the minimal amount of high availability, we’ll deploy our ECS cluster to run on at least two Availability Zones (AZs). The load balancer also needs at least 2 public subnets in different AZs.

Initial command terraform init terraform/ This gets it all set up and ready to apply.

Finally, run terraform apply terraform/ to get this bad boy deployed! It will refresh state for all your resources and show you what will be created/removed/updated.

When it spits out your load balancer url, go ahead and visit it at port :8080 and you should see the JSON returned from the initial block in your deployed into ECR app.

In this example, wherever it says sb is my application name.

To run locally

Note: I was unable to run new versions of spring-cloud-aws locally. It seems it tries always to perform some autoconfiguration assuming it is deployed on AWS, and as long as it doesn't find a valid instance id, it raises an exception and stops.

Some configurations are required in your AWS account for this sample to work. Additionally, we need an IAM user with access key and programmatic access to AWS API so that we can access AWS resources from our development machine.

Create an IAM User

  • Enable programmatic access
  • Generate an access key for the user
  • Give the user the following permissions: ** AmazonRDSFullAccess

To run on EC2

Create an IAM role Create an IAM role with the following properties:

  • EC2 role (i.e., a role to be attached to EC2 instances)
  • Policies: ** AmazonRDSFullAccess

Create an EC2 instance - if you want to create instance in AWS

It has been tested with an instance with the following properties:

  • AMI: Ubuntu 18.04
  • Type: t2.micro
  • Storage: 20Gb
  • Security group: choose or create one with ports 22 and 8080 opened
  • Attach the IAM role created previously

What you'll need

  • Docker
  • Jenkins
  • AWS ECS
  • AWS RDS
  • AWS VPC
  • AWS ERC
  • AWS ALB
  • Terraform

Stack

  • AWS
  • Docker
  • Docker-Compose
  • Java
  • Spring Boot
  • MySQL
  • Tomcat
  • Maven

You can check the log by

Open http://[your DNS name]:8080 in your browser.

ecs-spring-boot-rds-tf's People

Contributors

timurgaleev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.