67 lines
2.0 KiB
Ruby
67 lines
2.0 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.13.2.tar.gz"
|
|
sha256 "f1138827f4a60f028860dddb742d8c1ab06d0b6975c9312bc7e9b399e8e040b5"
|
|
license "MPL-2.0"
|
|
head "https://github.com/hashicorp/terraform.git"
|
|
|
|
livecheck do
|
|
url "https://releases.hashicorp.com/terraform/"
|
|
regex(%r{href=.*?v?(\d+(?:\.\d+)+)/?["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "95d2f29209c06dc0b7bf87a7fd8b738353c82501c33efb266f734aa79394a3e5" => :catalina
|
|
sha256 "9f3f792c671c61654ef30bd81cf7e834c164fea3487b626d8a4c870fda0c326f" => :mojave
|
|
sha256 "f2d9f7dfcb34814a3bb8e5faaef33946aea74c7d797dd1c62a510585fde1b400" => :high_sierra
|
|
end
|
|
|
|
depends_on "go@1.14" => :build
|
|
|
|
conflicts_with "tfenv", because: "tfenv symlinks terraform binaries"
|
|
|
|
def install
|
|
# 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["CGO_ENABLED"] = "0"
|
|
system "go", "build", *std_go_args, "-ldflags", "-s -w", "-mod=vendor"
|
|
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
|