Steampipe的安装部署及简单使用(附带AWS CLI的安装与使用)

介绍

Steampipe 将 API 和服务公开为高性能关系数据库,使您能够编写基于 SQL 的查询来探索动态数据。Mods 通过使用简单 HCL 构建的仪表板、报告和控件扩展了 Steampipe 的功能。
官网:https://steampipe.io/

steampipe的安装

下载脚本并执行

sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)"

版本检查

steampipe -v
steampipe version 0.14.3

安装第一个插件

steampipe plugin install steampipe

Installed plugin: steampipe

测试运行您的第一个查询

steampipe query "select name from steampipe_registry_plugin;"

+------------------+
|       name       |
+------------------+
| turbot/aws       |
| turbot/steampipe |
| turbot/azure     |
| ...              |
+------------------+
  1. 上面这些步骤是Steampipe 的一步安装程序下载steampipe 二进制文件,将其安装到/usr/local/bin.,然后.steampipe在您的主目录中创建一个目录,其中包含所有支持库和启动所需的配置(包括 PostgreSQL)。
  2. 如需更新只需重新运行第一步上面的 curl 脚本即可安装最新发布的 Steampipe 版本。
  3. Steampipe 也可以作为二进制可执行文件使用(或者您可以从源代码构建)。要手动安装 Steampipe,请解压缩可执行文件并将其移动到系统的. PATH 可以从Steampipe Github
    存储库的发布部分访问源代码、压缩的可执行文件和二进制校验和。

steampipe的使用

因为我有一台aws的服务器我们本次举例aws的插件
首先需要在服务器在设置 AWS 环境(CLI)

配置 AWS 命令行界面 (CLI)

简介

AWS 命令行界面 (CLI) 是用于管理 AWS 产品的统一工具。只需要下载和配置一个工具,您就可以使用命令行控制多个 AWS 产品并利用脚本来自动执行这些服务。要使用 CLI 与 AWS 交互,需要配置凭证以供其在进行 API 调用时使用。

安装 AWS CLI

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

unzip awscliv2.zip

./aws/install

安装后查看是否安装成功

aws --version
aws-cli/2.2.17 Python/3.9.6 Darwin/20.5.0 source/x86_64 prompt/off

AWS CLI 现已正确安装,我们需要配置凭证。可以尝试运行诸如 aws ec2 describe-vpcs 之类的命令来查看是否一切运转正常。由于缺少凭证,您可能会看到以下错误消息:

aws ec2 describe-vpcs

# You may not see this error if you have already configured the CLI previously.
Unable to locate credentials. You can configure credentials by running ‘aws configure’.

配置 AWS CLI 凭证

要配置凭证,请使用命令 aws configure 。系统将要求您提供 AWS 访问密钥 ID、AWS 秘密访问密钥、原定设置区域和原定设置输出格式。

最后,格式类型是原定设置显示输出的方式,包括但不限于:json、yaml、text。完成后,您应该在终端中看到以下内容 (如果您选择 us-east-1 作为原定设置区域):
aws configure

AWS Access Key ID [None]: ANOTREALACCESSKEYID
AWS Secret Access Key [None]: ANOTREALSECRETACCESSKEY
Default region name [None]: us-east-1
Default output format [None]: json

(查找方法会在下面介绍)

现在我们可以运行之前的命令并查看结果,因为每个新的 AWS 账户都配置了原定设置 VPC:

aws ec2 describe-vpcs


# Output
{
    "Vpcs": [
        {
            "CidrBlock": "10.0.0.0/16",
            "DhcpOptionsId": "dopt-d12345",
            "State": "available",
            "VpcId": "vpc-0123456789abcdef",
            "OwnerId": "123456789012",
            ....

这就确认了 AWS CLI 现在已正确设置。它在 ~/.aws 中创建了两个文件:config 和 credentials。credentials 文件包含您指定的凭证:

[default]
aws_access_key_id = AKNOTREALACCESSKEYID
aws_secret_access_key ==AyNOTREALSECRETACCESSKEY

配置文件的任何其他配置都存储在 config 文件中。使用 aws configure 时,它将包含以下内容 (可能具有不同的区域):

[default]
region = us-east-1
output = json

AWS access ID 和 Secret的查找方法

在IAM的控制台上的右边找到我的安全凭证
在这里插入图片描述
选择访问密钥(访问密钥ID和秘密访问密钥)后即可查看
在这里插入图片描述

选择插件

选择插件的时候我们可以在官方网站上选择可用的插件
在这里插入图片描述
选择aws service插件
在这里插入图片描述

steampipe为了减少风险不支持在root用户上运行所以需要在普通用户下操作。

steampipe plugin install aws #这边已经下好了

在这里插入图片描述
填写相关的配置

vim .steampipe/config/aws.spc

connection "aws" {
  plugin = "aws"
  access_key = "***************"
  secret_key = "***************"
  # You may connect to one or more regions. If `regions` is not specified,
  # Steampipe will use a single default region using the same resolution
  # order as the AWS CLI:
  #  1. The `AWS_DEFAULT_REGION` or `AWS_REGION` environment variable
  #  2. The region specified in the active profile (`AWS_PROFILE` or default)
  #regions = ["us-east-1", "us-west-2"]
  regions=["**-****-*"]
  # If no credentials are specified, the plugin will use the AWS credentials
  # resolver to get the current credentials in the same manner as the CLI.
  # Alternatively, you may set static credentials with the `access_key`,
  # `secret_key`, and `session_token` arguments, or select a named profile
  # from an AWS credential file with the `profile` argument:
  profile = "******" #把credentials的标头写上就好
  # The maximum number of attempts (including the initial call) Steampipe will
  # make for failing API calls. Can also be set with the AWS_MAX_ATTEMPTS environment variable.
  # Defaults to 9 and must be greater than or equal to 1.
  #max_error_retry_attempts = 9

  # The minimum retry delay in milliseconds after which retries will be performed.
  # This delay is also used as a base value when calculating the exponential backoff retry times.
  # Defaults to 25ms and must be greater than or equal to 1ms.
  #min_error_retry_delay = 25

保存退出后测试

[lcf@server4 ~]$ steampipe query
Welcome to Steampipe v0.14.1
For more information, type .help
> select * from aws_vpc
+-----------------------+--------------------------------------------------------------+---------------+-----------+------------+-----------------------
| vpc_id                | arn                                                          | cidr_block    | state     | is_default | dhcp_options_id       
+-----------------------+--------------------------------------------------------------+---------------+-----------+------------+-----------------------
| vpc-************* | arn:aws:ec2:********:**********:vpc/vpc-*************** | ***.**.0.0/16 | available | true       | ********************
+-----------------------+--------------------------------------------------------------+---------------+-----------+------------+-----------------------
> 

成功!
更多功能请查看官方文档

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lll_cf

喜欢

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值