安装适用于 Linux 和 macOS 的 Guard - AWS CloudFormation Guard

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

安装适用于 Linux 和 macOS 的 Guard

你可以使用预先构建 AWS CloudFormation Guard 的发行版二进制文件 Cargo 或 Homebrew 在 Linux 和 macOS 上安装。

从预先构建的发行版二进制文件安装 Guard

使用以下步骤从预先构建的二进制文件安装 Guard。

  1. 打开终端,然后运行以下命令。

    curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/aws-cloudformation/cloudformation-guard/main/install-guard.sh | sh
  2. 运行以下命令来设置您的PATH变量。

    export PATH=~/.guard/bin:$PATH

    结果:您已成功安装了 Guard 并设置了PATH变量。

    1. (可选)要确认 Guard 的安装,请运行以下命令。

      cfn-guard --version

      该命令将返回以下输出。

      cfn-guard 3.0.0

安装货物防护

Cargo 是 Rust 包管理器。完成以下步骤来安装 Rust,其中包括 Cargo。然后,安装 Guard from Cargo。

  1. 从终端运行以下命令,然后按照屏幕上的说明安装 Rust。

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    1. (可选)对于 Ubuntu 环境,请运行以下命令。

      sudo apt-get update; sudo apt install build-essential
  2. 配置您的PATH环境变量,然后运行以下命令。

    source $HOME/.cargo/env
  3. 安装了 Cargo 后,运行以下命令来安装 Guard。

    cargo install cfn-guard

    结果:你已经成功安装了 Guard。

    1. (可选)要确认 Guard 的安装,请运行以下命令。

      cfn-guard --version

      该命令将返回以下输出。

      cfn-guard 3.0.0

从 Homebrew 安装 Guard

Homebrew 是一款适用于 macOS 和 Linux 的软件包管理器。完成以下步骤来安装 Homebrew。然后,从 Homebrew 中安装 Guard。

  1. 从终端运行以下命令,然后按照屏幕上的说明安装 Homebrew。

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. 安装了 Homebrew 后,运行以下命令来安装 Guard。

    brew install cloudformation-guard

    结果:你已经成功安装了 Guard。

    1. (可选)要确认 Guard 的安装,请运行以下命令。

      cfn-guard --version

      该命令将返回以下输出。

      cfn-guard 3.0.0