Giter Site home page Giter Site logo

dev-elasticsearch-ec2's Introduction

Deploy a throwaway one node elasticsearch server on EC2 for dev/testing purposes with basic authentication (based on Centos7).

Prerequisites

SSH client, Ansible, AWS CLI.

AWS

Create a stack with the aws.yamltempalate in the AWS_Elasticsearch_EC2_Instance directory.

Upload the template to Cloudformation via the AWS console and create the stack interactively.

aws cloudformation create-stack --stack-name Dev-Els  \
    --template-body file://AWS_Elasticsearch_EC2_Instance/aws.yaml \
    --parameters file://AWS_Elasticsearch_EC2_Instance/params.json \
    --capabilities CAPABILITY_IAM \
    --profile <your profile here>

If you want to use the cli, create your own parameters file named params.json in the AWS_Elasticsearch_EC2_Instance directory.

Here's an example params.json file for reference:

[
  {
    "ParameterKey": "VPCId",
    "ParameterValue": "vpc-b0ed07d5"
  }, 
  {
    "ParameterKey": "VPCSubnet",
    "ParameterValue": "subnet-d86ea1bd"
  },
  {
    "ParameterKey": "SSHAccessCIDR",
    "ParameterValue": "194.168.2.1/24"
  },
  {
    "ParameterKey": "HTTPAccessCIDR",
    "ParameterValue": "0.0.0.0/0"
  },
  {
    "ParameterKey": "KeyPairName",
    "ParameterValue": "MyKeyPair"
  },
  {
    "ParameterKey": "InstanceAMI",
    "ParameterValue": "ami-6e28b517"
  },
  {
    "ParameterKey": "ElsInstanceType",
    "ParameterValue": "t2.medium"
  }
]

Monitor your stack creation (I use jq here, you can use the build in --query as well)

aws cloudformation describe-stacks --stack-name  Dev-Els --profile <your profile> | jq -r '.Stacks[].StackStatus'

Get the outputs from the stack (Instance DNS name and public IP)

aws cloudformation describe-stacks --stack-name  Dev-Els --profile <your profile> | jq -r '.Stacks[].Outputs'

Delete stack

aws cloudformation delete-stack --stack-name Dev-Els --profile <your profile>

After deletion is complete, if you query again, you get a "good" error: "An error occurred (ValidationError) when calling the DescribeStacks operation: Stack with id Dev-Els does not exist".

Ansible playbook

Configuration

Inventory

Once your stack is created, recover the stack outputs and add the target hostname to the ec2.txt inventory file.

Certificates

Create an sslcerts directory at the root of the current directory and add your:

  • fullchain certificate: name it ssl-bundle.crt
  • private key: name it private.key.pem

This is needed for the TLS configuration of the nginx reverse proxy.

Playbook

Edit the varssection of the playbook and set:

  • the elasticsearch and kibana package version to install.
  • the username for basic authentication
  • the password for basic authentication
  • the AWS Region

Run

ansible-playbook -i ec2.txt elasticsearch-playbook.yaml 

This will setup:

  • Elasticsearch
  • Kibana
  • Nginx reverse proxy
    • elasticsearch vhost
    • kibana vhost
    • htpasswd for basic auth (via SSL)
  • awslogs:
    • awslogs.conf to log elasticsearch logs to cloudwatch
  • exclude els and kibana from updates if you keep it running for longer than anticipated ;-)

dev-elasticsearch-ec2's People

Contributors

olibob avatar

Watchers

 avatar

Forkers

carlinix

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.