Code Monkey home page Code Monkey logo

terraform-ethereum-ganache's Introduction

terraform-ethereum-ganache

Terraform project for setting up a remote Ganache atop AWS

This README assumes you have practical knowledge of how to install Terraform on your developer machine. you will of course also need AWS credentials to be able to run this project setup on your terminal.

Do note that this Terraform project assumes credentials as being set as an AWS profile and not as plain AWS keys variables. For more information on that (click here)[https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html]

There a few key variables required to run this project:

  • AWS region - the region variable
  • AWS credentials profile name - the aws_profile variable
  • Instance type/size - the instance_type variable
  • Path to public key to be used - the ssh_keypath variable

Basically all of these variables have their appropriate defaults based on the best practices available on the web.

How to run this project

Deploy

Firstly clone this project into your local machine by typing the following into your terminal:

git clone [email protected]:orbs-network/terraform-ethereum-ganache.git

After the repository finished downloading, go inside it's folder and type:

terraform init

Terraform will initialize the repository, downloading any plugins used as well (in our case mostly the AWS plugin) The next step would be to import our existing Elastic IP to attach to this machine (The allocation of the IP can happen via the aws cli tool or via the AWS Console and is outside the scope of this guide)

terraform import -var aws_profile=staging -var region=eu-west-1 aws_eip.eip_ganache 52.44.35.215

Next up is peforming either a plan or an apply commands whether depending on your plan of action. To simply go ahead and create the machine in AWS simply issue an apply like so:

terraform apply -var aws_profile=staging -var region=eu-west-1 -auto-approve

(The variables are of course an example just to showcase how you can change the default variables inline while running the apply command)

Test

Once done, Terraform will output the DNS and IP of the machine which was created. Ganache should answer on TCP port 8545 after a couple of minutes.

Use Ethereum JSON RPC to communicate with the node, this CURL command for example will get the latest block:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1}' 52.44.35.215:8545

Destroy

When you want to destroy the Ganache machine and it's related assets, type the following to detach the Elastic IP from the Terraform workspace:

terraform state rm aws_eip.eip_ganache

Next up you can go ahead and type the following to destroy the machine and it's related resources:

terraform destroy -var aws_profile=staging -var region=eu-west-1 -auto-approve

Enjoy

terraform-ethereum-ganache's People

Contributors

daviddayag avatar itamararjuan avatar talkol avatar

Watchers

 avatar  avatar  avatar

terraform-ethereum-ganache's Issues

terraform init does not take -var

Symptom:

In my ~/.aws/credentials I don't have a default profile, only the orbs-staging profile.. and terraform init does not work.

Possible Cause:

The -var command line arg is only supported in terraform apply and not in terraform init

So I get an error on init:

➜  terraform-ethereum-ganache git:(master) ✗ terraform init -var aws_profile=orbs-staging
Initializing modules...

Initializing the backend...

Error: No valid credential sources found for AWS Provider.
	Please see https://terraform.io/docs/providers/aws/index.html for more information on
	providing credentials for the AWS Provider

It only starts working if I put the credentials inside the [default] profile

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.