Skip to content

Basic ec2 instance on AWS with some defaults like VPC, IAM, and security group settings

License

Notifications You must be signed in to change notification settings

insight-infrastructure/terraform-aws-ec2-basic

Repository files navigation

terraform-aws-ec2-basic

Terraform module to run a basic ec2 on AWS with some basic defaults.

Features

  • ec2
    • Basic options exposed
  • Security group
  • VPC
    • If no VPC is supplied, deploys in default VPC
  • EBS
    • Create volume and mount or not
  • IAM
    • Able to provide custom policy or managed policy for instance profile
  • Elastic IP
    • Optional create
  • AMI
    • Supply AMI ID or default to ubuntu
  • Key pair
    • Supply public key or just keyname
  • User data
    • You are going to want to override

Terraform Versions

For Terraform v0.12.0+

Usage

module "this" {
    source = "github.com/robc-io/terraform-aws-ec2-basic"
    name = "stuff"
}

Examples

Known Issues

No issue is creating limit on this module.

Providers

Name Version
aws n/a
random n/a
template n/a

Inputs

Name Description Type Default Required
ami_id n/a string "" no
create Boolean to determine if you should create the instance or destroy all associated resources bool true no
create_eip Optional ability to create elastic IP bool false no
ebs_prevent_destroy n/a bool false no
ebs_volume_id The volume id of the ebs volume to mount string "" no
ebs_volume_size n/a number 0 no
ec2_prevent_destroy n/a bool false no
egress_rules From terraform-aws-security-group module list(string)
[
"all-all"
]
no
eip_prevent_destroy n/a bool false no
iam_managed_policies List of managed policies to add to instance profile. Instance profile must not be specified as it has precendance list(string) [] no
ingress_cidr_blocks From terraform-aws-security-group module list(string) [] no
ingress_rules From terraform-aws-security-group module list(string) [] no
ingress_with_cidr_blocks From terraform-aws-security-group module list(map(string)) [] no
instance_profile_id n/a string "" no
instance_type n/a string "m4.large" no
json_policy A user supplied policy to add to the instance string "" no
json_policy_name The name of the user defined policy string "" no
key_name If this is supplied, it takes precidence string "" no
local_public_key n/a string "" no
monitoring Send logs and metrics to cloudwatch bool true no
name The name to be used in tags any n/a yes
root_volume_size n/a number 8 no
subnet_id Supply both vpc_id and subnet_id or deploy into default vpc string "" no
tags Tags that are appended map(string) {} no
user_data n/a string "" no
user_data_script n/a string "user_data_ubuntu_ebs.sh" no
volume_path n/a string "/dev/sdf" no
vpc_id Supply both vpc_id and subnet_id or deploy into default vpc string "" no
vpc_security_group_ids A list of provided descurity group IDs list(string) n/a yes

Outputs

Name Description
eip_id n/a
instance_id n/a
instance_profile_id n/a
key_name n/a
private_ip n/a
public_ip n/a
volume_path n/a

Testing

This module has been packaged with terratest tests.

go mod tidy
make test

To run them:

  1. Install Go
  2. Run make test-init from the root of this repo
  3. Run make test again from root

Authors

Module managed by robc-io

Credits

License

Apache 2 Licensed. See LICENSE for full details.

About

Basic ec2 instance on AWS with some defaults like VPC, IAM, and security group settings

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •