base2-mcp 0.1.0__py3-none-any.whl
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.
- __init__.py +0 -0
- app.py +54 -0
- base2_mcp-0.1.0.dist-info/METADATA +171 -0
- base2_mcp-0.1.0.dist-info/RECORD +23 -0
- base2_mcp-0.1.0.dist-info/WHEEL +4 -0
- base2_mcp-0.1.0.dist-info/entry_points.txt +2 -0
- docs/__init__.py +30 -0
- docs/bastion.md +138 -0
- docs/cfhighlander.md +145 -0
- docs/cfn_vpn.md +97 -0
- docs/guardian.md +125 -0
- docs/monitorable.md +75 -0
- docs/shelvery.md +144 -0
- executor/__init__.py +0 -0
- executor/cli_runner.py +90 -0
- tools/__init__.py +0 -0
- tools/bastion_tools.py +146 -0
- tools/cfhighlander_tools.py +168 -0
- tools/cfn_vpn_tools.py +147 -0
- tools/guardian_tools.py +117 -0
- tools/monitorable_tools.py +66 -0
- tools/overview_tools.py +72 -0
- tools/shelvery_tools.py +161 -0
__init__.py
ADDED
|
File without changes
|
app.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from mcp.server.fastmcp import FastMCP
|
|
7
|
+
|
|
8
|
+
from tools.overview_tools import register_overview_tools
|
|
9
|
+
from tools.cfhighlander_tools import register_cfhighlander_tools
|
|
10
|
+
from tools.shelvery_tools import register_shelvery_tools
|
|
11
|
+
from tools.guardian_tools import register_guardian_tools
|
|
12
|
+
from tools.monitorable_tools import register_monitorable_tools
|
|
13
|
+
from tools.cfn_vpn_tools import register_cfn_vpn_tools
|
|
14
|
+
from tools.bastion_tools import register_bastion_tools
|
|
15
|
+
|
|
16
|
+
logging.basicConfig(
|
|
17
|
+
level=logging.INFO,
|
|
18
|
+
format="%(asctime)s %(name)s %(levelname)s %(message)s",
|
|
19
|
+
stream=sys.stderr,
|
|
20
|
+
)
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
mcp = FastMCP(
|
|
24
|
+
name="base2-mcp",
|
|
25
|
+
instructions=(
|
|
26
|
+
"Base2 MCP Server — documentation, guidance, and CLI execution for "
|
|
27
|
+
"Base2 open-source AWS tools.\n\n"
|
|
28
|
+
"Supported tools:\n"
|
|
29
|
+
"- **cfhighlander**: CloudFormation DSL and component library\n"
|
|
30
|
+
"- **shelvery**: Automated AWS backups (EBS, RDS, EC2, Redshift, DocumentDB)\n"
|
|
31
|
+
"- **cfn-guardian**: CloudWatch alarm management via CloudFormation\n"
|
|
32
|
+
"- **monitorable**: CloudWatch alarm coverage auditing\n"
|
|
33
|
+
"- **cfn-vpn**: AWS Client VPN management via CloudFormation\n"
|
|
34
|
+
"- **bastion-cli**: Temporary bastion EC2 instances via Session Manager\n\n"
|
|
35
|
+
"Start with 'list_base2_tools' for an overview of all tools, or "
|
|
36
|
+
"'get_tool_docs' to read detailed documentation for a specific tool."
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
register_overview_tools(mcp)
|
|
41
|
+
register_cfhighlander_tools(mcp)
|
|
42
|
+
register_shelvery_tools(mcp)
|
|
43
|
+
register_guardian_tools(mcp)
|
|
44
|
+
register_monitorable_tools(mcp)
|
|
45
|
+
register_cfn_vpn_tools(mcp)
|
|
46
|
+
register_bastion_tools(mcp)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def main() -> None:
|
|
50
|
+
mcp.run(transport="stdio")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
main()
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: base2-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for Base2 open-source AWS tools — documentation, guidance, and CLI execution
|
|
5
|
+
Author: Base2 Services
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: aws,backup,bastion,cloudformation,mcp,monitoring,vpn
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Requires-Dist: mcp[cli]>=1.9.0
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# base2-mcp
|
|
16
|
+
|
|
17
|
+
MCP server for Base2 open-source AWS tools — documentation, guidance, and CLI execution.
|
|
18
|
+
|
|
19
|
+
## Supported Tools
|
|
20
|
+
|
|
21
|
+
| Tool | Description | Install |
|
|
22
|
+
|------|-------------|---------|
|
|
23
|
+
| [cfhighlander](https://github.com/theonestack/cfhighlander) | CloudFormation DSL and component library | `gem install cfhighlander` |
|
|
24
|
+
| [shelvery](https://github.com/base2Services/shelvery-aws-backups) | Automated AWS backups (EBS, RDS, EC2, Redshift, DocumentDB) | `pip install shelvery` |
|
|
25
|
+
| [cfn-guardian](https://github.com/base2Services/cfn-guardian) | CloudWatch alarm management via CloudFormation | `gem install cfn-guardian` |
|
|
26
|
+
| [monitorable](https://github.com/base2Services/monitorable) | CloudWatch alarm coverage auditing | Clone repo |
|
|
27
|
+
| [cfn-vpn](https://github.com/base2Services/cfn-vpn) | AWS Client VPN management via CloudFormation | `gem install cfn-vpn` |
|
|
28
|
+
| [bastion-cli](https://github.com/base2Services/bastion-cli) | Temporary bastion EC2 instances via Session Manager | [GitHub releases](https://github.com/base2Services/bastion-cli/releases) |
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
### Cursor IDE (Recommended)
|
|
33
|
+
|
|
34
|
+
Add to your `.cursor/mcp.json` (project-level) or `~/.cursor/mcp.json` (global):
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"base2": {
|
|
40
|
+
"command": "uvx",
|
|
41
|
+
"args": ["--upgrade", "base2-mcp"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
No manual install needed — `uvx` fetches the package from PyPI automatically and `--upgrade` ensures you always get the latest version on server restart.
|
|
48
|
+
|
|
49
|
+
### Claude Desktop
|
|
50
|
+
|
|
51
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"base2": {
|
|
57
|
+
"command": "uvx",
|
|
58
|
+
"args": ["--upgrade", "base2-mcp"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Alternative: pin to a specific version
|
|
65
|
+
|
|
66
|
+
If you need a stable version that won't change unexpectedly:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"base2": {
|
|
72
|
+
"command": "uvx",
|
|
73
|
+
"args": ["base2-mcp==0.1.0"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Prerequisite: uv
|
|
80
|
+
|
|
81
|
+
`uvx` is part of [uv](https://docs.astral.sh/uv/), a fast Python package manager. Install it with:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# macOS / Linux
|
|
85
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
86
|
+
|
|
87
|
+
# Windows
|
|
88
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
89
|
+
|
|
90
|
+
# Or via pip
|
|
91
|
+
pip install uv
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## What It Does
|
|
95
|
+
|
|
96
|
+
This MCP server gives AI agents two capabilities for each tool:
|
|
97
|
+
|
|
98
|
+
1. **Documentation** — Embedded docs with CLI usage, configuration, examples, and best practices. The agent can read these to understand any tool without you explaining it.
|
|
99
|
+
|
|
100
|
+
2. **CLI Execution** — Wrapper tools that run the actual CLI commands (`cfhighlander cfcompile`, `shelvery ebs create_backups`, `bastion launch`, etc.) and return structured output.
|
|
101
|
+
|
|
102
|
+
### Available MCP Tools
|
|
103
|
+
|
|
104
|
+
**Discovery:**
|
|
105
|
+
- `list_base2_tools` — Overview of all 6 tools
|
|
106
|
+
- `get_tool_docs` — Detailed documentation for a specific tool
|
|
107
|
+
|
|
108
|
+
**cfhighlander:**
|
|
109
|
+
- `cfhighlander_docs` / `cfhighlander_compile` / `cfhighlander_publish` / `cfhighlander_test` / `cfhighlander_validate`
|
|
110
|
+
|
|
111
|
+
**shelvery:**
|
|
112
|
+
- `shelvery_docs` / `shelvery_create_backups` / `shelvery_clean_backups` / `shelvery_pull_shared_backups`
|
|
113
|
+
|
|
114
|
+
**cfn-guardian:**
|
|
115
|
+
- `guardian_docs` / `guardian_compile` / `guardian_deploy` / `guardian_show_alarms` / `guardian_show_resources`
|
|
116
|
+
|
|
117
|
+
**monitorable:**
|
|
118
|
+
- `monitorable_docs` / `monitorable_audit`
|
|
119
|
+
|
|
120
|
+
**cfn-vpn:**
|
|
121
|
+
- `cfn_vpn_docs` / `cfn_vpn_init` / `cfn_vpn_modify` / `cfn_vpn_routes` / `cfn_vpn_sessions`
|
|
122
|
+
|
|
123
|
+
**bastion-cli:**
|
|
124
|
+
- `bastion_docs` / `bastion_launch` / `bastion_connect` / `bastion_terminate` / `bastion_port_forward`
|
|
125
|
+
|
|
126
|
+
## Prerequisites
|
|
127
|
+
|
|
128
|
+
The MCP server itself only needs Python 3.11+ and the `mcp` package. The CLI tools it wraps need to be installed separately — the server will tell the agent if a tool is missing and how to install it.
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Install dependencies
|
|
134
|
+
pip install -r requirements.txt -r requirements-dev.txt
|
|
135
|
+
|
|
136
|
+
# Run tests
|
|
137
|
+
pytest tests/ -v
|
|
138
|
+
|
|
139
|
+
# Run the server locally (stdio mode)
|
|
140
|
+
python src/app.py
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Architecture
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
base2-mcp/
|
|
147
|
+
├── src/
|
|
148
|
+
│ ├── app.py # FastMCP entry point (stdio transport)
|
|
149
|
+
│ ├── docs/ # Embedded markdown documentation
|
|
150
|
+
│ │ ├── __init__.py # Doc loader utility
|
|
151
|
+
│ │ ├── cfhighlander.md
|
|
152
|
+
│ │ ├── shelvery.md
|
|
153
|
+
│ │ ├── guardian.md
|
|
154
|
+
│ │ ├── monitorable.md
|
|
155
|
+
│ │ ├── cfn_vpn.md
|
|
156
|
+
│ │ └── bastion.md
|
|
157
|
+
│ ├── executor/
|
|
158
|
+
│ │ └── cli_runner.py # Shared subprocess executor
|
|
159
|
+
│ └── tools/ # One module per tool
|
|
160
|
+
│ ├── overview_tools.py # list_base2_tools, get_tool_docs
|
|
161
|
+
│ ├── cfhighlander_tools.py
|
|
162
|
+
│ ├── shelvery_tools.py
|
|
163
|
+
│ ├── guardian_tools.py
|
|
164
|
+
│ ├── monitorable_tools.py
|
|
165
|
+
│ ├── cfn_vpn_tools.py
|
|
166
|
+
│ └── bastion_tools.py
|
|
167
|
+
├── tests/ # pytest suite (56 tests)
|
|
168
|
+
├── pyproject.toml
|
|
169
|
+
├── requirements.txt
|
|
170
|
+
└── requirements-dev.txt
|
|
171
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
app.py,sha256=sNbbvdv0Y1bn5LpbeHnVsycY_s6ee1pBdDVQvA8ejDU,1815
|
|
3
|
+
docs/__init__.py,sha256=9TLNUywZ35fBYuy05BheQciEhSGJVhHGEEw0fEUeEj0,668
|
|
4
|
+
docs/bastion.md,sha256=_dg197MPbsfXukYJGwxJenm_-2HQm0vBk-foUu_vMuo,3672
|
|
5
|
+
docs/cfhighlander.md,sha256=CejQX0pD_kKO19Awq_nuFxTBeKxqvILHUQYCIWmSn1c,5179
|
|
6
|
+
docs/cfn_vpn.md,sha256=tZQnvU-4cbC98vOYxK3Qf4phHU_UhUJzY8VxaNBIJhU,2380
|
|
7
|
+
docs/guardian.md,sha256=Z-oGa6e8LIZTVQpvWW4WKqnNYNztwk0nwH0128OMAXg,3184
|
|
8
|
+
docs/monitorable.md,sha256=35HFs769HByrGm_WXye_tirpeKZvLyibrovCjADDEL0,2539
|
|
9
|
+
docs/shelvery.md,sha256=eA_oZmH17UD4QzSKyPXJk00quxF4LIbrwIkRlIHg7d8,4459
|
|
10
|
+
executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
executor/cli_runner.py,sha256=y5Ou-y81ms7LnCGmUUZHuDwzCl-lsLycBzgjBWdQeGo,2469
|
|
12
|
+
tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
tools/bastion_tools.py,sha256=OLNcoiieTZLlqsZKsY5xAJ8AaEbyoKdkGMZbjfsfumQ,4876
|
|
14
|
+
tools/cfhighlander_tools.py,sha256=TAFDSoTb9bWO1f8TRqa0UAsd0xPhMrGR_pxcaJmohgw,5818
|
|
15
|
+
tools/cfn_vpn_tools.py,sha256=XQC4TA3LGkUPNgDm--rcSNYFHHueE0qsfxhoZjXoSQ8,4348
|
|
16
|
+
tools/guardian_tools.py,sha256=K4FFoWUbmlYemo3slCuRWFTCrJS_iEj0zooc-s8YGWY,3644
|
|
17
|
+
tools/monitorable_tools.py,sha256=xrsR71u-U9aK0nDqR_s0MZ5ZJnb3SPGX_T0vxeNl6k0,2183
|
|
18
|
+
tools/overview_tools.py,sha256=uir1zXGH9YcQOcYw7olVlgVTB8eAIEC6lxgSAjUj0So,2481
|
|
19
|
+
tools/shelvery_tools.py,sha256=Ywt2Ap9v64zfcI0oVH6J490ye1GuUb1PFW5kssooNis,5735
|
|
20
|
+
base2_mcp-0.1.0.dist-info/METADATA,sha256=les5mHRlgsmCbnxBW2iBgmoHzEES0e3kAsjecbIjClw,5607
|
|
21
|
+
base2_mcp-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
22
|
+
base2_mcp-0.1.0.dist-info/entry_points.txt,sha256=yPZYCEC3vLL0y17JJGyaAfvA9pOmlEj_DnRYw3Au3o0,39
|
|
23
|
+
base2_mcp-0.1.0.dist-info/RECORD,,
|
docs/__init__.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Literal
|
|
5
|
+
|
|
6
|
+
DOCS_DIR = Path(__file__).parent
|
|
7
|
+
|
|
8
|
+
ToolName = Literal[
|
|
9
|
+
"cfhighlander",
|
|
10
|
+
"shelvery",
|
|
11
|
+
"guardian",
|
|
12
|
+
"monitorable",
|
|
13
|
+
"cfn_vpn",
|
|
14
|
+
"bastion",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
TOOL_DOC_FILES: dict[ToolName, str] = {
|
|
18
|
+
"cfhighlander": "cfhighlander.md",
|
|
19
|
+
"shelvery": "shelvery.md",
|
|
20
|
+
"guardian": "guardian.md",
|
|
21
|
+
"monitorable": "monitorable.md",
|
|
22
|
+
"cfn_vpn": "cfn_vpn.md",
|
|
23
|
+
"bastion": "bastion.md",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def load_doc(tool: ToolName) -> str:
|
|
28
|
+
"""Load the embedded markdown documentation for a tool."""
|
|
29
|
+
filename = TOOL_DOC_FILES[tool]
|
|
30
|
+
return (DOCS_DIR / filename).read_text()
|
docs/bastion.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# bastion-cli
|
|
2
|
+
|
|
3
|
+
Temporary on-demand bastion EC2 instances via AWS Session Manager.
|
|
4
|
+
|
|
5
|
+
- **Source**: https://github.com/base2Services/bastion-cli
|
|
6
|
+
- **Language**: Go
|
|
7
|
+
- **Install**: Download binary from [GitHub releases](https://github.com/base2Services/bastion-cli/releases) and add to PATH
|
|
8
|
+
- **Supported OS**: macOS, Windows, Linux
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Bastion CLI creates and manages temporary on-demand bastion EC2 instances and connects to them using AWS Session Manager. Supports both Amazon Linux and Windows operating systems.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- AWS credentials configured
|
|
17
|
+
- [AWS Session Manager Plugin](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html) installed
|
|
18
|
+
- For Windows RDP: Microsoft Remote Desktop (macOS) or mstsc (Windows)
|
|
19
|
+
|
|
20
|
+
## CLI Commands
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bastion --help # List all commands
|
|
24
|
+
bastion COMMAND --help # Help for specific command
|
|
25
|
+
|
|
26
|
+
# Launch a new Linux bastion
|
|
27
|
+
bastion launch
|
|
28
|
+
|
|
29
|
+
# Launch a new Windows bastion
|
|
30
|
+
bastion launch-windows
|
|
31
|
+
|
|
32
|
+
# Connect to an existing instance
|
|
33
|
+
bastion start-session
|
|
34
|
+
|
|
35
|
+
# Remote port forwarding
|
|
36
|
+
bastion port-forward --remote-port 5432 --region ap-southeast-2
|
|
37
|
+
|
|
38
|
+
# Terminate a bastion
|
|
39
|
+
bastion terminate --session-id <session-id>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Launching Linux Bastions
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Basic launch (auto-terminates after 2 hours)
|
|
46
|
+
bastion launch
|
|
47
|
+
|
|
48
|
+
# Extended expiry (5 hours)
|
|
49
|
+
bastion launch --expire-after 300
|
|
50
|
+
|
|
51
|
+
# No expiry (requires manual termination)
|
|
52
|
+
bastion launch --no-expire
|
|
53
|
+
|
|
54
|
+
# Prevent auto-terminate on session end
|
|
55
|
+
bastion launch --no-terminate
|
|
56
|
+
|
|
57
|
+
# SSH session with key
|
|
58
|
+
bastion launch --ssh --ssh-key ~/.ssh/id_rsa.pub
|
|
59
|
+
|
|
60
|
+
# SSH tunnel (e.g. to an RDS instance)
|
|
61
|
+
bastion launch --ssh --ssh-key ~/.ssh/id_rsa.pub \
|
|
62
|
+
--ssh-opts '-L 3306:db.internal.example.com:3306'
|
|
63
|
+
|
|
64
|
+
# Mount EFS filesystem
|
|
65
|
+
bastion launch --efs fs-123456789
|
|
66
|
+
|
|
67
|
+
# Mount EFS access points
|
|
68
|
+
bastion launch --efs fs-123456789 \
|
|
69
|
+
--access-points fsap-12345678900000000,fsap-12345678900000001
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Launching Windows Bastions
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Basic launch
|
|
76
|
+
bastion launch-windows
|
|
77
|
+
|
|
78
|
+
# Launch with RDP session
|
|
79
|
+
bastion launch-windows --rdp
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When using `--rdp`, the CLI opens the RDP client and copies the Administrator password to clipboard.
|
|
83
|
+
|
|
84
|
+
## Connecting to Existing Instances
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Interactive instance picker (any instance with SSM agent)
|
|
88
|
+
bastion start-session
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Port Forwarding
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
bastion port-forward --remote-port 5432 --region ap-southeast-2
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Creates an SSH tunnel through a bastion to a remote service (e.g. RDS on port 5432).
|
|
98
|
+
|
|
99
|
+
## Instance Management
|
|
100
|
+
|
|
101
|
+
### Session IDs
|
|
102
|
+
|
|
103
|
+
Each launched bastion gets a session ID for reconnection or termination.
|
|
104
|
+
|
|
105
|
+
### Default Behaviour
|
|
106
|
+
|
|
107
|
+
- Instances use **spot pricing** by default (use `--on-demand` for critical bastions)
|
|
108
|
+
- Linux instances **auto-terminate after 2 hours** by default
|
|
109
|
+
- Instances **terminate when the session ends** by default
|
|
110
|
+
|
|
111
|
+
### Tagging
|
|
112
|
+
|
|
113
|
+
| Tag | Value |
|
|
114
|
+
|----------------------|-------------------------------------------|
|
|
115
|
+
| `Name` | `bastion-[session-id]` |
|
|
116
|
+
| `bastion:session-id` | The session ID |
|
|
117
|
+
| `bastion:launched-by`| IAM identity of the launcher |
|
|
118
|
+
|
|
119
|
+
### IAM
|
|
120
|
+
|
|
121
|
+
Bastion CLI auto-creates an IAM policy, role, and instance profile named `BastionCliSessionManager` in the account with permissions for SSM messaging.
|
|
122
|
+
|
|
123
|
+
## Terminating
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
bastion terminate --session-id <session-id>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Cleans up the EC2 instance and any associated resources.
|
|
130
|
+
|
|
131
|
+
## Cancel Expiry
|
|
132
|
+
|
|
133
|
+
If you launched with default expiry and want to keep the instance running:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# On the bastion instance as root
|
|
137
|
+
atrm 1
|
|
138
|
+
```
|
docs/cfhighlander.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# cfhighlander
|
|
2
|
+
|
|
3
|
+
CloudFormation DSL and component library.
|
|
4
|
+
|
|
5
|
+
- **Source**: https://github.com/theonestack/cfhighlander
|
|
6
|
+
- **Language**: Ruby (gem)
|
|
7
|
+
- **Install**: `gem install cfhighlander`
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Cfhighlander is a feature-rich tool and DSL for infrastructure coders working with CloudFormation templates. It allows you to:
|
|
12
|
+
|
|
13
|
+
- Abstract AWS resources as **components** using cfhighlander DSL and cfndsl
|
|
14
|
+
- Produce, validate, and publish CloudFormation templates from those components
|
|
15
|
+
- Use **inheritance** and **composition** — components can be extended and built from other components
|
|
16
|
+
- Discover and consume components from git repos, file system, or S3 buckets
|
|
17
|
+
|
|
18
|
+
## CLI Commands
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
cfhighlander help # List all commands
|
|
22
|
+
cfhighlander cfcompile component[@version] -f FORMAT # Compile to CloudFormation
|
|
23
|
+
cfhighlander cfpublish component[@version] -f FORMAT # Compile and publish to S3
|
|
24
|
+
cfhighlander configcompile component[@version] # Compile configuration only
|
|
25
|
+
cfhighlander dslcompile component[@version] -f FORMAT # Compile to intermediate cfndsl
|
|
26
|
+
cfhighlander publish component[@version] [-v version] # Publish component source to S3
|
|
27
|
+
cfhighlander cftest component[@version] -f FORMAT # Run component tests
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### cfcompile
|
|
31
|
+
|
|
32
|
+
Produces CloudFormation templates in the specified format (defaults to yaml). Use `--validate` to validate against AWS. Output goes to `$WORKDIR/out/$format`.
|
|
33
|
+
|
|
34
|
+
### cfpublish
|
|
35
|
+
|
|
36
|
+
Compiles and publishes templates to S3. Supports `--dstbucket`, `--dstprefix`, `-v` for version. Provides a quick-launch CloudFormation URL.
|
|
37
|
+
|
|
38
|
+
### cftest
|
|
39
|
+
|
|
40
|
+
Runs test cases defined as `*.test.yaml` files in a `tests/` directory. Each test file is compiled and validated against the AWS CloudFormation API.
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
- `-d, --directory=DIRECTORY` — Tests directory (default: tests)
|
|
44
|
+
- `-t, --tests=LIST` — Specific test files
|
|
45
|
+
- `--validate / --no-validate` — Validate template (default: true)
|
|
46
|
+
- `-q, --quiet` — Silent mode for lambda packaging prompts
|
|
47
|
+
- `-r, --report=FORMAT` — Output report as json or xml
|
|
48
|
+
|
|
49
|
+
## Component Structure
|
|
50
|
+
|
|
51
|
+
A cfhighlander component consists of:
|
|
52
|
+
|
|
53
|
+
- `componentname.cfhighlander.rb` — Highlander DSL file (required)
|
|
54
|
+
- `*.config.yaml` — Configuration files (optional)
|
|
55
|
+
- `componentname.cfndsl.rb` — CfnDSL template (optional)
|
|
56
|
+
- `*.mappings.yaml` — CloudFormation mappings (optional)
|
|
57
|
+
- `componentname.mappings.rb` — Dynamic mappings (optional)
|
|
58
|
+
- `ext/cfndsl/*.rb` — Ruby extensions for cfndsl (optional)
|
|
59
|
+
|
|
60
|
+
## DSL Example
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
CfhighlanderTemplate do
|
|
64
|
+
# Explicit VPC configuration
|
|
65
|
+
vpc_config = { 'maximum_availability_zones' => 2 }
|
|
66
|
+
|
|
67
|
+
Component name: 'vpc',
|
|
68
|
+
template: 'vpc@master.snapshot',
|
|
69
|
+
config: vpc_config do
|
|
70
|
+
parameter name: 'DnsDomain', value: 'example.com'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Component name: 'ecs', template: 'ecs@master.snapshot' do
|
|
74
|
+
parameter name: 'DnsDomain', value: 'example.com'
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Component Library
|
|
80
|
+
|
|
81
|
+
Available at https://github.com/theonestack — auto-resolved from `hl-component-$name`:
|
|
82
|
+
|
|
83
|
+
- **vpc** — Public/private subnet separation, NAT gateways, route tables
|
|
84
|
+
- **ecs** — ECS Cluster in VPC compute subnets
|
|
85
|
+
- **bastion** — Bastion host in public subnets with IP whitelisting
|
|
86
|
+
- **ecs-service** — Containerised apps on ECS
|
|
87
|
+
- **loadbalancer** — ALB, ELB, or NLB
|
|
88
|
+
- **sns** — SNS topics with Slack integration
|
|
89
|
+
- **efs** — Elastic File System
|
|
90
|
+
- **rds-mysql** / **rds-postgres** — RDS instances
|
|
91
|
+
- **aurora-mysql** / **aurora-postgres** — Aurora clusters
|
|
92
|
+
- **elasticache-memcache** / **elasticache-redis** — ElastiCache
|
|
93
|
+
- **asg** — Auto Scaling Groups
|
|
94
|
+
- **cognito** — Cognito user pools and clients
|
|
95
|
+
|
|
96
|
+
## Component Sources
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
CfhighlanderTemplate do
|
|
100
|
+
Component name: 'vpc0', template: 'vpc' # default github
|
|
101
|
+
Component name: 'vpc1', template: 'github:theonestack/hl-component-vpc#master'
|
|
102
|
+
Component name: 'vpc3', template: 'git:https://github.com/theonestack/hl-component-sns.git'
|
|
103
|
+
Component name: 'vpc5', template: 'vpc@1.0.4' # version tag
|
|
104
|
+
end
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Configuration Hierarchy (lowest to highest priority)
|
|
108
|
+
|
|
109
|
+
1. Component local config (`component.config.yaml`)
|
|
110
|
+
2. Outer component config file (under `components` key)
|
|
111
|
+
3. Outer component explicit config (`config:` parameter)
|
|
112
|
+
4. Exported configuration from other components (`config_export`)
|
|
113
|
+
|
|
114
|
+
## Environment Variables
|
|
115
|
+
|
|
116
|
+
- `CFHIGHLANDER_WORKDIR` — Working directory for output (defaults to `$PWD`)
|
|
117
|
+
- `CFHIGHLANDER_AWS_RETRY_LIMIT` — AWS SDK retry limit (default: 10)
|
|
118
|
+
|
|
119
|
+
## Lambda Functions
|
|
120
|
+
|
|
121
|
+
Cfhighlander can package and deploy Lambda functions defined in config:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
functions:
|
|
125
|
+
myapp:
|
|
126
|
+
role: default
|
|
127
|
+
code: src/app.py
|
|
128
|
+
runtime: python3.6
|
|
129
|
+
handler: app.index
|
|
130
|
+
timeout: 30
|
|
131
|
+
package_cmd: 'pip3 install -r requirements.txt -t .'
|
|
132
|
+
log_retention: 30
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Render Modes
|
|
136
|
+
|
|
137
|
+
- **Substack** (default) — Creates nested CloudFormation stacks
|
|
138
|
+
- **Inline** — Inlines all resources into the parent template
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
CfhighlanderTemplate do
|
|
142
|
+
Component template: 'vpc@1.5.0', name: 'vpc', render: Inline
|
|
143
|
+
Component template: 'bastion@1.2.0', name: 'bastion', render: Substack
|
|
144
|
+
end
|
|
145
|
+
```
|
docs/cfn_vpn.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# cfn-vpn
|
|
2
|
+
|
|
3
|
+
AWS Client VPN management via CloudFormation.
|
|
4
|
+
|
|
5
|
+
- **Source**: https://github.com/base2Services/cfn-vpn
|
|
6
|
+
- **Language**: Ruby (gem)
|
|
7
|
+
- **Install**: `gem install cfn-vpn`
|
|
8
|
+
- **Docs**: https://base2services.github.io/cfn-vpn/
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
CfnVpn manages AWS Client VPN endpoints using CloudFormation. It handles the full lifecycle: initialization, modification, route management, user sessions, and teardown.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- AWS credentials configured
|
|
17
|
+
- ACM certificate for the VPN server
|
|
18
|
+
- VPC with subnets
|
|
19
|
+
|
|
20
|
+
## CLI Commands
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cfn-vpn help # List all commands
|
|
24
|
+
cfn-vpn help COMMAND # Help for specific command
|
|
25
|
+
|
|
26
|
+
# Initialize a new VPN
|
|
27
|
+
cfn-vpn init my-vpn \
|
|
28
|
+
--server-cn my-vpn.example.com \
|
|
29
|
+
--subnet-ids subnet-abc123 \
|
|
30
|
+
--region ap-southeast-2
|
|
31
|
+
|
|
32
|
+
# Modify VPN configuration
|
|
33
|
+
cfn-vpn modify my-vpn \
|
|
34
|
+
--region ap-southeast-2 \
|
|
35
|
+
--dns-servers 10.0.0.2
|
|
36
|
+
|
|
37
|
+
# Manage routes
|
|
38
|
+
cfn-vpn routes my-vpn \
|
|
39
|
+
--region ap-southeast-2
|
|
40
|
+
|
|
41
|
+
# View active sessions
|
|
42
|
+
cfn-vpn sessions my-vpn \
|
|
43
|
+
--region ap-southeast-2
|
|
44
|
+
|
|
45
|
+
# Generate client config
|
|
46
|
+
cfn-vpn client my-vpn \
|
|
47
|
+
--region ap-southeast-2
|
|
48
|
+
|
|
49
|
+
# Embed client config in browser
|
|
50
|
+
cfn-vpn embedded my-vpn \
|
|
51
|
+
--region ap-southeast-2
|
|
52
|
+
|
|
53
|
+
# Delete VPN
|
|
54
|
+
cfn-vpn delete my-vpn \
|
|
55
|
+
--region ap-southeast-2
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Commands
|
|
59
|
+
|
|
60
|
+
### init
|
|
61
|
+
|
|
62
|
+
Creates a new Client VPN endpoint with CloudFormation. Requires:
|
|
63
|
+
- `--server-cn` — Common name for the server certificate
|
|
64
|
+
- `--subnet-ids` — VPC subnet(s) to associate
|
|
65
|
+
- `--region` — AWS region
|
|
66
|
+
|
|
67
|
+
Optional:
|
|
68
|
+
- `--dns-servers` — Custom DNS servers
|
|
69
|
+
- `--split-tunnel` — Enable split tunneling
|
|
70
|
+
- `--protocol` — `udp` (default) or `tcp`
|
|
71
|
+
- `--cidr` — Client CIDR block (default: `10.250.0.0/16`)
|
|
72
|
+
|
|
73
|
+
### modify
|
|
74
|
+
|
|
75
|
+
Updates an existing VPN's CloudFormation stack with new parameters.
|
|
76
|
+
|
|
77
|
+
### routes
|
|
78
|
+
|
|
79
|
+
Manages VPN authorization and routing rules. Add or remove routes to VPC subnets or external networks.
|
|
80
|
+
|
|
81
|
+
### sessions
|
|
82
|
+
|
|
83
|
+
Lists active VPN sessions, showing connected users and connection details.
|
|
84
|
+
|
|
85
|
+
### client
|
|
86
|
+
|
|
87
|
+
Generates an OpenVPN client configuration file for connecting to the VPN.
|
|
88
|
+
|
|
89
|
+
### delete
|
|
90
|
+
|
|
91
|
+
Tears down the VPN by deleting the CloudFormation stack and associated resources.
|
|
92
|
+
|
|
93
|
+
## Authentication Methods
|
|
94
|
+
|
|
95
|
+
- **Mutual TLS** — Client and server certificates (default)
|
|
96
|
+
- **AWS SSO / SAML** — Federated authentication
|
|
97
|
+
- **Active Directory** — AWS Directory Service integration
|