Created
January 31, 2024 03:01
-
-
Save 5HT2/65ea4906c8f6e3c2ca969fb9f4445bbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Terraform < Formula | |
desc "Tool to build, change, and version infrastructure" | |
homepage "https://www.terraform.io/" | |
url "https://github.com/hashicorp/terraform/archive/refs/tags/v1.7.1.tar.gz" | |
sha256 "6a43ee1aeb3cd96e6407f746bea13572d98c01624c77a2e467628744ea8b7925" | |
license "BUSL-1.1" | |
head "https://github.com/hashicorp/terraform.git", branch: "main" | |
# TODO: Remove this if/when the formula is deprecated. | |
livecheck do | |
skip "Formula will not be updated due to BUSL license change" | |
end | |
depends_on "go" => :build | |
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment