73 lines
2.1 KiB
Ruby
73 lines
2.1 KiB
Ruby
class Terraform < Formula
|
|
desc "Tool to build, change, and version infrastructure"
|
|
homepage "https://www.terraform.io/"
|
|
url "https://github.com/hashicorp/terraform/archive/v0.12.19.tar.gz"
|
|
sha256 "bcc7a2d074a0d22cfa8daf0a604167b61b439d2769840909a47556c5644bda4d"
|
|
head "https://github.com/hashicorp/terraform.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "7f8a1371bc9786efd3aec4401c37a45b5f19dced3c62150cc97cf5e93a24817f" => :catalina
|
|
sha256 "87fb6c29636c1a19eeac2ce5b4b4cde1018da45323915a4a441006eb81d5f435" => :mojave
|
|
sha256 "bf6ebda1beb2dc91e5ec6e607456ce1c0789dfe102d25e879856dfd5938eb3dd" => :high_sierra
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "gox" => :build
|
|
|
|
conflicts_with "tfenv", :because => "tfenv symlinks terraform binaries"
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
ENV.prepend_create_path "PATH", buildpath/"bin"
|
|
|
|
dir = buildpath/"src/github.com/hashicorp/terraform"
|
|
dir.install buildpath.children - [buildpath/".brew_home"]
|
|
|
|
cd dir do
|
|
# v0.6.12 - source contains tests which fail if these environment variables are set locally.
|
|
ENV.delete "AWS_ACCESS_KEY"
|
|
ENV.delete "AWS_SECRET_KEY"
|
|
|
|
ENV["XC_OS"] = "darwin"
|
|
ENV["XC_ARCH"] = "amd64"
|
|
system "make", "tools", "bin"
|
|
|
|
bin.install "pkg/darwin_amd64/terraform"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
test do
|
|
minimal = testpath/"minimal.tf"
|
|
minimal.write <<~EOS
|
|
variable "aws_region" {
|
|
default = "us-west-2"
|
|
}
|
|
|
|
variable "aws_amis" {
|
|
default = {
|
|
eu-west-1 = "ami-b1cf19c6"
|
|
us-east-1 = "ami-de7ab6b6"
|
|
us-west-1 = "ami-3f75767a"
|
|
us-west-2 = "ami-21f78e11"
|
|
}
|
|
}
|
|
|
|
# Specify the provider and access details
|
|
provider "aws" {
|
|
access_key = "this_is_a_fake_access"
|
|
secret_key = "this_is_a_fake_secret"
|
|
region = var.aws_region
|
|
}
|
|
|
|
resource "aws_instance" "web" {
|
|
instance_type = "m1.small"
|
|
ami = var.aws_amis[var.aws_region]
|
|
count = 4
|
|
}
|
|
EOS
|
|
system "#{bin}/terraform", "init"
|
|
system "#{bin}/terraform", "graph"
|
|
end
|
|
end
|