trevor-laher / OnDemandMinecraft

An AWS hosted Minecraft server that will only run when players are active. Players can start the server through a simple UI accessed through free Heroku server hosting.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cloudformation Automation

Cyrokrypto opened this issue · comments

I like this idea, but I feel like the deployment process could be vastly simplified and be made more secure by using a Cloudformation template to take care of the majority of deployment:

The deployment steps would change to:

  • Create an SSH keypair.
  • Create a Cloudformation stack, select AMI / Instance Type / Keypair

The Cloudformation stack will:

  • Create an IAM role.
  • Set up the security group.
  • Create the EC2 instance in the current region.
  • Download an install script from this git repo (downloaded by EC2 launch script)

The launch script will:

  • Clone this repository.
  • Create the 'ubuntu' user.
  • Install openjdk
  • Download the latest Minecraft server .jar
  • Configure crontab, permissions etc.

The instance will use the IAM role to authenticate with Boto3 instead of hard coding your AWS credentials.

Thoughts?

I think this is a fantastic idea and wasn't aware that so much of the AWS configuration could be set up remotely. Downloading the latest jar however might be difficult as there is a specific URL for each server file, this used to not be the case. I'll have to double check that this is the case, however.

commented

You should use the AWS cdk to model your infrastructure: https://github.com/awslabs/aws-cdk

@sam-goodwin I have nothing against using aws-cdk, however, I think Troposphere would make more sense in the scope of this project as Python is already being used.

@trevor-laher I think the entire process can be automated. I'll work on something over the weekend if I manage to get some free time. With regards to finding the latest .jar, it looks like versions and their URLs can be located here: https://launchermeta.mojang.com/mc/game/version_manifest.json

commented

The cdk has a python version if that changes anything.

Yeah infrastructure as code is exactly what this project is musimy. I have mostly used terraform for that it basically does the same thing as cloud formation. And that would be extremely easy to create since there is a open source solution called terraforming that allows to create terraform file from existing infra structure. I will take a look at this in my free time:D

  • it would be language agnostic so anyone without aws and python knowledge could easly change simple configuration such as instance type etc.

The CloudFormation stack can also be used to automate creation of Heroku web application using a combination of AWS services. The amount of users accessing this backend will most likely always fall under the free tier anyways.

  • S3 Bucket for static website content
  • API Gateway for the post request after entering the correct password
  • Lambda to check/start the server/get the IP address

@seang96 I was thinking the same. To make this easier, as the web app is written with Flask. Zappa can be used to easily deploy to Lambda / S3 / API Gateway.

Opening up a branch and looking into this now. Feel free to check it out and make some progress.

Opening up a branch and looking into this now. Feel free to check it out and make some progress.

@trevor-laher I've made some progress on this over the weekend. Let me know once you've created a new branch and I'll create a pull request.

@trevor-laher if you have interest in exploring the terraform route, I made a branch from my exploration this evening. Let me know and I'll prioritize making a getting started readme.

[X] Security groups
[X] EC2 instance
[X] Heroku app ( I plan on investigating AWS Lambda eventually)
[X] SSH key
[ ] Setting up ec2 instance
[ ] Pushing code to heroku

https://github.com/paul-schwendenman/OnDemandMinecraft/tree/terrafy