GithubHelp home page GithubHelp logo

nerc-project / terraform-nerc-r-shiny Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 231 KB

This includes a basic template to provision and manage R-Shiny server on NERC OpenStack resources using Terraform.

HCL 65.91% Shell 34.09%

terraform-nerc-r-shiny's Introduction

Provisioning the NERC resources using Terraform

This includes a basic template to provision and manage user's NERC OpenStack resources using Terraform. NERC has an OpenStack deployment. Terraform is an open-source Infrastructure as Code (IaC) software tool that works with NERC and allows you to orchestrate, provision, and manage infrastructure resources quickly and easily.

Benefits of Terraform

If you have multiple instances/ VMs you are managing for your work or research, it can be simpler and more reproducible if you are doing it with automation tool like Terraform.

Installing Terraform

To use Terraform you will need to install it from here.

Basic Operations

The basic setup is as follows:

  1. Git clone this terraform-nerc-r-shiny repo.

  2. Generate and move a new SSH key pair to your local ~/.ssh folder.

  3. Download the NERC's OpenStack RC file i.e. -openrc.sh file into the repo.

  4. Run source *-openrc.sh.

  5. Review example.tfvars file in the repo and change some of the local variables' values as per your settings i.e. quantity, keypair-name, keypair-path, user-data-path, secgroup, network_name, etc.

    NOTE: Please make sure to review bash script file i.e. install-R-Shiny.sh is pointing as user-data-path variable in example.tfvars. This includes the script required to setup Shiny R server. If you want to change and update this script you can just change this file and then run terraform plan and terraform apply command pointing this example.tfvars file.

  6. Review network.tf file in the repo and you can see we opened r-shiny-ingress resource that open ingress port of 3838 which is required to expose R Shiny web server as http://<Newly_Created_Floating_IP>:3838.

  7. Initalize Terraform in the repo with terraform init.

  8. See what changes Terraform wants to make to your infrastructure with terraform plan -var-file="example.tfvars".

  9. Apply the changes with terraform apply -var-file="example.tfvars".

  10. The terminal will show the Floating IP(s) of the newly creted instance(s). Try to SSH into it using ssh almalinux@<Floating_IP> -i ./your-private-key-pair.

  11. Go to the NERC's OpenStack dashboard to review your newly provisioned resources.

  12. Clean up all resources using terraform destroy -var-file="example.tfvars".

How to get Credential to connect NERC's OpenStack

You can download the environment file with the credentials from the OpenStack dashboard.

  • Log in to the NERC's OpenStack dashboard, choose the project for which you want to download the OpenStack RC file.

  • Navigate to Identity > Application Credentials.

  • Click on "Create Application Credential" button and provide a Name and Roles for the application credential. All other fields are optional and leaving the "Secret" field empty will set it to autogenerate (recommended).

Application Credentials Setup

  • After clicking "Create Application Credential" button, the ID and Secret will be displayed and you will be prompted to Download openrc file or to Download clouds.yaml. Both of these are different methods of configuring the client for CLI access. Please save the file.

Then, source your downloaded OpenStack RC File:

Find the file (by default it will be named the same as the application credential name with the suffix -openrc.sh where project is the name of your OpenStack project).

Source the file:

[user@laptop ~]$ source app-cred-<Credential_Name>-openrc.sh

NOTE: When you source the file, environment variables are set for your current shell.

How to Setup SSH key pairs

Create a new key running: ssh-keygen -t rsa -f your-private-key-pair

Make sure the newly generated SSH key pairs exist on your ~/.ssh folder.

Running Terraform

The Terraform deployment workflow on the NERC looks like this:

Automating NERC resources using Terraform

Terraform Init

Initialize - Install the plugins Terraform needs to manage the infrastructure.

Terraform Plan

Plan - Preview the changes Terraform will make to match your configuration.

Terraform Apply

Apply - Make the planned changes.

Track your infrastructure and Collaborate

Terraform keeps track of your real infrastructure in a state file, which acts as a source of truth for your environment. Terraform uses the state file to determine the changes to make to your infrastructure so that it will match your configuration. Terraform's state allows you to track resource changes throughout your deployments. You can securely share your state with your teammates, provide a stable environment for Terraform to run in, and prevent race conditions when multiple people make configuration changes at once.

For more info read this.

terraform-nerc-r-shiny's People

Contributors

milstein avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rockpapergoat

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.