class Atmos < Formula desc "Universal Tool for DevOps and Cloud Automation" homepage "https://github.com/cloudposse/atmos" url "https://github.com/cloudposse/atmos/archive/v1.19.1.tar.gz" sha256 "6a317b86adce8aca5c87d75bbd2f1aa1698c7d2c338f62421a1b0754319087be" license "Apache-2.0" bottle do sha256 cellar: :any_skip_relocation, arm64_ventura: "8273e900179d5427821f00779d1c4faf7f40c1309b3be97978c8439474c6b588" sha256 cellar: :any_skip_relocation, arm64_monterey: "bd0c541f0c351ca188806e3df140b0ba3ec1b3d141056f45830b0b5f3df38d80" sha256 cellar: :any_skip_relocation, arm64_big_sur: "f066496954d06fadb49b76133a42cf0cd2ddae4867e835b8ca92570655ee0422" sha256 cellar: :any_skip_relocation, ventura: "27ccda7e5e1a9682b595ed84bff89f7618b52254821a8ec7783cebdcfa31b29c" sha256 cellar: :any_skip_relocation, monterey: "ba4fd3b84a38a6ef041f30125cd917cdcc99480a56b2d4b64eeb7d6e6d5ea9ed" sha256 cellar: :any_skip_relocation, big_sur: "c80463dd4f1bc0ba08eea9034160dd9638203b8dcd1c5677bb7c3e2a2f70ca82" sha256 cellar: :any_skip_relocation, x86_64_linux: "831898da54af8687044b7aece56f68e880cf4f20cfbc092dd14e0dbd43432d50" end depends_on "go" => :build def install system "go", "build", *std_go_args(ldflags: "-s -w -X 'github.com/cloudposse/atmos/cmd.Version=#{version}'") generate_completions_from_executable(bin/"atmos", "completion") end test do # create basic atmos.yaml (testpath/"atmos.yaml").write <<~EOT components: terraform: base_path: "./components/terraform" apply_auto_approve: false deploy_run_init: true auto_generate_backend_file: false helmfile: base_path: "./components/helmfile" kubeconfig_path: "/dev/shm" helm_aws_profile_pattern: "{namespace}-{tenant}-gbl-{stage}-helm" cluster_name_pattern: "{namespace}-{tenant}-{environment}-{stage}-eks-cluster" stacks: base_path: "./stacks" included_paths: - "**/*" excluded_paths: - "globals/**/*" - "catalog/**/*" - "**/*globals*" name_pattern: "{tenant}-{environment}-{stage}" logs: verbose: false colors: true EOT # create scaffold mkdir_p testpath/"stacks" mkdir_p testpath/"components/terraform/top-level-component1" (testpath/"stacks/tenant1-ue2-dev.yaml").write <<~EOT terraform: backend_type: s3 # s3, remote, vault, static, etc. backend: s3: encrypt: true bucket: "eg-ue2-root-tfstate" key: "terraform.tfstate" dynamodb_table: "eg-ue2-root-tfstate-lock" acl: "bucket-owner-full-control" region: "us-east-2" role_arn: null remote: vault: vars: tenant: tenant1 region: us-east-2 environment: ue2 stage: dev components: terraform: top-level-component1: {} EOT # create expected file (testpath/"backend.tf.json").write <<~EOT { "terraform": { "backend": { "s3": { "workspace_key_prefix": "top-level-component1", "acl": "bucket-owner-full-control", "bucket": "eg-ue2-root-tfstate", "dynamodb_table": "eg-ue2-root-tfstate-lock", "encrypt": true, "key": "terraform.tfstate", "region": "us-east-2", "role_arn": null } } } } EOT system bin/"atmos", "terraform", "generate", "backend", "top-level-component1", "--stack", "tenant1-ue2-dev" actual_json = JSON.parse(File.read(testpath/"components/terraform/top-level-component1/backend.tf.json")) expected_json = JSON.parse(File.read(testpath/"backend.tf.json")) assert_equal expected_json["terraform"].to_set, actual_json["terraform"].to_set end end