Code Monkey home page Code Monkey logo

tf_aws_coreos_ami's Introduction

tf_aws_coreos_ami

Starting from Terraform version 0.7 this module is redundant, because Terraform has aws_ami data-structure which allows to get ID of specific CoreOS AMI.

Here is the code:

variable "channel" {
  default = "stable"
}

variable "virtualization_type" {
  default = "hvm"
}

data "aws_ami" "coreos" {
  most_recent = true

  owners = ["595879546273"]

  filter {
    name   = "architecture"
    values = ["x86_64"]
  }

  filter {
    name = "virtualization-type"
    values = ["${var.virtualization_type}"]
  }

  filter {
    name   = "name"
    values = ["CoreOS-${var.channel}-*"]
  }
}

output "ami_id" {
  value = "${data.aws_ami.coreos.image_id}"
}

If you are using Terraform older than version 0.7 keep reading and using this module.

Terraform module to get the current set of publicly available CoreOS AMIs.

This module grabs all of the AMIs listed at:

https://coreos.com/docs/running-coreos/cloud-providers/ec2/

and then looks up the one you want given the input variables.

Input variables

  • region - E.g. eu-central-1
  • channel - stable/alpha/beta
  • virttype - hvm/pv

Outputs

  • ami_id

Example use

module "ami" {
  source = "github.com/terraform-community-modules/tf_aws_coreos_ami"
  region = "eu-central-1"
  channel = "stable"
  virttype = "hvm"
}

resource "aws_instance" "core" {
  instances = 5
  ami = "${module.ami.ami_id}"
  instance_type = "m3.8xlarge"
}

Note

This module has bundled version of variables.tf.json, but if you need to update it you can run make in this directory to pull that file down.

You can do this with a few lines like this in your top level Makefile:

.terraform/modules:
        terraform get
        for i in $$(ls .terraform/modules/*/Makefile); do i=$$(dirname $$i); make -C $$i; done

Consider open a pull-request with updated variables.tf.json.

Getting an AMI by instance_type

Often you don't want to care if you need an hvm or pv instance.

In these cases, you can instead use:

module "ami" {
  source = "github.com/terraform-community-modules/tf_aws_coreos_ami/instance_type"
  region = "eu-central-1"
  channel = "stable"
  instance_type = "m3.large"
}

Note this prefers hvm instances where available.

LICENSE

Apache2 - See the included LICENSE file for more information.

tf_aws_coreos_ami's People

Contributors

bobtfish avatar antonbabenko avatar paultyng avatar iamveen avatar tilgovi avatar rdowne avatar girishramnani 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.