79 lines
2.6 KiB
Ruby
79 lines
2.6 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/v1.0.8.tar.gz"
|
|
sha256 "b12daf73d366e11fdceec78479613703e123712bb06abd8a2006931a667d5459"
|
|
license "MPL-2.0"
|
|
head "https://github.com/hashicorp/terraform.git", branch: "main"
|
|
|
|
livecheck do
|
|
url "https://releases.hashicorp.com/terraform/"
|
|
regex(%r{href=.*?v?(\d+(?:\.\d+)+)/?["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "dd54f125d6d1357e01f9a2cdc8e5848c92a53085f224905bc23b0df2bdaa3d8c"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "80de651d29e10455a58aa2cbb75e0d22383fc966944fcd77564db20430956641"
|
|
sha256 cellar: :any_skip_relocation, catalina: "a47d6194f3ba803c2e27871b1898a12e637933fc3499e17679d33a24934e4ae3"
|
|
sha256 cellar: :any_skip_relocation, mojave: "7e834190d12e58f6263879fdf73f7cd1166bba712ac56f7656a250d8813deb09"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "61c26bccdd56bf3e0e84b81e05d04bc13e824d7b551d0df43061f28429dc3128"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
on_linux do
|
|
depends_on "gcc"
|
|
end
|
|
|
|
conflicts_with "tfenv", because: "tfenv symlinks terraform binaries"
|
|
|
|
# Needs libraries at runtime:
|
|
# /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by node)
|
|
fails_with gcc: "5"
|
|
|
|
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"
|
|
|
|
# resolves issues fetching providers while on a VPN that uses /etc/resolv.conf
|
|
# https://github.com/hashicorp/terraform/issues/26532#issuecomment-720570774
|
|
ENV["CGO_ENABLED"] = "1"
|
|
|
|
system "go", "build", *std_go_args, "-ldflags", "-s -w"
|
|
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
|