akeyless-cloudrun-rta 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. akeyless_cloudrun_rta-0.1.0/.dockerignore +15 -0
  2. akeyless_cloudrun_rta-0.1.0/.env.example +17 -0
  3. akeyless_cloudrun_rta-0.1.0/.github/workflows/ci.yml +48 -0
  4. akeyless_cloudrun_rta-0.1.0/.github/workflows/publish.yml +74 -0
  5. akeyless_cloudrun_rta-0.1.0/.gitignore +33 -0
  6. akeyless_cloudrun_rta-0.1.0/Dockerfile +23 -0
  7. akeyless_cloudrun_rta-0.1.0/LICENSE +19 -0
  8. akeyless_cloudrun_rta-0.1.0/PKG-INFO +105 -0
  9. akeyless_cloudrun_rta-0.1.0/README.md +73 -0
  10. akeyless_cloudrun_rta-0.1.0/SECURITY.md +20 -0
  11. akeyless_cloudrun_rta-0.1.0/deploy/deploy.sh +74 -0
  12. akeyless_cloudrun_rta-0.1.0/deploy/terraform/main.tf +81 -0
  13. akeyless_cloudrun_rta-0.1.0/deploy/terraform/outputs.tf +8 -0
  14. akeyless_cloudrun_rta-0.1.0/deploy/terraform/variables.tf +74 -0
  15. akeyless_cloudrun_rta-0.1.0/docs/AKEYLESS_SETUP.md +62 -0
  16. akeyless_cloudrun_rta-0.1.0/docs/CLOUD_RUN_DEPLOY.md +82 -0
  17. akeyless_cloudrun_rta-0.1.0/docs/RELEASING.md +47 -0
  18. akeyless_cloudrun_rta-0.1.0/examples/adk-agent/embedded_agent/__init__.py +1 -0
  19. akeyless_cloudrun_rta-0.1.0/examples/adk-agent/embedded_agent/agent.py +56 -0
  20. akeyless_cloudrun_rta-0.1.0/examples/adk-agent/mcp_agent/__init__.py +1 -0
  21. akeyless_cloudrun_rta-0.1.0/examples/adk-agent/mcp_agent/agent.py +46 -0
  22. akeyless_cloudrun_rta-0.1.0/examples/adk-agent/requirements.txt +2 -0
  23. akeyless_cloudrun_rta-0.1.0/pyproject.toml +60 -0
  24. akeyless_cloudrun_rta-0.1.0/scripts/release.sh +28 -0
  25. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/__init__.py +13 -0
  26. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/ara.py +262 -0
  27. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/auth.py +134 -0
  28. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/caller.py +65 -0
  29. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/client.py +208 -0
  30. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/config.py +249 -0
  31. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/http_ara.py +225 -0
  32. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/tools/__init__.py +17 -0
  33. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/tools/mcp.py +346 -0
  34. akeyless_cloudrun_rta-0.1.0/src/akeyless_cloudrun_rta/tools/service.py +160 -0
  35. akeyless_cloudrun_rta-0.1.0/tests/test_ara.py +153 -0
  36. akeyless_cloudrun_rta-0.1.0/tests/test_auth.py +107 -0
  37. akeyless_cloudrun_rta-0.1.0/tests/test_caller.py +56 -0
  38. akeyless_cloudrun_rta-0.1.0/tests/test_client.py +234 -0
  39. akeyless_cloudrun_rta-0.1.0/tests/test_cloud_run.py +175 -0
  40. akeyless_cloudrun_rta-0.1.0/tests/test_config.py +76 -0
  41. akeyless_cloudrun_rta-0.1.0/tests/test_mcp_tools.py +249 -0
@@ -0,0 +1,15 @@
1
+ .git
2
+ .github
3
+ .venv
4
+ venv
5
+ .env
6
+ .env.*
7
+ **/__pycache__
8
+ .pytest_cache
9
+ .ruff_cache
10
+ tests
11
+ examples
12
+ deploy
13
+ docs
14
+ dist
15
+ build
@@ -0,0 +1,17 @@
1
+ # Customer Gateway with Agentic Runtime Authority (required; api.akeyless.io is rejected)
2
+ AKEYLESS_GATEWAY_URL=https://10.0.0.5:8000
3
+
4
+ # Akeyless GCP auth method bound to the Cloud Run service account
5
+ AKEYLESS_ACCESS_ID=p-xxxxxxxx
6
+ AKEYLESS_ACCESS_TYPE=gcp
7
+ AKEYLESS_GCP_AUDIENCE=akeyless.io
8
+
9
+ # Optional
10
+ # AKEYLESS_CA_BUNDLE=/etc/akeyless/ca.pem
11
+ # AKEYLESS_DEFAULT_SECRET_NAME=/prod/orders-db
12
+ # AKEYLESS_AGENT_ID=cloud-run
13
+ # PORT=8080
14
+
15
+ # Local development alternative
16
+ # AKEYLESS_ACCESS_TYPE=access_key
17
+ # AKEYLESS_ACCESS_KEY=
@@ -0,0 +1,48 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.10", "3.12"]
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - run: pip install -e ".[dev,mcp]"
26
+ - run: pytest
27
+
28
+ image:
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ - run: docker build -t akeyless-cloudrun-rta:ci .
33
+ - name: Container runs as non-root
34
+ run: test "$(docker run --rm --entrypoint id akeyless-cloudrun-rta:ci -u)" != "0"
35
+
36
+ ci-success:
37
+ name: ci-success
38
+ runs-on: ubuntu-latest
39
+ needs: [test, image]
40
+ if: always()
41
+ steps:
42
+ - name: Require all jobs to pass
43
+ run: |
44
+ if [ "${{ needs.test.result }}" != "success" ] || [ "${{ needs.image.result }}" != "success" ]; then
45
+ echo "One or more jobs failed"
46
+ exit 1
47
+ fi
48
+ echo "All jobs passed"
@@ -0,0 +1,74 @@
1
+ name: Publish
2
+
3
+ # Push a tag vX.Y.Z (scripts/release.sh does this) to test, build, publish to
4
+ # PyPI and create the GitHub Release. The workflow file name and the `pypi`
5
+ # environment must match the trusted publisher registered on PyPI.
6
+ on:
7
+ push:
8
+ tags: ["v*.*.*"]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.12"
24
+
25
+ - name: Tag must be on main
26
+ run: |
27
+ git fetch origin main
28
+ git merge-base --is-ancestor "$GITHUB_SHA" origin/main \
29
+ || { echo "Tag $GITHUB_REF_NAME is not on main"; exit 1; }
30
+
31
+ - name: Tag must match package version
32
+ run: |
33
+ version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' src/akeyless_cloudrun_rta/__init__.py)
34
+ if [ "v${version}" != "$GITHUB_REF_NAME" ]; then
35
+ echo "Tag $GITHUB_REF_NAME does not match __version__ ${version}"
36
+ exit 1
37
+ fi
38
+
39
+ - run: pip install -e ".[dev,mcp]" build
40
+ - run: pytest
41
+ - run: python -m build
42
+
43
+ - uses: actions/upload-artifact@v4
44
+ with:
45
+ name: dist
46
+ path: dist/
47
+
48
+ pypi:
49
+ needs: build
50
+ runs-on: ubuntu-latest
51
+ environment: pypi
52
+ permissions:
53
+ id-token: write
54
+ steps:
55
+ - uses: actions/download-artifact@v4
56
+ with:
57
+ name: dist
58
+ path: dist/
59
+ - uses: pypa/gh-action-pypi-publish@release/v1
60
+
61
+ github-release:
62
+ needs: pypi
63
+ runs-on: ubuntu-latest
64
+ permissions:
65
+ contents: write
66
+ steps:
67
+ - uses: actions/checkout@v4
68
+ - uses: actions/download-artifact@v4
69
+ with:
70
+ name: dist
71
+ path: dist/
72
+ - env:
73
+ GH_TOKEN: ${{ github.token }}
74
+ run: gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --generate-notes --verify-tag
@@ -0,0 +1,33 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ dist/
7
+ build/
8
+ *.egg
9
+ .venv/
10
+ venv/
11
+ .env
12
+ .env.local
13
+ .env.*.local
14
+
15
+ # Testing / tooling
16
+ .pytest_cache/
17
+ .coverage
18
+ htmlcov/
19
+ .mypy_cache/
20
+ .ruff_cache/
21
+
22
+ # IDE
23
+ .idea/
24
+ .vscode/
25
+ *.swp
26
+ .DS_Store
27
+
28
+
29
+ # Terraform
30
+ .terraform/
31
+ *.tfstate
32
+ *.tfstate.*
33
+ .terraform.lock.hcl
@@ -0,0 +1,23 @@
1
+ FROM python:3.12-slim AS build
2
+
3
+ WORKDIR /src
4
+ COPY pyproject.toml README.md LICENSE ./
5
+ COPY src ./src
6
+ RUN pip install --no-cache-dir --upgrade pip \
7
+ && pip wheel --no-cache-dir --wheel-dir /wheels ".[mcp]"
8
+
9
+ FROM python:3.12-slim
10
+
11
+ ENV PYTHONDONTWRITEBYTECODE=1 \
12
+ PYTHONUNBUFFERED=1 \
13
+ PORT=8080
14
+
15
+ COPY --from=build /wheels /wheels
16
+ RUN pip install --no-cache-dir /wheels/*.whl \
17
+ && rm -rf /wheels \
18
+ && useradd --uid 10001 --no-create-home --shell /usr/sbin/nologin app
19
+
20
+ USER 10001
21
+ EXPOSE 8080
22
+
23
+ CMD ["akeyless-cloudrun-rta-mcp"]
@@ -0,0 +1,19 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ Copyright 2026 Akeyless Community
8
+
9
+ Licensed under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License.
11
+ You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.5
2
+ Name: akeyless-cloudrun-rta
3
+ Version: 0.1.0
4
+ Summary: Akeyless Agentic Runtime Authority (RTA/ARA) for Google Cloud Run — secretless DB and cloud actions
5
+ Project-URL: Homepage, https://github.com/akeyless-community/cloud-run-akeyless-rta
6
+ Project-URL: Repository, https://github.com/akeyless-community/cloud-run-akeyless-rta
7
+ Author: Akeyless Community
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: adk,akeyless,ara,cloud-run,gcp,mcp,rta,runtime-authority
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Security
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: akeyless-cloud-id>=0.3.1
21
+ Requires-Dist: akeyless>=5.0.0
22
+ Requires-Dist: google-auth>=2.20.0
23
+ Requires-Dist: requests>=2.31.0
24
+ Provides-Extra: all
25
+ Requires-Dist: mcp<2,>=1.9.0; extra == 'all'
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
29
+ Provides-Extra: mcp
30
+ Requires-Dist: mcp<2,>=1.9.0; extra == 'mcp'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # Akeyless RTA for Google Cloud Run
34
+
35
+ Let AI agents on Google Cloud query databases and act on cloud services **without ever holding credentials**. This package runs Akeyless **Agentic Runtime Authority** (RTA, also called ARA) on Cloud Run:
36
+
37
+ - The Cloud Run service signs in to Akeyless with its **service account** (GCP auth method). No Akeyless keys in env vars or images.
38
+ - Agents call `query-db` or `service-execute`; your **Akeyless Gateway** runs the query or action with credentials it keeps to itself and returns only results.
39
+ - Callers are gated by **Cloud Run IAM** (`roles/run.invoker`).
40
+
41
+ Two ways to use it:
42
+
43
+ | Mode | When |
44
+ |------|------|
45
+ | **MCP server on Cloud Run** | Any MCP client (ADK `MCPToolset`, Gemini, Claude, Cursor) |
46
+ | **Embedded client library** | Your agent already runs on Cloud Run and calls Python directly |
47
+
48
+ ## Quick start
49
+
50
+ 1. Set up the Gateway, auth method and role: [docs/AKEYLESS_SETUP.md](docs/AKEYLESS_SETUP.md)
51
+ 2. Deploy: [docs/CLOUD_RUN_DEPLOY.md](docs/CLOUD_RUN_DEPLOY.md)
52
+
53
+ ### Embedded
54
+
55
+ ```bash
56
+ pip install akeyless-cloudrun-rta
57
+ ```
58
+
59
+ ```python
60
+ from akeyless_cloudrun_rta import AkeylessRtaClient
61
+
62
+ client = AkeylessRtaClient() # AKEYLESS_GATEWAY_URL, AKEYLESS_ACCESS_ID from env; access type gcp
63
+ for secret in client.list_secrets():
64
+ print(secret.name, secret.target_type)
65
+
66
+ result = client.query_db("SELECT count(*) FROM orders", secret_name="/prod/orders-db")
67
+ print(result.results)
68
+ ```
69
+
70
+ ### MCP server (local run)
71
+
72
+ ```bash
73
+ pip install 'akeyless-cloudrun-rta[mcp]'
74
+ PORT=8080 akeyless-cloudrun-rta-mcp # serves http://localhost:8080/mcp
75
+ ```
76
+
77
+ ## Tools
78
+
79
+ | Tool | Purpose |
80
+ |------|---------|
81
+ | `list-secrets` | RTA-enabled secrets: names and types only (hidden when `AKEYLESS_DEFAULT_SECRET_NAME` is set) |
82
+ | `query-db` | SQL / NoSQL query on a database secret |
83
+ | `service-execute` | Cloud, Kubernetes, GitHub, custom MCP action, or a remote command on SSH / Windows / LDAP items |
84
+ | `list-sub-tools` | Optional discovery for service secrets and remote items |
85
+
86
+ Tool names, descriptions and arguments match the Akeyless Go MCP server (`akeyless mcp-runtime-authority`) and the [Bedrock AgentCore package](https://github.com/akeyless-community/bedrock-agentcore-akeyless-rta).
87
+
88
+ ## Examples
89
+
90
+ - [examples/adk-agent/embedded_agent](examples/adk-agent/embedded_agent/agent.py): ADK agent with the client as function tools
91
+ - [examples/adk-agent/mcp_agent](examples/adk-agent/mcp_agent/agent.py): ADK agent calling the Cloud Run MCP server
92
+
93
+ ## Development
94
+
95
+ ```bash
96
+ python -m venv .venv && . .venv/bin/activate
97
+ pip install -e '.[dev,mcp]'
98
+ pytest
99
+ ```
100
+
101
+ Releases are automated from tags; see [docs/RELEASING.md](docs/RELEASING.md).
102
+
103
+ ## License
104
+
105
+ Apache-2.0
@@ -0,0 +1,73 @@
1
+ # Akeyless RTA for Google Cloud Run
2
+
3
+ Let AI agents on Google Cloud query databases and act on cloud services **without ever holding credentials**. This package runs Akeyless **Agentic Runtime Authority** (RTA, also called ARA) on Cloud Run:
4
+
5
+ - The Cloud Run service signs in to Akeyless with its **service account** (GCP auth method). No Akeyless keys in env vars or images.
6
+ - Agents call `query-db` or `service-execute`; your **Akeyless Gateway** runs the query or action with credentials it keeps to itself and returns only results.
7
+ - Callers are gated by **Cloud Run IAM** (`roles/run.invoker`).
8
+
9
+ Two ways to use it:
10
+
11
+ | Mode | When |
12
+ |------|------|
13
+ | **MCP server on Cloud Run** | Any MCP client (ADK `MCPToolset`, Gemini, Claude, Cursor) |
14
+ | **Embedded client library** | Your agent already runs on Cloud Run and calls Python directly |
15
+
16
+ ## Quick start
17
+
18
+ 1. Set up the Gateway, auth method and role: [docs/AKEYLESS_SETUP.md](docs/AKEYLESS_SETUP.md)
19
+ 2. Deploy: [docs/CLOUD_RUN_DEPLOY.md](docs/CLOUD_RUN_DEPLOY.md)
20
+
21
+ ### Embedded
22
+
23
+ ```bash
24
+ pip install akeyless-cloudrun-rta
25
+ ```
26
+
27
+ ```python
28
+ from akeyless_cloudrun_rta import AkeylessRtaClient
29
+
30
+ client = AkeylessRtaClient() # AKEYLESS_GATEWAY_URL, AKEYLESS_ACCESS_ID from env; access type gcp
31
+ for secret in client.list_secrets():
32
+ print(secret.name, secret.target_type)
33
+
34
+ result = client.query_db("SELECT count(*) FROM orders", secret_name="/prod/orders-db")
35
+ print(result.results)
36
+ ```
37
+
38
+ ### MCP server (local run)
39
+
40
+ ```bash
41
+ pip install 'akeyless-cloudrun-rta[mcp]'
42
+ PORT=8080 akeyless-cloudrun-rta-mcp # serves http://localhost:8080/mcp
43
+ ```
44
+
45
+ ## Tools
46
+
47
+ | Tool | Purpose |
48
+ |------|---------|
49
+ | `list-secrets` | RTA-enabled secrets: names and types only (hidden when `AKEYLESS_DEFAULT_SECRET_NAME` is set) |
50
+ | `query-db` | SQL / NoSQL query on a database secret |
51
+ | `service-execute` | Cloud, Kubernetes, GitHub, custom MCP action, or a remote command on SSH / Windows / LDAP items |
52
+ | `list-sub-tools` | Optional discovery for service secrets and remote items |
53
+
54
+ Tool names, descriptions and arguments match the Akeyless Go MCP server (`akeyless mcp-runtime-authority`) and the [Bedrock AgentCore package](https://github.com/akeyless-community/bedrock-agentcore-akeyless-rta).
55
+
56
+ ## Examples
57
+
58
+ - [examples/adk-agent/embedded_agent](examples/adk-agent/embedded_agent/agent.py): ADK agent with the client as function tools
59
+ - [examples/adk-agent/mcp_agent](examples/adk-agent/mcp_agent/agent.py): ADK agent calling the Cloud Run MCP server
60
+
61
+ ## Development
62
+
63
+ ```bash
64
+ python -m venv .venv && . .venv/bin/activate
65
+ pip install -e '.[dev,mcp]'
66
+ pytest
67
+ ```
68
+
69
+ Releases are automated from tags; see [docs/RELEASING.md](docs/RELEASING.md).
70
+
71
+ ## License
72
+
73
+ Apache-2.0
@@ -0,0 +1,20 @@
1
+ # Security
2
+
3
+ ## Model
4
+
5
+ - The Cloud Run service holds **no Akeyless keys**. It authenticates with its service account's Google ID token, and the Gateway keeps the target credentials.
6
+ - Tool and client responses contain secret **paths, metadata and results only**, never credential values.
7
+ - **Anyone who can invoke the service acts with its Akeyless role.** Deploy with `--no-allow-unauthenticated`, prefer `--ingress internal`, grant `roles/run.invoker` only to the agents and users that need it, and use one service plus one narrow Akeyless role per trust boundary.
8
+ - The invoker email added to `original_user` comes from the ID token Cloud Run IAM already verified. It is audit metadata, not an access-control input.
9
+ - TLS verification to the Gateway is always on. Use `AKEYLESS_CA_BUNDLE` for private CAs; never disable verification.
10
+ - The container runs as a non-root user.
11
+
12
+ ## Operational guidance
13
+
14
+ - Do not log tokens, cloud IDs or tool payloads/results; they may contain sensitive data.
15
+ - Require human approval in the agent for any write, delete or other mutating `query-db` / `service-execute` call.
16
+ - Prefer `AKEYLESS_ACCESS_TYPE=gcp` in production. `access_key` is for local development only; if you must use it on Cloud Run, store the key in Secret Manager, not in plain env vars.
17
+
18
+ ## Reporting a vulnerability
19
+
20
+ Please report security issues privately to security@akeyless.io rather than opening a public issue.
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env bash
2
+ # Deploy the Akeyless RTA MCP server to Cloud Run with a dedicated service
3
+ # account, private VPC egress to the Gateway, and IAM-only ingress.
4
+ #
5
+ # Required env:
6
+ # PROJECT_ID, REGION, NETWORK, SUBNET
7
+ # AKEYLESS_GATEWAY_URL private Gateway URL with ARA enabled, e.g. https://10.0.0.5:8000
8
+ # AKEYLESS_ACCESS_ID Akeyless GCP auth method access ID (p-...)
9
+ # INVOKER_MEMBERS space-separated IAM members allowed to call the service,
10
+ # e.g. "serviceAccount:my-agent@proj.iam.gserviceaccount.com user:me@example.com"
11
+ # Optional env:
12
+ # SERVICE_NAME (akeyless-rta), SA_NAME (akeyless-rta), INGRESS (internal),
13
+ # AKEYLESS_GCP_AUDIENCE (akeyless.io), AKEYLESS_DEFAULT_SECRET_NAME, REPOSITORY (akeyless)
14
+ set -euo pipefail
15
+
16
+ : "${PROJECT_ID:?PROJECT_ID is required}"
17
+ : "${REGION:?REGION is required}"
18
+ : "${NETWORK:?NETWORK is required}"
19
+ : "${SUBNET:?SUBNET is required}"
20
+ : "${AKEYLESS_GATEWAY_URL:?AKEYLESS_GATEWAY_URL is required}"
21
+ : "${AKEYLESS_ACCESS_ID:?AKEYLESS_ACCESS_ID is required}"
22
+ : "${INVOKER_MEMBERS:?INVOKER_MEMBERS is required}"
23
+
24
+ SERVICE_NAME="${SERVICE_NAME:-akeyless-rta}"
25
+ SA_NAME="${SA_NAME:-akeyless-rta}"
26
+ INGRESS="${INGRESS:-internal}"
27
+ REPOSITORY="${REPOSITORY:-akeyless}"
28
+ AKEYLESS_GCP_AUDIENCE="${AKEYLESS_GCP_AUDIENCE:-akeyless.io}"
29
+ SA_EMAIL="${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com"
30
+ IMAGE="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPOSITORY}/${SERVICE_NAME}:$(date +%Y%m%d%H%M%S)"
31
+ ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
32
+
33
+ if ! gcloud iam service-accounts describe "$SA_EMAIL" --project "$PROJECT_ID" >/dev/null 2>&1; then
34
+ gcloud iam service-accounts create "$SA_NAME" \
35
+ --project "$PROJECT_ID" \
36
+ --display-name "Akeyless RTA (Cloud Run)"
37
+ fi
38
+
39
+ if ! gcloud artifacts repositories describe "$REPOSITORY" --location "$REGION" --project "$PROJECT_ID" >/dev/null 2>&1; then
40
+ gcloud artifacts repositories create "$REPOSITORY" \
41
+ --repository-format docker \
42
+ --location "$REGION" \
43
+ --project "$PROJECT_ID"
44
+ fi
45
+
46
+ gcloud builds submit "$ROOT_DIR" --tag "$IMAGE" --project "$PROJECT_ID"
47
+
48
+ ENV_VARS="AKEYLESS_GATEWAY_URL=${AKEYLESS_GATEWAY_URL},AKEYLESS_ACCESS_ID=${AKEYLESS_ACCESS_ID},AKEYLESS_ACCESS_TYPE=gcp,AKEYLESS_GCP_AUDIENCE=${AKEYLESS_GCP_AUDIENCE}"
49
+ if [[ -n "${AKEYLESS_DEFAULT_SECRET_NAME:-}" ]]; then
50
+ ENV_VARS="${ENV_VARS},AKEYLESS_DEFAULT_SECRET_NAME=${AKEYLESS_DEFAULT_SECRET_NAME}"
51
+ fi
52
+
53
+ gcloud run deploy "$SERVICE_NAME" \
54
+ --project "$PROJECT_ID" \
55
+ --region "$REGION" \
56
+ --image "$IMAGE" \
57
+ --service-account "$SA_EMAIL" \
58
+ --no-allow-unauthenticated \
59
+ --ingress "$INGRESS" \
60
+ --network "$NETWORK" \
61
+ --subnet "$SUBNET" \
62
+ --vpc-egress private-ranges-only \
63
+ --timeout 300 \
64
+ --set-env-vars "$ENV_VARS"
65
+
66
+ for member in $INVOKER_MEMBERS; do
67
+ gcloud run services add-iam-policy-binding "$SERVICE_NAME" \
68
+ --project "$PROJECT_ID" \
69
+ --region "$REGION" \
70
+ --member "$member" \
71
+ --role roles/run.invoker
72
+ done
73
+
74
+ echo "Deployed ${SERVICE_NAME}. Bind ${SA_EMAIL} in your Akeyless GCP auth method if you have not already."
@@ -0,0 +1,81 @@
1
+ terraform {
2
+ required_version = ">= 1.5"
3
+ required_providers {
4
+ google = {
5
+ source = "hashicorp/google"
6
+ version = ">= 5.30"
7
+ }
8
+ }
9
+ }
10
+
11
+ provider "google" {
12
+ project = var.project_id
13
+ region = var.region
14
+ }
15
+
16
+ resource "google_service_account" "rta" {
17
+ account_id = var.service_account_name
18
+ display_name = "Akeyless RTA (Cloud Run)"
19
+ }
20
+
21
+ resource "google_cloud_run_v2_service" "rta" {
22
+ name = var.service_name
23
+ location = var.region
24
+ ingress = var.ingress
25
+ deletion_protection = false
26
+
27
+ template {
28
+ service_account = google_service_account.rta.email
29
+ timeout = "300s"
30
+
31
+ vpc_access {
32
+ egress = "PRIVATE_RANGES_ONLY"
33
+ network_interfaces {
34
+ network = var.network
35
+ subnetwork = var.subnet
36
+ }
37
+ }
38
+
39
+ containers {
40
+ image = var.image
41
+
42
+ ports {
43
+ container_port = 8080
44
+ }
45
+
46
+ env {
47
+ name = "AKEYLESS_GATEWAY_URL"
48
+ value = var.akeyless_gateway_url
49
+ }
50
+ env {
51
+ name = "AKEYLESS_ACCESS_ID"
52
+ value = var.akeyless_access_id
53
+ }
54
+ env {
55
+ name = "AKEYLESS_ACCESS_TYPE"
56
+ value = "gcp"
57
+ }
58
+ env {
59
+ name = "AKEYLESS_GCP_AUDIENCE"
60
+ value = var.akeyless_gcp_audience
61
+ }
62
+ dynamic "env" {
63
+ for_each = var.akeyless_default_secret_name == "" ? [] : [var.akeyless_default_secret_name]
64
+ content {
65
+ name = "AKEYLESS_DEFAULT_SECRET_NAME"
66
+ value = env.value
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ # No allUsers / allAuthenticatedUsers binding: callers must hold roles/run.invoker.
74
+ resource "google_cloud_run_v2_service_iam_member" "invokers" {
75
+ for_each = toset(var.invoker_members)
76
+
77
+ name = google_cloud_run_v2_service.rta.name
78
+ location = google_cloud_run_v2_service.rta.location
79
+ role = "roles/run.invoker"
80
+ member = each.value
81
+ }
@@ -0,0 +1,8 @@
1
+ output "service_url" {
2
+ value = google_cloud_run_v2_service.rta.uri
3
+ }
4
+
5
+ output "service_account_email" {
6
+ description = "Bind this service account in the Akeyless GCP auth method."
7
+ value = google_service_account.rta.email
8
+ }
@@ -0,0 +1,74 @@
1
+ variable "project_id" {
2
+ type = string
3
+ }
4
+
5
+ variable "region" {
6
+ type = string
7
+ }
8
+
9
+ variable "image" {
10
+ type = string
11
+ description = "Container image built from this repo's Dockerfile."
12
+ }
13
+
14
+ variable "network" {
15
+ type = string
16
+ description = "VPC network that can reach the Akeyless Gateway."
17
+ }
18
+
19
+ variable "subnet" {
20
+ type = string
21
+ description = "Subnet used for Direct VPC egress."
22
+ }
23
+
24
+ variable "akeyless_gateway_url" {
25
+ type = string
26
+ description = "Private Gateway URL with ARA enabled, e.g. https://10.0.0.5:8000. Not api.akeyless.io."
27
+
28
+ validation {
29
+ condition = !can(regex("api\\.akeyless\\.io", lower(var.akeyless_gateway_url)))
30
+ error_message = "ARA needs a customer Gateway; the public SaaS API (api.akeyless.io) is not supported."
31
+ }
32
+ }
33
+
34
+ variable "akeyless_access_id" {
35
+ type = string
36
+ description = "Access ID of the Akeyless GCP auth method bound to the service account."
37
+ }
38
+
39
+ variable "akeyless_gcp_audience" {
40
+ type = string
41
+ default = "akeyless.io"
42
+ }
43
+
44
+ variable "akeyless_default_secret_name" {
45
+ type = string
46
+ default = ""
47
+ }
48
+
49
+ variable "invoker_members" {
50
+ type = list(string)
51
+ description = "IAM members allowed to call the service (serviceAccount:..., user:..., group:...)."
52
+
53
+ validation {
54
+ condition = alltrue([
55
+ for m in var.invoker_members : !contains(["allUsers", "allAuthenticatedUsers"], m)
56
+ ])
57
+ error_message = "Public invokers are not allowed: anyone who can call the service acts with its Akeyless role."
58
+ }
59
+ }
60
+
61
+ variable "service_name" {
62
+ type = string
63
+ default = "akeyless-rta"
64
+ }
65
+
66
+ variable "service_account_name" {
67
+ type = string
68
+ default = "akeyless-rta"
69
+ }
70
+
71
+ variable "ingress" {
72
+ type = string
73
+ default = "INGRESS_TRAFFIC_INTERNAL_ONLY"
74
+ }