Coder Social home page Coder Social logo

terraform_aws_spot_instance's Introduction

How to use terraform to spin up three ubuntu nodes using spot instances.

Download and Install Terraform

https://www.terraform.io/downloads.html

Edit the k8s.tf file:

  1. Change "YOUR_KEY_NAME_HERE" to your ssh keyname (assumes it's already uploaded)
  2. Update the AWS region as desired (make sure your ssh key is in this region)
  3. Add your AWS "access key" and "aws_secret_key" to this file (NOT RECOMENDED). Terraform will use ~/.aws/credentials if not specified in the .tf file. (RECOMENDED)

Bootstrap terraform

  1. Run terraform init
  2. Run terraform plan
  3. Run terraform apply

If your IP Address changes, and you lose access to ssh into your hosts, just run terraform apply again and the security group will be updated with your new IP Address.

If you don't know how to create and upload a key pair to aws, see here. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

To tear down all the created resources

  1. Run terraform destroy

Changes and fixes

  1. Added aws_ec2_tag resources to tag spot instances, as spot request api doesn't tag instances
  2. Added helper script to get an Ansible inventory: ./ansible-inventory.sh >../ansible-k8s-setup-kubeadm/inventory
  3. ...

terraform_aws_spot_instance's People

Contributors

magic7s avatar emanueleborin avatar emanueleborinatscaiitec avatar

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.