This needs bqto Pro.
A first stack
P with your project ID, and orders and cache with your instances.
- The first line connects to the Cloud SQL instance
ordersand saves the session as the profiledb. Ctrl-C ends it. - The second line saves the Redis instance
cacheas a profile, without connecting. bqto connect dbopens one profile by name.- The next two lines group both profiles in the stack
work, and open them in one session, through one bastion. - The last two lines rename the profile
cachetosessions, and the stackworktocheckout. A stack that lists a renamed profile lists the new name in the same place.
bqto profile -h and bqto stack -h show the help, with examples.
Profiles
A profile stores the identity of a target: the project, the service, and the instance. It never stores the private IP of the service. bqto looks up the IP again on every connect, because PSC endpoints change, and an old IP fails much later in a confusing way.bqto profile createsaves a profile without connecting.--saveon abqto connectsaves the session that you are already running.bqto connect --service NAMEstays as it was: one service, nothing saved.bqto profile list --output jsonlists the saved profiles as JSON.bqto profile rm NAMEremoves a profile.bqto profile rename OLD NEWrenames a profile. In the same write, bqto also updates every stack that lists it.bqto stack rename OLD NEWrenames a stack.
Names that are taken
If a name is already saved, bqto refuses it before it creates anything, with exit code 2. To overwrite it, add--replace to bqto profile create, bqto stack create, or
bqto connect --save. bqto then prints the profile or stack that it replaced.
Where profiles live
bqto stores profiles and stacks inconfig.toml, in the bqto config folder:
To remove all profiles, delete the file.
Several services at once
An application talks to its database, its cache, and its queue. Three sessions mean three bastions and three terminals. Profiles and stacks put them in one session:Rules for a stack
- Every service must be on the same VPC, because a session is one bastion. If two services are on different VPCs, bqto says which two before it creates anything.
- A stack can have services in different regions. bqto warns about it. bqto creates the bastion in the region of the first service in the stack. It also asks that region for everything that the session needs from a subnet.
- This matters for Cloud Run, because Cloud Run needs Private Google Access on the subnet of the bastion. Put first a service whose region has Private Google Access, or turn it on as Cloud Run shows.
--service,--instance,--endpoint,-p,--web,--save, and-- CMDdescribe a single target. They do not apply to a stack, which takes them from each profile.- bqto checks every profile in the stack before it creates anything.
duration, spot,
zone, subnet, machine_type, image, and web. bqto warns when a later profile sets them
differently.
bqto creates the bastion in the project of the first profile. It looks up the service of each
profile in its own project, so a stack can span projects on a Shared VPC. bqto checks Private
Google Access when any profile is Cloud Run.
In CI and in the Mac app
- In GitHub Actions, bqto-action reads profiles and stacks from a
config.tomlin your repository. See GitHub Actions. - The Mac app lists, creates, edits, and opens your profiles and stacks.