GithubHelp home page GithubHelp logo

qdrk / aws-ami-autoscaling-codedeploy-springboot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krrrr38/aws-ami-autoscaling-codedeploy-springboot

0.0 1.0 0.0 71 KB

Shell 23.88% Java 11.89% Ruby 14.62% HCL 49.61%

aws-ami-autoscaling-codedeploy-springboot's Introduction

AWS AutoScaling CodeDeploy Spring Boot

Prepare

$ brew install awscli packer terraform
$ aws configure # setup your own (region: ap-northeast-1)

Usage

Initialize

  • Create Deployment S3 Bucket by manually
    • e.g. aws s3 mb s3://sampledeploy
    • this s3 bucket is used for CodeDeploy or LaunchConfiguration for EC2 Instance (put/pull zip file)
  • Create AMI with Packer
  • Run Terraform
  • Deploy Java Application
    • Continuous Deploy, just do deploy.sh

Components

  • packer
  • terraform
  • javaapp

Packer

Create AMI

  • require AWS_ACCESS_KEY & AWS_SECRET_KEY
  • this AMI includes followings
    • CodeDeploy agent
    • user-data.sh which run when instance is up
$ cd packer
$ packer build sampleapp.json

terraform

aws provisioner for ap-northeast-1. this requires AMI which is build by above Packer. (ami_id is automatically selected with aws api)

$ cd terraform
$ terraform init

example settings (this settings is for terraform managed state)

$ terraform init
The name of the S3 bucket
  Enter a value: terraformsample
The path to the state file inside the bucket
  Enter a value: sampleapp
The region of the S3 bucket.
  Enter a value: ap-northeast-1
$ terraform plan
$ terraform apply
  • start point is terraform/module_sample.tf.
    • ami_id is fetched by data resource (see terraform/modules/sample/data.f)

ssh into instance

If you want to ssh instances, apply following diff. (bastion server is not ready)

diff --git a/terraform/modules/sample/aws_launch_configuration.tf b/terraform/modules/sample/aws_launch_configuration.tf
index b6720ea..6146565 100644
--- a/terraform/modules/sample/aws_launch_configuration.tf
+++ b/terraform/modules/sample/aws_launch_configuration.tf
@@ -7,4 +7,5 @@ resource "aws_launch_configuration" "sample" {
name                        = "sample"
security_groups             = ["${aws_security_group.sample_web.id}"]
user_data                   = "${var.aws_launch_configuration_sample_user_data}"
+  key_name                    = "YOUR_KEYPAIR_KEY_NAME"
}

Java Application

  • javaapp/deploy/appspec.yml
    • CodeDeploy scripts
    • this is used for continuous deployment

Local Run

$ cd javaapp
$ ./gradlew clean bootRun
  • endpoints
$ curl localhost:8080 # 200 OK
$ curl localhost:8080/check/status # 200 OK
$ curl -XPOST localhost:8080/check/off # 200 OK
$ curl localhost:8080/check/status # 503 SERVICE UNAVAILABLE

Deploy

  • deploy.sh
    • create executable jar
    • aws deploy
      • zip following files (deploy directory)
        • executable jar
        • application initialize script
        • appspec.yml (for CodeDeploy)
      • upload zip into s3
    • run create-deployment

generally this script is executed by jenkins or somewhere

aws-ami-autoscaling-codedeploy-springboot's People

Contributors

krrrr38 avatar

Watchers

 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.