12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #-------------------------------
- # Create Nuxeo Ubuntu Instance
- #-------------------------------
- # Create a new EC2 instance
- variable "stack_name" {
- type = "string"
- description = "Name of the Stack/Env that this instance will used for"
- }
- variable "ubuntu_releases" {
- default = {
- trusty = "trusty-14.04"
- xenial = "xenial-16.04"
- yakkety = "yakkety-16.10"
- }
- }
- variable "os_release" {
- type = "string"
- description = "Ubuntu Release"
- default = "xenial"
- }
- variable "instance_type" {
- type = "string"
- description = "EC2 Instance Type"
- default = "t2.micro"
- }
- variable "instance_name" {
- type = "string"
- description = "Name to be give to this instance"
- }
- # Lookup on Amazon for the right AMI for Ubuntu on any region
- data "aws_ami" "ubuntu" {
- most_recent = true
- filter {
- name = "name"
- values = ["ubuntu/images/hvm-ssd/ubuntu-${lookup(var.ubuntu_releases, var.os_release)}-amd64-server-*"]
- }
- filter {
- name = "virtualization-type"
- values = ["hvm"]
- }
- owners = ["099720109477"] # Canonical
- }
- variable "subnet_id" {
- type = "string"
- }
- variable "public_key_path" {
- type = "string"
- description = "Local Path to the Pub Key to put on server"
- }
- #---------------------
- # Deployer SSH keys
- #--------------------
- resource "aws_key_pair" "deployer" {
- key_name = "deployer-key"
- public_key = "${file(var.public_key_path)}"
- }
- #---------------------
- # EC2 Instance
- #--------------------
- resource "aws_instance" "ec2" {
- ami = "${data.aws_ami.ubuntu.id}"
- instance_type = "${var.instance_type}"
- key_name = "${aws_key_pair.deployer.id}"
- subnet_id = "${var.subnet_id}"
- tags {
- Name = "${var.instance_name}"
- billing-category = "customers"
- billing-subcategory = "${var.stack_name}"
- role= "nuxeo.instance"
- managed_by="terraform"
- }
- }
|