Giter Club home page Giter Club logo

terraform-aws-ec2-instance's Introduction

terraform-aws-ec2-instance

An opinionated module that creates an ec2 instance to be used as a bastion.

Instantiation

The simplest instantiation requires only an environment and ami_id.

module "ec2" {
  source = "[email protected]:kiawnna/terraform-aws-ec2-instance.git"
  ami_id = "ami-id"
  environment = var.environment
}

This example will create an ec2 instance without a key pair, with the defaults found below in Variables / Customizations.


To use this module as a bastion, you would need to add a key_pair and subnet_id as well. The below example also shows how you can programmatically grab the ami id for an Amazon Linux 2 AMI.

data "aws_ami" "amazon-2" {
  most_recent = true

  filter {
    name = "name"
    values = ["amzn2-ami-hvm-*-x86_64-ebs"]
  }
  owners = ["amazon"]
}

module "bastion" {
  source = "[email protected]:kiawnna/terraform-aws-ec2-instance.git"
  ami_id = data.aws_ami.amazon-2.id
  key_pair = "my-key-pair.pem"
  environment = var.environment
  subnet_id = "subnet-id"
}

This example will create an amazon linux 2 instance, type t2.micro in a subnet of your choice.

Resources Created

  • An EC2 instance.

Outputs

The instance id.

Reference it as:

module.ec2_instance_module_name.instance_id

Variables / Customization

The variable below can be customized to fit your needs. The current defaults are:

  • instance_type → t2.micro
  • associate_public_iptrue
  • subnet_id → none
  • key_pair → none
  • security_group_ids → none
  • environment → none

See the variables.tf file for further information.

Tags

Tags are automatically added to all resources where possible. Tags will have the following format:

tags = {
    Name = "${var.environment}-bastion"
    Deployment_Method = "terraform"
    Environment = var.environment
}

terraform-aws-ec2-instance's People

Contributors

kiawnna avatar

Watchers

 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.