Skip to content

Instantly share code, notes, and snippets.

@scarolan
Last active May 23, 2018 19:55
Show Gist options
  • Save scarolan/dfcf1af65821bf758dbc634a94164fde to your computer and use it in GitHub Desktop.
Save scarolan/dfcf1af65821bf758dbc634a94164fde to your computer and use it in GitHub Desktop.
# My first Terraform
variable "access_key" {}
variable "secret_key" {}
variable "ami" {}
variable "subnet_id" {}
variable "instance_type" {}
variable "vpc_security_group_id" {}
variable "identity" {}
variable "region" {
default = "us-west-2"
}
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
module "server" {
source = "./server"
ami = "${var.ami}"
subnet_id = "${var.subnet_id}"
vpc_security_group_id = "${var.vpc_security_group_id}"
identity = "${var.identity}"
instance_type = "${var.instance_type}"
}
output "public_ip" {
value = "${module.server.public_ip}"
}
# My first Terraform module
variable "ami" {}
variable "subnet_id" {}
variable "instance_type" {}
variable "vpc_security_group_id" {}
variable "identity" {}
resource "aws_instance" "web" {
ami = "${var.ami}"
instance_type = "${var.instance_type}"
vpc_security_group_ids = ["${var.vpc_security_group_id}"]
subnet_id = "${var.subnet_id}"
tags = {
Identity = "${var.identity}"
}
}
output "public_ip" {
value = "${aws_instance.web.public_ip}"
}
output "public_dns" {
value = "${aws_instance.web.public_dns}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment