poco
PostgreSQL到Honeycode管道 (PostgreSQL to Honeycode Pipeline)
Recently Amazon released their “no code” platform, Honeycode. The aim is to help non-developers pull together a working application with a WYSIWYG UI and logic that is closer to spreadsheet formulas!
最近,亚马逊发布了其“无代码”平台Honeycode 。 目的是帮助非开发人员将工作中的应用程序与所见即所得的 UI和更接近电子表格公式的逻辑组合在一起!
There is a lot of discussion online about the impact “no code”, “low code”, and “full code” will have, and we will have to see how it plays out as even Gartner predicts that by 2024, 65% of development will be performed on low-code platforms.
在线上有很多关于“无代码”,“低代码”和“完整代码”将产生的影响的讨论,而且我们将不得不观察它如何发挥作用,甚至Gartner预测到2024年, 发展的65%将在低代码平台上执行 。
Honeycode itself comes with several templates and seems aimed at creating standalone applications, MVPs etc..
Honeycode本身带有多个模板 ,似乎旨在创建独立的应用程序,MVP等。
Yet, I really want to tie this into our existing systems, allow our non developers to create applications that meet their needs with the data they require. Over the last few bog posts, we looked into exporting data from a database to store in S3, and also how to access the Honeycode API.
但是,我确实希望将其与我们现有的系统结合起来,允许非开发人员创建需要的数据的应用程序。 在最后的沼泽帖子中,我们研究了如何从数据库中导出数据以存储在S3中 ,以及如何访问Honeycode API 。
Now we will bring this all together into one pipeline!
现在,我们将所有这些整合到一个管道中!
POC (POC)
The aim of this POC is to get users who are created in our existing system, to have them imported into the Honeycode App where a Honeycode user will review them, and we will set some additional attribute data within Honeycode. A simple approve/deny review system.
此POC的目的是让在我们现有系统中创建的用户,将其导入Honeycode应用程序中,Honeycode用户将对其进行审查,并在Honeycode中设置一些其他属性数据。 一个简单的批准/拒绝审核系统。
建筑 (Architecture)
API (API)
We will start off with our existing application in the form of API Gateway, a Lambda, and a Database. This will simply take some JSON input and map it to our database table, won’t really go into it, but wanted to provide a more end to end flow.
我们将从API网关,Lambda和数据库形式的现有应用程序开始。 这将只需要一些JSON输入并将其映射到我们的数据库表,就不会真正使用它,而是希望提供更多的端到端流程。
数据库 (Database)
Sticking with a very simple table here, but it really doesn’t matter. The magic is all centered around our database trigger which will kick off our query. We would actually want to add our trigger to all the tables we want to capture an event on. For this test, I’m going to use the following SQL to populate my CSV:
在这里只保留一个非常简单的表,但这并不重要。 魔术全部集中在数据库触发器上,它将触发我们的查询。 我们实际上希望将触发器添加到要捕获事件的所有表上。 对于此测试,我将使用以下SQL填充CSV:
SELECT
st.id,
st.name,
st.email,
CASE
WHEN st.email = 'boss@gizmo.codes' THEN 'Boss'
ELSE 'Pleb'
END AS "status"
FROM
sample_table st
管道 (Pipeline)
Our database trigger will generate the CSV file and upload it to S3. We will utilize the S3 Event Notification feature to call our honeycode lambda. This lambda will be responsible for reading the CSV file off S3, formatting the data, and sending it to our Honeycode table… all the heavy lifting!
我们的数据库触发器将生成CSV文件并将其上传到S3。 我们将利用S3事件通知功能来调用我们的honeycode lambda。 这个lambda负责从S3读取CSV文件,格式化数据并将其发送到我们的Honeycode表中……所有繁重的工作!
蜜码 (Honeycode)
The end goal! Within Honeycode we will create an application, build several tables, link those tables to screens.. and see the data sync in real time! The only real design consideration here is to treat the table you are syncing with as if external — don’t build any filters etc on to the table, don’t update it via the UI. Use it for look ups and save data into other Honeycode tables. There are other projects out there to export Workbook data though if you want that type of functionality!
最终目标! 在Honeycode中,我们将创建一个应用程序,构建多个表,将这些表链接到屏幕..并实时查看数据同步! 此处唯一真正的设计考虑因素是将要与之同步的表视为外部表-不要在表上构建任何过滤器等,也不要通过UI更新它。 使用它进行查找并将数据保存到其他Honeycode表中。 还有其他项目可以导出Workbook数据,但是如果您需要这种功能的话!
步骤1 (Step One)
Ugh, since I can’t provide a way to create this workbook, the next LARGE chunk of this post will be on building up the majority of it!
gh,由于我无法提供创建此工作簿的方法,因此本文的下一个大块内容将建立在大部分内容上!
蜜码 (Honeycode)
Lets start at the end and get our Honeycode application up and running! This isn’t meant as a tutorial for building a Honeycode application as I’ve been pretty rough in shoehorning this application into the POC :)
让我们从最后开始,启动并运行我们的Honeycode应用程序! 这并不意味着要作为构建Honeycode应用程序的教程,因为我在将这个应用程序引入POC时一直很粗鲁:)
Lets create our Workbook to start off:
让我们开始创建工作簿:
This will drop you into an Untitled workbook, and present you with your first table called Table1! Honeycode’s UI is pretty straightforward, the navigation consists of the three menu items on the left horizontal bar:
这将使您进入“无标题”工作簿,并向您展示第一个表Table1! Honeycode的用户界面非常简单,导航由左侧水平栏中的三个菜单项组成:
- Tables 桌子
- Builder 建造者
- Automations 自动化技术
We won’t even touch Automations for this pipeline!
我们甚至不会为该管道涉及自动化!
蜜码表 (Honeycode Tables)
We will build the following table structure:
我们将构建以下表结构:
Lets dive into each table quickly so!
让我们Swift潜入每张桌子!
用户数 (Users)
The Users
table is what we will be writing to from the pipeline, so we wont have it linking out to anything. We don't want Honeycode writing to it etc, as the data is going to be changing.
Users
表是我们将要从管道写入的表,因此我们不会将其链接到任何内容。 我们不希望Honeycode对其进行写操作,因为数据将不断变化。
Lets take Table1
and rename it Users
and provide the following columns to it:
让我们使用Table1
并将其重命名为Users
并为其提供以下各列:
- ID ID
- Name 名称
- Email 电子邮件
- Role 角色
We want to keep this in-sync with the query we will later trigger.
我们希望与以后将触发的查询保持同步。
Lets put in some dummy data right now to help us with the Honeycode App, and delete the other rows:
现在让我们输入一些虚拟数据来帮助我们使用Honeycode App,并删除其他行:
审查状态 (Review Status)
We will now track the status of the reviews, and use the status to filter the results in the App so we can choose to see only the non-reviewed rows.
现在,我们将跟踪评论的状态,并使用该状态在App中过滤结果,以便我们可以选择仅查看未评论的行。
Create a new blank table:
创建一个新的空白表:
and lets name this Review_Status
and provide the following columns:
并命名为Review_Status
并提供以下列:
* Status* Reviews
*状态*评论
Lets enter the following data
让我们输入以下数据
Status = PendingReviews = '=FilterDiff(Users,Filter(Users,"Users[ID]=Reviewed[User ID] AND (Reviewed[Status]=""Approved"" OR Reviewed[Status]=""Denied"")"))'
And
和
Status = ReviewedReviews = '
Delete the extra column and row :)
删除多余的列和行:)
These formulas will initial throw an exception, but we will fix that in the next step.
这些公式最初会引发异常,但是我们将在下一步中修复该异常。
已审核 (Reviewed)
Now to start connecting to the Users
table, and save meta-data about the users to a Honeycode controlled table.
现在开始连接到Users
表,并将有关用户的元数据保存到Honeycode控制的表中。
Lets create another new table and name it Reviewed
and provide the following two columns:
让我们创建另一个新表并将其命名为“已Reviewed
并提供以下两列:
- User ID 用户身份
- Status 状态
We won’t put any data in this table, simply delete the additional column and the empty rows:
我们不会在此表中放置任何数据,只需删除其他列和空行:
And now that we have this table, you can jump back to Review_Status
to see that it is working and showing our test Users
data as pending!
现在我们有了此表,您可以跳回到Review_Status
以查看它是否正在运行,并将我们的测试Users
数据显示为待处理!
Our final table, lets add some additional meta data like, who approved the user and maybe allow them to set an optional note!
我们的最终表允许添加一些其他元数据,例如,谁批准了用户,还可能允许他们设置可选注释!
Create a table called Reviewer_Comments
and set the following columns:
创建一个名为Reviewer_Comments
的表并设置以下列:
- Review Date 审核日期
- Reviewer 审稿人
- User ID 用户身份
- Comment 评论
Delete the empty rows, and finally we wil want to format both Review Date
and Reviewer
.
删除空行,最后我们将要同时设置Review Date
和Reviewer
格式。
Review Date
审核日期
If you select the Column by A
and select Format...
:
如果您选择A
列,然后选择Format...
:
We want to set the Column Format
to be Date & Time
and the Column Formula
to be =NOW()
, click Apply:
我们要将“ Column Format
设置为“ Date & Time
,将“ Column Formula
设置为=NOW()
,单击“应用”:
Reviewer
审稿人
Within Honeycode, the users who will use the web app are known as Contacts. We will configure the column to be a type Contact
so that we will get the logged in users details.
在Honeycode中,将使用Web应用程序的用户称为Contacts 。 我们将列配置为Contact
类型,以便获得登录用户的详细信息。
Similar to Review Date
, select the column to format and this time set Column Format
to be Contact
and leave the Column Formula
blank:
与“ Review Date
类似,选择要设置格式的列,这次将“ Column Format
设置为“ Contact
并将“ Column Formula
保留为空白:
Honeycode应用 (Honeycode App)
Lets now build out our UI! Keeping this straight forward, we will only have two screens — a main dashboard screen, and a details sceen!
现在让我们构建我们的UI! 保持直截了当,我们只有两个屏幕-一个主仪表板屏幕和一个详细信息屏幕!
Select the Builder option from the left menu and click Build your own
:
从左侧菜单中选择“生成器”选项,然后单击“ Build your own
:
仪表板 (Dashboard)
Lets start from the + Add objects
in the bottom left:
让我们从左下方的+ Add objects
开始:
First add a Button
and then also select Column
list. For the list, lets take the defaults, while selecting Add a detail screen
:
首先添加一个Button
,然后选择Column
列表。 对于列表,请选择默认值,然后选择Add a detail screen
:
Buttons, all the Buttons
按钮,所有按钮
Lets just focus in on our one lonely button… Lets shring it a bit and duplicate it so that we have FOUR buttons, name two of them Pending
and two Reviewed
:
让我们只关注一个孤独的按钮……让我们对其进行一点点复制,然后复制它,以便我们有四个按钮,将其中两个命名为Pending
,将两个命名为Reviewed
:
These buttons will control our list, allowing us to filter to Pending users or Reviewed users driven mainly thanks to our Review_Status
table.
这些按钮将控制我们的列表,主要是由于使用Review_Status
表,因此我们可以筛选出“待处理用户”或“已审核用户”。
We want two buttons for each action — while the table is set to pending, we do not want the pending button to do anything. So one button will simply sit there, looking all nice. When the table is showing already reviewed though, we then want the “action” pending button to appear so that it switches up the list when clicked.
我们希望每个操作都有两个按钮-当表设置为待处理时,我们不希望待处理按钮做任何事情。 因此,一个按钮将只是坐在那里,看起来很不错。 当表格显示已审核时,我们希望显示“操作”待处理按钮,以便在单击时切换列表。
To achieve this, we will need some variables…
为此,我们将需要一些变量...
Variables
变数
To allow us to control the list, we will need two variables.
为了允许我们控制列表,我们将需要两个变量。
One variable, the CurrentFilter
, will determine WHICH button is showing - the one that performs an action, or just sits there? Another variable, UsersFilter
, will actual contain the rows we want displayed.
一个变量CurrentFilter
,将确定显示的是哪个按钮-执行一个动作还是只是坐在那里? 另一个变量UsersFilter
将实际包含我们要显示的行。
Current Filter
电流滤波器
From + Add objects
click Data Cell
- change the name to CurrentFilter
, switch the type to Variable
, and set the inital value to Pending
. Under the Display tab, change Visibility to =FALSE
:
在+ Add objects
单击Data Cell
-将名称更改为CurrentFilter
,将类型更改为Variable
,并将初始值设置为Pending
。 在显示标签下,将可见性更改为=FALSE
:
Users Filter
用户过滤
We will default our list to show the pending users on load.
我们将默认使用列表来显示正在加载的未决用户。
Again we want a data cell so from + Add objects
click Data Cell
- change the name to UsesFilter
, switch the type to Variable
, and set the initial value to a formula. This will be: =FindRow(Review_Status,"Review_Status[Status]=%","Pending")
. Lets also set the visibility to False under the Display tab:
同样,我们需要一个数据单元,因此从+ Add objects
单击Data Cell
-将名称更改为UsesFilter
,将类型切换为Variable
,并将初始值设置为公式。 这将是: =FindRow(Review_Status,"Review_Status[Status]=%","Pending")
。 还可以在“显示”选项卡下将可见性设置为“假”:
Connecting Buttons to Variables
将按钮连接到变量
If we select View App in the top right, we will see a pretty ugly UI, with our four buttons:
如果我们选择右上角的View App,我们将看到一个非常丑陋的UI,其中包含四个按钮:
So lets reduce the cluter and implement the button logic. For each of the buttons, we will update the Visibility formula on the Display Tab.
因此让我们减少麻烦并实现按钮逻辑。 对于每个按钮,我们将更新“显示”选项卡上的“可见性”公式。
Update the top Pending
button to: =IF($[CurrentFilter]="Pending", TRUE, FALSE)
Update the bottom Pending
button to: =IF($[CurrentFilter]<>"Pending", TRUE, FALSE)
Update the top Reviewed
button to: =IF($[CurrentFilter]="Reviewed", TRUE, FALSE)
Update the bottom Reviewed
button to: =IF($[CurrentFilter]<>"Reviewed", TRUE, FALSE)
将顶部的Pending
按钮更新为: =IF($[CurrentFilter]="Pending", TRUE, FALSE)
将底部的Pending
按钮更新为: =IF($[CurrentFilter]<>"Pending", TRUE, FALSE)
更新顶部Reviewed
按钮改为: =IF($[CurrentFilter]="Reviewed", TRUE, FALSE)
将底部Reviewed
按钮更新为: =IF($[CurrentFilter]<>"Reviewed", TRUE, FALSE)
i.e.
即
And our App should now only show two buttons:
现在我们的应用程序应该只显示两个按钮:
Button Actions
按钮动作
Lets give our buttons something to do now! You’ll have noticed that the button dialog has three options:
让我们给按钮做些事情吧! 您会注意到按钮对话框具有三个选项:
We will give our buttons some quick actions!
我们将为按钮提供一些快速操作!
Pending Action Button
等待操作按钮
Select the bottom Pending
button and go to the Action tab. Under Quick Actions, you want to select Update current screen
. You'll be prompted to Set a variable
, and choose the CurrentFilter
First. We want to populate the Take data from
formula with simply: ="Pending"
.
选择底部的“ Pending
按钮,然后转到“操作”选项卡。 在快速操作下,您要选择Update current screen
。 系统将提示您Set a variable
,然后首先选择CurrentFilter
。 我们只想使用="Pending"
填充公式中的Take data from
。
Reviewed Action Button
复习动作按钮
Select the bottom Reviewed
button and go to the Action tab. Under Quick Actions, you want to select Update current screen
. You'll be prompted to Set a variable
, and choose the CurrentFilter
First. We want to populate the Take data from
formula with simply: ="Reviewed"
.
选择底部的“已Reviewed
按钮,然后转到“操作”选项卡。 在快速操作下,您要选择Update current screen
。 系统将提示您Set a variable
,然后首先选择CurrentFilter
。 我们只想用="Reviewed"
填充“ Take data from
公式中Take data from
="Reviewed"
。
Connecting Buttons To The Table
将按钮连接到桌子
We now have the buttons performing actions, but we don’t see anything changing in our app! This is because the table is still sourcing data directly from the Users
table. We want to update it to pull actually from our variable!
现在,我们可以使用按钮来执行操作,但是我们的应用程序没有任何变化! 这是因为该表仍在直接从Users
表中获取数据。 我们想要对其进行更新以实际从变量中提取!
This is the nice and easy part, select the List from the UI and on the Data tab, lets change the source from =Users
to be =$[UsersFilter][Reviews]
这是很简单的部分,从UI中选择“列表”,然后在“数据”选项卡上,将源从=Users
更改为=$[UsersFilter][Reviews]
Switching back to our App view, we can see the buttons working correctly:
切换回我们的应用程序视图,我们可以看到按钮正常工作:
详细画面 (Detail Screen)
So our detail screen will save some data into our Honeycode tables, set the comment and the audit data — who did it and when.
因此,我们的详细信息屏幕会将一些数据保存到我们的Honeycode表中,设置注释和审核数据-谁以及何时进行。
Action Section
行动科
Approve Automation
批准自动化
Lets take the Approve button first, select the Action
tab and this time we want to Create an automation
as we will be saving data to the tables!
让我们先单击Action
批准”按钮,选择“ Action
选项卡,这一次我们要Create an automation
因为我们将数据保存到表中!
We want three actions in total:
我们总共需要三个动作:
Add a row to
Reviewed
在已
Reviewed
添加一行Add a row to
Reviewer_Comments
在
Reviewer_Comments
添加一行- Redirect back to the Dashboard 重定向回仪表板
Adding a Row to Reviewed
在评论中添加行
Click + Add actions
and select Add a row
. Choose our Reviewed
table from the drop down. Remember, we only have two columns on this table: User ID and Status. The screen currently is showing the User ID, and we can pull that into our "Take data from" formula with =$[InputRow][ID]
and then set the column to be =[User ID]
.
点击+ Add actions
然后选择Add a row
。 从下拉列表中选择我们的已Reviewed
表。 请记住,此表上只有两列:用户ID和状态。 当前屏幕上显示的是用户ID,我们可以使用=$[InputRow][ID]
将其拖入“从中获取数据”公式中,然后将列设置为=[User ID]
。
Since we have two columns to populate, lets select + Add another
and popuate the options with:
由于我们要填充两列,因此请选择+ Add another
列,然后使用以下命令填充选项:
Take Date From: "=Approved"
Write To: "=[Status]"
Adding a Row to Reviewer Comments
在审阅者评论中添加一行
Once again, click + Add another
and select Add a row
. Choose our Reviewer_Comments
table from the drop down. Populate the following columns:
再次点击+ Add another
然后选择Add a row
。 从下拉列表中选择我们的Reviewer_Comments
表。 填充以下列:
Take Date From: "=NOW()"
Write To: "=[Review Date]"
And also
并且
Take Date From: "=$[SYS_USER]"
Write To: "=[Reviewer]"
Finally:
最后:
Take Date From: "=$[InputRow][ID]"
Write To: "=[User ID]"
Redirect
重新导向
Our final action, click + Add actions
and select Navigate
. Select Screen
from the dropdown. And thats our action button complete!
我们的最终操作,点击+ Add actions
然后选择Navigate
。 从下拉菜单中选择Screen
。 这就是我们的操作按钮完成了!
第二步 (Step Two)
Yes.. finally on step 2 — thankfully the rest is more or less automatically deployable!
是的..终于进入第2步了-幸好其余的或多或少都可以自动部署!
We will want to setup our “existing” infrastructure — an API hitting a database. We then will have a lambda that keeps out Honeycode Users
table in sync with a CSV file in S3.
我们将要设置我们的“现有”基础结构-API击中数据库。 然后,我们将得到一个lambda值,该值可以使Honeycode Users
表与S3中的CSV文件保持同步。
变形 (Terrform)
You can clone the github repo. There are several variables that we will want to set before executing the terraform script, namely, we need:
您可以克隆github repo 。 在执行terraform脚本之前,我们需要设置几个变量,即,我们需要:
- Our Honeycode login 我们的Honeycode登录
- Our Honeycode password 我们的Honeycode密码
- The Honeycode Workbook UUID Honeycode工作簿UUID
The Honeycode Table UUID for the
Users
tableUsers
表的Honeycode表UUID
Lets retrieve the Table UUID!
让我们检索表UUID!
用户UUID (Users UUID)
I wrote a little script to help us, and go into more details on it in another blog post if you’re interested in it.
我写了一个小脚本来帮助我们,如果您对此感兴趣的话,可以在另一篇博客文章中进一步了解它。
Lets kick it off though:
让我们开始吧:
$ cd aws-rds-to-honeycode/query-honeycode
$ npm install
$ node index.js workbooks -u USERNAME -p "PASSWORD"
Workbook Name Workbook UUID
------------- -------------
Untitled => arn:aws:sheets:us-west-2:122162422134:workbook:28e53ee7-adcd-4c40-b243-ea289eb954e2
Now taking the Workbook UUID, we can get the Tables UUID:
现在,使用工作簿UUID,我们可以获取表UUID:
$ node index.js tables -u USERNAME -p "PASSWORD" -w "arn:aws:sheets:us-west-2:122162422134:workbook:28e53ee7-adcd-4c40-b243-ea289eb954e2"
Table NameTable UUID
------------- -------------
Users => b2cdc524-4085-352f-86b9-c7c956eb9da2
Review_Status => 9c83ce89-6172-4968-a4e6-971c1cf121bf
Reviewed => 8d65ae15-1d35-4633-a339-171fa6592ea0
Reviewer_Comments => 9859cdd7-d556-4ad6-9d60-b64dd1f06275
We now have the Users
UUID: b2cdc524-4085-352f-86b9-c7c956eb9da2
现在,我们有Users
UUID:b2cdc524-4085-352f-86b9-c7c956eb9da2
工作簿UUID (Workbook UUID)
Very similar to before, just run the script to retrieve our Workbook UUID:
与之前非常相似,只需运行脚本来检索我们的工作簿UUID:
$ node index.js workbooks-uuid -u USERNAME -p "PASSWORD"
Workbook Name Workbook UUID
------------- -------------
Untitled => 28e53ee7-adcd-4c40-b243-ea289eb954e2
地形变量文件 (Terraform Variable File)
We will want to create a new file in the terraform
folder called terraform.tfvars
which you want to populate with the following:
我们将要在terraform
文件夹中创建一个名为terraform.tfvars
的新文件,并使用以下内容填充该文件:
honeycode_login = "USERNAME"
honeycode_password = "PASSWORD"
honeycode_workbook = "WORKBOOK UUID"
honeycode_sheet = "TABLE UUID"
Last two steps before we deploy, we need to prep our application dependencies:
在部署之前的最后两个步骤,我们需要准备应用程序依赖项:
$ cd aws-rds-to-honeycode/app
$ npm install
$ cd ../lambda
$ npm install
Finally, lets spin up our environment with:
最后,让我们通过以下方式提升环境:
cd ../terraform
terraform init
terraform apply -auto-approve
This will take a few minutes to complete as we wait for the database cluster to stand up.
当我们等待数据库集群启动时,这将需要几分钟的时间来完成。
We should get the following output:
我们应该得到以下输出:
Great, then we are ready to move on :D
太好了,那么我们就可以继续:D
数据库 (Database)
We need to grant the database permission to connect to our S3 bucket, we can do this with the following script:
我们需要授予数据库连接到S3存储桶的权限,我们可以使用以下脚本进行操作:
cd aws-rds-to-honeycode/script
./add_role_to_db_cluster.sh
This will take a few minutes to apply, but we can press on! Connect to the database using the URL and credentials you received from the terraform output. See PostgreSQL Trigger To S3 if you are not sure how to connect to the Database.
这需要几分钟的时间,但我们可以继续! 使用从terraform输出中收到的URL和凭据连接到数据库。 如果不确定如何连接到数据库,请参见PostgreSQL触发器到S3 。
Once you’re connected, we will want to execute the following SQL statements.
建立连接后,我们将要执行以下SQL语句。
CREATE EXTENSION IF NOT EXISTS aws_s3 CASCADE;CREATE TABLE sample_table (id SERIAL PRIMARY KEY, name varchar, email varchar);
数据库触发器 (Database Trigger)
Now for the black magic, refer back to the terraform output, particularly database_bucket_id
. We want to update the trigger code to match this:
现在有关黑魔法,请参考terraform输出,尤其是database_bucket_id
。 我们要更新触发代码以使其与此匹配:
CREATE OR REPLACE FUNCTION export_to_s3()
RETURNS TRIGGER
AS $export_to_s3$
BEGIN
PERFORM aws_s3.query_export_to_s3(
'SELECT st.id, st.name, st.email, CASE WHEN st.email = ''boss@gizmo.codes'' THEN ''Boss'' ELSE ''Pleb'' END manager_check FROM sample_table st',
aws_commons.create_s3_uri(
'S3_BUCKET_NAME',
'test.csv',
'us-east-1'),
options :='format csv, delimiter $$,$$'
);
RETURN NEW;
END;
$export_to_s3$ LANGUAGE plpgsql;CREATE TRIGGER sample_table_trg
AFTER INSERT OR DELETE OR UPDATE OR TRUNCATE
ON sample_table
FOR EACH STATEMENT
EXECUTE PROCEDURE export_to_s3();
Excellent! We are done!
优秀的! 我们完了!
第三步 (Step Three)
Lets test this bad boy out!
让我们测试一下这个坏男孩!
Refer back to the terraform output again, and find the api_gateway_url
. We can make a JSON post call to this and watch it propagate through the system.
再次参考terraform输出,并找到api_gateway_url
。 我们可以对此进行JSON post调用,并观察它在系统中的传播。
I’ll first return to Honeycode and delete the test data we had in Users
, Reviewed
, and Reviewer_Comments
.
我将首先返回Honeycode并删除我们在Users
, Reviewed
和Reviewer_Comments
拥有的测试数据。
Then we can call:
然后我们可以调用:
$ curl --header "Content-Type: application/json" --request POST --data '{"name": "JD", "email": "pleb@gizmo.codes"}' API_URL/honeycode-sync
We should see our user appear — we can add a few more.
我们应该看到用户出现-我们可以添加更多。
$ curl --header "Content-Type: application/json" --request POST --data '{"name": "Gizmo", "email": "boss@gizmo.codes"}' API_URL/honeycode-sync $ curl --header "Content-Type: application/json" --request POST --data '{"name": "Swayze", "email": "boss@gizmo.codes"}' API_URL/honeycode-sync
And we are done! Our pipeline is compelete with updates taking around 13 seconds from calling the Application, saving to the database, updating S3, pushing the data from S3 to Joneycode, and finally displaying in the Honeycode App.
我们完成了! 从调用应用程序,保存到数据库,更新S3,将数据从S3推送到Joneycode并最终显示在Honeycode App中,大约需要13秒钟的更新来完成我们的管道。
第四步 (Step Four)
Finally, make sure to tear this all down when you’re finished. You don’t want public databases left out there and AWS charges on your bill…
最后,请确保完成后将所有内容拆解。 您不希望遗漏公共数据库,也不想在账单上收取AWS费用……
$ cd aws-rds-to-honeycode/terraform
$ terraform destroy -auto-accept
Originally published at https://gizmo.codes.
最初发布在 https://gizmo.codes上 。
翻译自: https://medium.com/swlh/postgresql-to-honeycode-pipeline-ffa43081116f
poco