Pantheon Community

Using Terminus as a Yggdrasil client library from an AWS lambda function

[quote]
View in #terminus on Slack

![bweaver] @bweaver: i don’t suppose there’s any available documentation on the PHP class hierarchy that makes up terminus…? because it’s not something that’s intended for customers to dig into directly…

i know i can look at the actual php code directly… and i did find the plugin development article and the example plugin…

i’m trying to develop a PHP application that invokes terminus commands directly via php… not via system/command-line commands… (AWS lambda… i’m not sure those things are even available considering that we’re “serverless” so there’s no server?)

i’m not sure how much plugin development tracks with what i’m trying to do, as i imagine plugins are designed to be invoked by terminus and i’m trying to invoke terminus with my thing
i did already find this: https://github.com/pantheon-systems/bref-terminus
and used it as a baseline to create my own lambda function which is successfully getting a site list… but now it looks like i’ll be digging into terminus’s code directly to figure out how to invoke other things…

i realize that terminus’s implementation can be changed without warning, as it’s conceptually a bunch of “private methods”

GitHub: pantheon-systems/bref-terminus

![Doug] @Doug: terminus is built off of Symphony Console, so I believe that you could follow something like what’s laid out here
https://symfony.com/doc/current/console/calling_commands.html

How to Call Other Commands (Symfony Docs)

![greg.1.anderson] @greg.1.anderson: We actually have a Terminus api for AWS lambdas at Pantheon; I just don’t know that we have the time to give it to you. :disappointed:
bref-terminus became part of a monorepo & was finished there.
Maybe I could dump some raw code on you and you could make a PR to re-integrate it.

![bweaver] @bweaver: re-integrate into that bref-terminus project? maybe!

![uberhacker] @uberhacker: raw code dumps sound dangerous. :exploding_head:

![greg.1.anderson] @greg.1.anderson: Yeah, I would have to take it out of its protective lead enclosure. Radiation gear would be prudent.

![bweaver] @bweaver: i’m certainly open to the idea :slightly_smiling_face:

![greg.1.anderson] @greg.1.anderson: OK I am just going to make a PR on pantheon-systems/bref-terminus with just the terminus-bref stuff. I make no promise that it will work standalone without the stuff I’m leaving behind in the monorepo, but it should be most of what you need.

GitHub: pantheon-systems/bref-terminus

@bweaver https://github.com/pantheon-systems/bref-terminus/pull/1

GitHub: Code dump from 6d0b796 2020-12-07 by greg-1-anderson · Pull Request #1 · pantheon-systems/bref-terminus

![bweaver] @bweaver: lol hyooj

![greg.1.anderson] @greg.1.anderson: Someone else wanted this too, I wish I could remember who to @-mention them
@bweaver I force-pushed over my first PR. Please dump what you have and re-pull. Just got rid of some not-very-secret internal identifier

![bweaver] @bweaver: roger that

git checkout master git branch -D terminus-bref-from-autopilot-state-machines git fetch --all

this code is so much more pro than me :laughing:
so this would be a hard fork, right? it’s not feasible to keep it in tandem with what you guys have internally?
in your vision

![greg.1.anderson] @greg.1.anderson: In our vision, Terminus Bref is a hack. We are going to retire it and use internal APIs later. We just threw this together in a week or two to make progress rapidly.
So yes, hard fork, you’d have to maintain it if you use it.
The problem with Terminus Bref is that it authenticates like a customer would, via Terminus tokens. This is not a problem for customer use, but it does pose problems for us internally because we need to use it for multiple customers.
Just wanted to be clear on that – there’s nothing wrong with it for customer use.
It’s also fairly well tested, although it’s not super complete, it only has the Terminus commands we needed.