Skip to content

Commit

Permalink
auto_ami_enable
Browse files Browse the repository at this point in the history
  • Loading branch information
yadavprakash committed Jun 2, 2021
1 parent 5576a6d commit 39b6d1b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 0 additions & 1 deletion _example/basic_example/.terraform.tfstate.lock.info

This file was deleted.

23 changes: 22 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,35 @@ locals {
ebs_iops = var.ebs_volume_type == "io1" ? var.ebs_iops : 0
}

data "aws_ami" "amazon_linux" {
most_recent = true

owners = ["amazon"]

filter {
name = "name"

values = [
"amzn-ami-hvm-*-x86_64-gp2",
]
}

filter {
name = "owner-alias"

values = [
"amazon",
]
}
}

#Module : EC2
#Description : Terraform module to create an EC2 resource on AWS with Elastic IP Addresses
# and Elastic Block Store.
resource "aws_instance" "default" {
count = var.instance_enabled == true ? var.instance_count : 0

ami = var.ami
ami = var.ami == "" ? data.aws_ami.amazon_linux.id : var.ami
ebs_optimized = var.ebs_optimized
instance_type = var.instance_type
key_name = var.key_name
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ variable "managedby" {
# Description : Terraform EC2 module variables.
variable "ami" {
type = string
default = ""
description = "The AMI to use for the instance."
}

Expand Down

0 comments on commit 39b6d1b

Please sign in to comment.