MusicBot icon indicating copy to clipboard operation
MusicBot copied to clipboard

[Wiki] Add Terraform setup in docs

Open sawaca96 opened this issue 4 years ago • 0 comments

Is your feature request related to a problem? Please describe.

It would be nice if there was a example to use the terraform in the documentation.

What is your ideal solution to the problem?

This is an example of the aws provider.

Please put appropriate values in the 'region' , 'profile.' and 'ami'

# main.tf
provider "aws" {
  region  = "ap-northeast-2"
  profile = "jmusic-bot"
}

resource "aws_instance" "JMusicBot" {
  ami                    = "ami-0ba5cd124d7a79612"
  instance_type          = "t2.micro"
  vpc_security_group_ids = [aws_security_group.public.id]
  user_data              = <<-EOF
	#!/bin/bash
  sudo apt-get -y update
  sudo apt-get -y install openjdk-8-jdk
  wget https://github.com/jagrosh/MusicBot/releases/download/0.3.6/JMusicBot-0.3.6.jar
  { echo "${var.token}"; echo "${var.owner}"; } | java -Dnogui=true -jar JMusicBot-0.3.6.jar
	EOF
  tags = {
    Name = "JMusicBot"
  }
}

resource "aws_security_group" "public" {
  name = "public"

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

# vars.tf
variable "token" {
  description = "The token for the bot to log in with"
}

variable "owner" {
  description = "The owner of the bot"
}

How would this feature be used?

  1. It is useful for people who want to use JMusicBot using the cloud.
  2. You can use JMusicBot with a single command.

Additional Info

content is also here.

Checklist

sawaca96 avatar Oct 09 '21 12:10 sawaca96