Connect your tools
Point SDKs, the cloud CLIs, Terraform and the CDK at pogi.
pogi works with the AWS, Google Cloud and Azure tools you already use. Point them at it with the steps below.
Before you start, run pogi start. The commands below find pogi at http://localhost:7644. If it runs on another port, pass --endpoint to client commands or set POGI_ENDPOINT.
SDKs and CLIs
pogi env prints the settings that point these tools at pogi: the AWS CLI and SDKs, gcloud and the Google Cloud client libraries, and the Azure Storage, Cosmos DB and Key Vault clients. Terraform has its own file, covered under Terraform.
Load the settings into your shell. Pick the tab for your shell:
eval "$(pogi env)"| Shell | Output |
|---|---|
sh | export NAME="value" lines. |
fish | set -gx NAME "value"; lines. |
pwsh | $env:NAME="value" lines. Invoke-Expression runs them in your session. |
dotenv | NAME=value lines, for tools that read a .env file. |
Then use your tools as usual. The sections below say what pogi env sets for each cloud.
AWS
pogi env sets AWS_ENDPOINT_URL, AWS_ and AWS_ (both test), AWS_ and AWS_REGION. Every current AWS SDK and the AWS CLI read AWS_ENDPOINT_URL, so your code does not change. This Go program lists buckets with no pogi-specific code:
package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx) // reads AWS_ENDPOINT_URL and the test credentials
if err != nil {
panic(err)
}
out, err := s3.NewFromConfig(cfg).ListBuckets(ctx, &s3.ListBucketsInput{})
if err != nil {
panic(err)
}
for _, b := range out.Buckets {
fmt.Println(*b.Name)
}
}With a bucket called demo, it prints:
demoTo run the AWS CLI without loading the variables, use pogi aws. It needs the AWS CLI installed.
pogi aws s3 lsGoogle Cloud
pogi env sets STORAGE_, PUBSUB_, FIRESTORE_, DATASTORE_, SPANNER_, BIGTABLE_ and, for the Firebase Admin SDK, FIREBASE_. The client libraries read them. It also sets the gcloud settings (CLOUDSDK_, project pogi), so gcloud talks to pogi.
Some Google APIs have the same paths as others. Memorystore and Filestore both use /v1/, for example. pogi tells them apart by a path prefix: the API's name. For these APIs, include the prefix in the endpoint you give a client library:
redis.NewService(ctx, option.WithEndpoint("http://localhost:7644/redis/"), option.WithoutAuthentication())pogi env and pogi tf --cloud gcp already add the prefixes for gcloud and Terraform. A gRPC client needs no prefix: localhost:7644 is enough. The coverage page shows each API's path.
Azure
pogi env sets AZURE_ (Azurite ports 10000 to 10002). It also sets COSMOS_ENDPOINT, COSMOS_KEY and AZURE_ for the HTTPS port, plus the managed identity and Microsoft Entra ID settings (IDENTITY_, AZURE_ and ARM_). HTTPS services use pogi's own certificate authority (CA). Run pogi cert to see where it is and how to trust it.
Azure CLI
The Azure CLI (az) signs in to pogi with a service principal (an app identity) once you register pogi as a cloud. pogi env sets AZURE_, so az login doesn't ask Microsoft's sign-in service about pogi's address first. az also has to trust pogi's CA through REQUESTS_. pogi env leaves that one out, because it replaces the trusted list of every Python tool that reads it. Set it only in the shell where you run az:
eval "$(pogi env)"
export REQUESTS_CA_BUNDLE="$HOME/.pogi/certs/ca.pem" # pogi's CA; `pogi cert` prints its path
export AZURE_CONFIG_DIR="$HOME/.pogi/azure" # keeps your own ~/.azure as it is
az cloud show -n pogi > /dev/null 2>&1 || az cloud register -n pogi --endpoint-resource-manager https://localhost:7644/
az cloud set -n pogi --only-show-errors
az login --service-principal -u 00000000-0000-0000-0000-000000000001 -p secret \
--tenant 00000000-0000-0000-0000-000000000000 --output noneYou can run the block again: it registers the cloud only the first time.
Any client ID and secret work. The tenant is pogi's own. After that, Azure Resource Manager (ARM) commands such as az group create, az aks create and az aks get-credentials talk to pogi. Your own ~/.azure doesn't change, so a new shell talks to real Azure again. pogi doesn't serve the browser sign-in, so plain az login doesn't work.
S3 with bucket names in the host
Some code needs the bucket in the host name, as in <bucket>.s3.aws.localhost.
-
Start pogi with a host name:
pogi start --hostname aws.localhost -
Print matching settings:
pogi env --hostname aws.localhostOutput export AWS_ENDPOINT_URL="http://aws.localhost:7644" … export AWS_ENDPOINT_URL_S3="http://s3.aws.localhost:7644" …To load them, run
eval "$(pogi env --hostname aws.localhost)".
pogi doctor tells you whether *.localhost names resolve on your machine.
Terraform
pogi tf prints a Terraform provider block (the settings that tell Terraform which cloud to call) with every endpoint pointed at pogi.
-
Write it next to your own files. Terraform loads
*_override.tffiles over your own settings, so your configuration stays as it is:pogi tf > pogi_override.tfThe file starts like this:
pogi_override.tf # Generated by "pogi tf": point the AWS provider at pogi. provider "aws" { region = "us-east-1" access_key = "test" secret_key = "test" skip_credentials_validation = true skip_metadata_api_check = true skip_requesting_account_id = true s3_use_path_style = true -
Run Terraform:
terraform init terraform apply
For the other clouds:
pogi tf --cloud gcp > pogi_override.tf
pogi tf --cloud azure > pogi_override.tf| Flag | Meaning |
|---|---|
--cloud | aws (default), gcp or azure. |
--region | Region. Default us-east-1 for AWS, us-central1 for Google Cloud. |
--project | Google Cloud project. Default pogi. |
--endpoint | pogi's address. |
--metadata-host | host:port for the azurerm provider. |
The azurerm provider needs HTTPS. The Azure output starts with comments that show how to run Terraform in a container that trusts pogi's CA.
CDK
The AWS CDK works without a wrapper, and custom resources work, including the CDK provider framework.
-
Set
AWS_ENDPOINT_URLand the test credentials in your shell:eval "$(pogi env)" -
Run
pogi lambda-sdksonce. It gives native Lambda functions the AWS SDKs that real Lambda runtimes include: the JavaScript v3 SDK fromnpmandboto3frompip, in pogi's data folder. You need Node.js and Python on your machine.pogi lambda-sdks -
Bootstrap and deploy:
cdk bootstrap cdk deploy
Go tests
-
Start pogi inside the test, and set the environment for the code under test:
srv := pogi.Start(t) // in-process on a random port, cleaned up with the test srv.Setenv(t) // AWS_ENDPOINT_URL, *_EMULATOR_HOST, Azure settings for code under test -
Build your client as usual. It now points at pogi:
cfg, _ := config.LoadDefaultConfig(ctx)
pogi.Start(t) runs everything inside the test process, with no container. With pogi.Start(t, cfg) and cfg, _ := pogi.LoadConfig("testdata/pogi.yaml"), it also creates what the pogi.yaml file lists.
With Testcontainers, run the ghcr.io/ image, expose port 7644, and wait for the log line Ready. or for /_localstack/.
Check that it works
-
Check that pogi is up:
pogi status -
Follow every call your tools make:
pogi logs -f
If a call does not show up, your tool is not using the endpoint from pogi env. See Troubleshoot.