1
---
2
name: alloydb-basics
3
metadata:
4
version: "1.0.1"
5
category: Databases
6
description: >-
7
Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and
8
integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations.
9
Use when creating, configuring, or administering AlloyDB databases.
10
Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.
11
---
12
13
# AlloyDB Basics
14
15
AlloyDB for PostgreSQL is a managed, PostgreSQL-compatible database service
16
designed for enterprise-grade performance and availability. It utilizes a
17
disaggregated compute and storage architecture to scale resources independently.
18
It also provides AlloyDB AI, a collection of features that includes AI-powered
19
search (vector, hybrid search, and AI functions), natural language capabilities,
20
conversational analytics, and inference features like forecasting and model
21
endpoint management to help developers build AI apps faster.
22
23
## Attribution
24
25
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
26
MUST read [Usage Attribution](references/attribution.md). For commands executed
27
directly in the terminal (never in generated scripts, Terraform, or user code),
28
prefix `gcloud` with
29
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:alloydb-basics)"`
30
and append `agent-skills/1.0 (skill:alloydb-basics)` to `User-Agent` headers.
31
32
## Quick Start
33
34
Before you begin, ensure you have the [Google Cloud SDK installed](https://cloud.google.com/sdk/docs/install) and authenticated (`gcloud auth login`).
35
36
1. **Enable the AlloyDB API:**
37
38
```bash
39
gcloud services enable alloydb.googleapis.com --quiet
40
```
41
42
2. **Create a Cluster:**
43
44
```bash
45
gcloud alloydb clusters create my-cluster --region=us-central1 \
46
--password=my-password --network=my-vpc --quiet
47
```
48
49
*For production environments, always use IAM database authentication instead
50
of passwords. If configuration constraint requires passwords, store them
51
securely using Secret Manager.*
52
53
3. **Create a Primary Instance:**
54
55
```bash
56
gcloud alloydb instances create my-primary --cluster=my-cluster \
57
--region=us-central1 --instance-type=PRIMARY --cpu-count=2 --quiet
58
```
59
60
## Reference Directory
61
62
Read these supplementary files when specific context or detailed steps are
63
required for a task:
64
65
- To understand architecture, regional availability, connectivity (Private IP,
66
Public IP, PSA, PSC), backups, point-in-time recovery, scaling (vertical and
67
horizontal), or Quota management: read
68
[Core Concepts](references/core-concepts.md).
69
- To manage clusters, instances, scaling, or backups via the CLI: read
70
[CLI Usage](references/cli-usage.md).
71
- To configure AlloyDB remote MCP tools: read
72
[MCP Usage](references/mcp-usage.md).
73
- To deploy AlloyDB using Terraform or Kubernetes Config Connector (KCC): read
74
[Infrastructure as Code](references/iac-usage.md).
75
- To configure IAM roles, service usage roles, service agents, database
76
users/privileges, or network security (public IP authorization, Auth Proxy
77
sidecar configuration): read [IAM & Security](references/iam-security.md).
78
79
*If you need product information not found in these references, use the
80
`developer_knowledge:search_documents` tool (see [Developer Knowledge MCP setup](https://developers.google.com/knowledge/mcp) for installation instructions).*
81
82
## Directives for Agents
83
84
Agents MUST adhere to the following directives when answering queries related to
85
AlloyDB:
86
87
- **Provide Multiple Methods:** When explaining how to perform administrative
88
tasks (like backups, scaling, or database user creation), always provide
89
both the Google Cloud Console steps and the `gcloud` CLI commands if both
90
are available in the reference documents.
91
- **Prioritize Private IP:** Recommend Private IP (especially PSC) over Public
92
IP for connections to ensure traffic remains within the Google Cloud network
93
and reduces exposure.
94
- **Require Serverless Connectors:** Verify and state that Serverless VPC
95
Access or Direct VPC Egress is required when connecting from Cloud Run to
96
Private IP.
97
- **Enforce Connectors:** Always direct users to configure the AlloyDB Auth
98
Proxy (running as a sidecar or locally) or language connectors rather than
99
direct TCP connections.
100
- **Block Open Public Access:** If Public IP is configured, warn against and
101
reject designs with `0.0.0.0/0` in Authorized Networks as this exposes the
102
database to the entire internet.
103
- **Default to IAM Database Authentication:** Suggest IAM database
104
authentication and the `alloydbiamuser` database role instead of static
105
database passwords.
106
- **Enforce Least Privilege Connection:** When explaining connection roles,
107
explicitly state that `roles/alloydb.client` should be used to adhere to the
108
principle of least privilege, and warn against using broader roles like
109
`roles/alloydb.admin` for connections.
110
- **Mention All Creation Methods:** When describing how to create IAM database
111
users, explicitly state that they can be created using the Google Cloud
112
Console, the `gcloud` CLI, and the AlloyDB API.
113
- **Explain Private IP Options:** When explaining Private IP connectivity,
114
always explicitly mention and describe both **Private Services Access
115
(PSA)** and **Private Service Connect (PSC)** as the supported methods,
116
recommending PSC for new deployments.
117
- **Compare Direct Connections:** Explicitly explain that direct connections
118
(connecting directly to the private IP without connectors) are possible but
119
discouraged, and compare their security (lack of IAM/mTLS) to secure methods
120
like the AlloyDB Auth Proxy or language connectors.
121
- **Enforce SQL Alone Warning:** When explaining IAM user creation, you MUST
122
explicitly state that "IAM database users cannot be created using standard
123
SQL alone" and must be registered via the control plane first.
124
- **Enforce Roles and Privileges Terminology:** When explaining database
125
object access, you MUST explicitly state that "standard PostgreSQL roles and
126
privileges" apply, using both terms.
127
- **Explain Backup Lifecycle:** When explaining backups, always explicitly
128
state that discrete backups exist independently of the source cluster and
129
remain active even if the source cluster is deleted.
130
- **Recommend Connectors for Public IP:** Explicitly state that secure
131
connection methods (AlloyDB Auth Proxy, Language Connectors) are
132
**especially recommended** for connections over Public IP.
133
- **Mention Autoscaling:** When explaining read pool scaling, always
134
explicitly mention the option of using **read pool autoscaling** and state
135
that it is in **Preview**.
136
137
## Supporting Links
138
139
- [AlloyDB for PostgreSQL Documentation](https://docs.cloud.google.com/alloydb/docs/overview.md.txt)
140
- [AlloyDB Auth Proxy GitHub Repository](https://github.com/GoogleCloudPlatform/alloydb-auth-proxy)
141
- [AlloyDB Java Connector GitHub Repository](https://github.com/GoogleCloudPlatform/alloydb-java-connector)
142
- [AlloyDB Python Connector GitHub Repository](https://github.com/GoogleCloudPlatform/alloydb-python-connector)
143
- [AlloyDB Go Connector GitHub Repository](https://github.com/GoogleCloudPlatform/alloydb-go-connector)
144