新聞中心
Steampipe: select * from cloud 可以讓你使用 SQL 來即時查詢你的云服務(AWS、Azure、GCP、Github、Slack 等),是一個開源 的 CLI 工具,不需要數(shù)據(jù)庫。Steampipe 將 API 和服務暴露成高性能關(guān)系數(shù)據(jù)庫,使你能夠編寫基于 SQL 的查詢來探索動態(tài)數(shù)據(jù)。Mods 通過使用簡單 HCL 構(gòu)建的 Dashboard、報告和控件擴展 Steampipe 的功能。

創(chuàng)新互聯(lián)建站是一家專業(yè)提供石門企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站制作、網(wǎng)站設(shè)計、html5、小程序制作等業(yè)務。10年已為石門眾多企業(yè)、政府機構(gòu)等服務。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進行中。
安裝
可以前往官方網(wǎng)站 https://steampipe.io/downloads 選擇對應的平臺下載安裝包。
假如你是 Linux 用戶,則可以使用下面的命令進行一鍵安裝。
sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)"
安裝后檢測是否成功。
~$ steampipe -v
steampipe version 0.15.2
如果顯示了上面的版本信息證明安裝成功了。
接下來就可以根據(jù)自己的需要去安裝對應的插件了 steampipe plugin install steampipe。
如果你是 Mac 用戶,則可以使用 Homebrew 進行一鍵安裝 brew install steampipe。
使用
這里我們以 AWS 為例進行說明如何使用 steampipe。
首先,下載并安裝 Steampipe,然后安裝插件:
steampipe plugin install aws
Steampipe 將在你第一次運行 steampipe 查詢時下載和安裝額外的組件,因此它最初可能需要幾秒鐘的時間來加載。
Steampipe 支持很多插件,可以在官網(wǎng) https://hub.steampipe.io/plugins 進行查看。
插件安裝完成后,Steampipe 將使用你的憑證文件和/或環(huán)境變量中的默認 AWS 憑證,所以你需要確保這些也已經(jīng)配置好了。
我們可以使用 profile 參數(shù)從 AWS 憑證文件中指定命名配置文件。每個配置文件的連接,使用命名配置文件可能是最常見的配置:
aws 憑證文件
[profile_y]
aws_access_key_id = AKIA4YFAKEKEYXTDS252
aws_secret_access_key = SH42YMW5p3EThisIsNotRealzTiEUwXN8BOIOF5J8m
region = us-west-2
[profile_z]
aws_access_key_id = AKIA4YFAKEKEYJ7HS98F
aws_secret_access_key = Apf938vDKd8ThisIsNotRealzTiEUwXj9nKLWP9mg4
aws.spc
connection "aws_account_y" {
plugin = "aws"
profile = "profile_y"
regions = ["us-east-1", "us-west-2"]
}
connection "aws_account_z" {
plugin = "aws"
profile = "profile_z"
regions = ["ap-southeast-1", "ap-southeast-2"]
}如果你能運行 aws ec2 describe-vpcs,則證明就可以使用了。
Steampipe 提供的命令允許你在不離開查詢 shell 的情況下發(fā)現(xiàn)和探索表和數(shù)據(jù)。可以運行 steampipe query 來打開交互式查詢會話:
$ steampipe query
Welcome to Steampipe v0.5.0
For more information, type .help
>
然后運行 .tables 命令可以列出可用的表:
> .tables
==> aws
+----------------------------------------+---------------------------------------------+
| table | description |
+----------------------------------------+---------------------------------------------+
| aws_accessanalyzer_analyzer | AWS Access Analyzer |
| aws_account | AWS Account |
| aws_acm_certificate | AWS ACM Certificate |
| aws_api_gateway_api_key | AWS API Gateway API Key |
...
+----------------------------------------+---------------------------------------------+
正常情況下我們會看到 aws 插件中有很多可用的表!比如有一個 aws_iam_role 表,我們可以來運行 .inspect 命令來查看該表中的內(nèi)容:
> .inspect aws_iam_role
+---------------------------+-----------------------------+---------------------------------------------------------------------------------------------------+
| column | type | description |
+---------------------------+-----------------------------+---------------------------------------------------------------------------------------------------+
| account_id | text | The AWS Account ID in which the resource is located. |
| akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. |
| arn | text | The Amazon Resource Name (ARN) specifying the role. |
| assume_role_policy | jsonb | The policy that grants an entity permission to assume the role. |
| assume_role_policy_std | jsonb | Contains the assume role policy in a canonical form for easier searching. |
| attached_policy_arns | jsonb | A list of managed policies attached to the role. |
| create_date | timestamp without time zone | The date and time when the role was created. |
| description | text | A user-provided description of the role. |
| inline_policies | jsonb | A list of policy documents that are embedded as inline policies for the role..
...
+---------------------------+-----------------------------+---------------------------------------------------------------------------------------------------+
現(xiàn)在我們知道 aws_iam_role 表中有哪些列可用,我們就可以運行一個簡單的查詢來列出角色:
select name from aws_iam_role
再查詢一個稍微復雜的場景,讓我們找到?jīng)]有應用邊界策略的角色:
select
name
from
aws_iam_role
where
permissions_boundary_arn is null;
和其他數(shù)據(jù)庫一樣,我們也可以將表連接在一起。例如,我們可以找到所有附加了 AWS 托管策略的角色:
select
r.name,
policy_arn,
p.is_aws_managed
from
aws_iam_role as r,
jsonb_array_elements_text(attached_policy_arns) as policy_arn,
aws_iam_policy as p
where
p.arn = policy_arn
and p.is_aws_managed;
+-------------------------------------------------------+------------------------------------------------------------------------------------+----------------+
| name | policy_arn | is_aws_managed |
+-------------------------------------------------------+------------------------------------------------------------------------------------+----------------+
| aws-elasticbeanstalk-ec2-role | arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier | true |
| aws-elasticbeanstalk-ec2-role | arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker | true |
| admin | arn:aws:iam::aws:policy/ReadOnlyAccess | true |
| AWSServiceRoleForSSO | arn:aws:iam::aws:policy/aws-service-role/AWSSSOServiceRolePolicy | true |
| AWSServiceRoleForAccessAnalyzer | arn:aws:iam::aws:policy/aws-service-role/AccessAnalyzerServiceRolePolicy | true |
| aws-elasticbeanstalk-service-role | arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkEnhancedHealth | true |
| AWSServiceRoleForElasticLoadBalancing | arn:aws:iam::aws:policy/aws-service-role/AWSElasticLoadBalancingServiceRolePolicy | true |
| aws-elasticbeanstalk-service-role | arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkService | true |
| AWSServiceRoleForOrganizations | arn:aws:iam::aws:policy/aws-service-role/AWSOrganizationsServiceTrustPolicy | true |
+-------------------------------------------------------+------------------------------------------------------------------------------------+----------------+
Steampipe 插件提供了一種簡單的方式來查詢您的配置,而 Steampipe modes 允許你創(chuàng)建和共享 dahsboard、報告和控件。Steampipe Dashboard 可讓你可視化你的 Steampipe 數(shù)據(jù)。
我們可以下載 AWS Insights mod 并查看儀表板。首先克隆 repo:
git clone https://github.com/turbot/steampipe-mod-aws-insights.git
然后切換到該目錄并運行 steampipe 儀表板:
cd steampipe-mod-aws-insights
steampipe dashboard
這樣就可以啟動 Dashboard 了。
Steampipe 將在瀏覽器中打開 http://localhost:9194/。主頁列出了可用的儀表板,并且可以按標題或標簽進行搜索。單擊報告的標題以查看它。例如,單擊 AWS CloudTrail Trail Dashboard 進行查看。
你可以在任何頁面頂部的搜索欄中導航到另一個儀表板,或者,你可以單擊左上角的 Steampipe logo 返回主頁。完成后,你可以返回終端控制臺并鍵入 Ctrl+c 退出。
Git 倉庫:https://github.com/turbot/steampipe。
網(wǎng)頁名稱:使用 SQL 絲滑查詢你的云 API 數(shù)據(jù) - Steampipe
網(wǎng)站路徑:http://m.fisionsoft.com.cn/article/djsoooj.html


咨詢
建站咨詢
