imbi-plugin-aws 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 (32) hide show
  1. imbi_plugin_aws-0.1.0/.github/workflows/publish.yml +45 -0
  2. imbi_plugin_aws-0.1.0/.github/workflows/test.yml +54 -0
  3. imbi_plugin_aws-0.1.0/.gitignore +10 -0
  4. imbi_plugin_aws-0.1.0/.pre-commit-config.yaml +36 -0
  5. imbi_plugin_aws-0.1.0/LICENSE +28 -0
  6. imbi_plugin_aws-0.1.0/PKG-INFO +99 -0
  7. imbi_plugin_aws-0.1.0/PLAN.md +967 -0
  8. imbi_plugin_aws-0.1.0/README.md +80 -0
  9. imbi_plugin_aws-0.1.0/justfile +59 -0
  10. imbi_plugin_aws-0.1.0/pyproject.toml +122 -0
  11. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/__init__.py +21 -0
  12. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/_helpers.py +31 -0
  13. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/account_resolution.py +138 -0
  14. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/aws_session.py +324 -0
  15. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/cloudwatch.py +1071 -0
  16. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/errors.py +42 -0
  17. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/identity.py +633 -0
  18. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/log_groups.py +137 -0
  19. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/models.py +35 -0
  20. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/query.py +219 -0
  21. imbi_plugin_aws-0.1.0/src/imbi_plugin_aws/ssm.py +409 -0
  22. imbi_plugin_aws-0.1.0/tests/__init__.py +0 -0
  23. imbi_plugin_aws-0.1.0/tests/test_account_resolution.py +124 -0
  24. imbi_plugin_aws-0.1.0/tests/test_aws_session.py +311 -0
  25. imbi_plugin_aws-0.1.0/tests/test_cloudwatch.py +1143 -0
  26. imbi_plugin_aws-0.1.0/tests/test_error_inheritance.py +41 -0
  27. imbi_plugin_aws-0.1.0/tests/test_identity.py +567 -0
  28. imbi_plugin_aws-0.1.0/tests/test_log_groups.py +142 -0
  29. imbi_plugin_aws-0.1.0/tests/test_models.py +36 -0
  30. imbi_plugin_aws-0.1.0/tests/test_query.py +138 -0
  31. imbi_plugin_aws-0.1.0/tests/test_ssm.py +345 -0
  32. imbi_plugin_aws-0.1.0/uv.lock +1993 -0
@@ -0,0 +1,45 @@
1
+ name: Publish to PyPI
2
+ on:
3
+ release:
4
+ types: [published]
5
+
6
+ permissions:
7
+ id-token: write
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout repository
14
+ uses: actions/checkout@v6
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v5
20
+
21
+ - name: Set up Python
22
+ run: uv python install 3.14
23
+
24
+ - name: Build
25
+ run: uv build
26
+
27
+ - name: Upload dist
28
+ uses: actions/upload-artifact@v4
29
+ with:
30
+ name: dist
31
+ path: dist/
32
+
33
+ publish:
34
+ needs: build
35
+ runs-on: ubuntu-latest
36
+ environment: pypi
37
+ steps:
38
+ - name: Download dist
39
+ uses: actions/download-artifact@v4
40
+ with:
41
+ name: dist
42
+ path: dist/
43
+
44
+ - name: Publish package
45
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,54 @@
1
+ name: Testing
2
+ on:
3
+ pull_request:
4
+ push:
5
+ branches: [ "main" ]
6
+ paths-ignore:
7
+ - 'docs/**'
8
+ - '*.md'
9
+ tags-ignore: [ "*" ]
10
+
11
+ jobs:
12
+ lint:
13
+ name: "Static Analysis"
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v5
18
+ - name: Install just
19
+ uses: extractions/setup-just@v2
20
+ with:
21
+ just-version: '1.47.1'
22
+ - name: Install uv
23
+ uses: astral-sh/setup-uv@v7
24
+ with:
25
+ enable-cache: true
26
+ - name: Run linters
27
+ run: just lint
28
+
29
+ test:
30
+ name: "Automated Tests"
31
+ runs-on: ubuntu-latest
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ python: [ "3.14" ]
36
+ steps:
37
+ - name: Checkout repository
38
+ uses: actions/checkout@v5
39
+ - name: Install just
40
+ uses: extractions/setup-just@v2
41
+ with:
42
+ just-version: '1.47.1'
43
+ - name: Install uv
44
+ uses: astral-sh/setup-uv@v7
45
+ with:
46
+ python-version: "${{ matrix.python }}"
47
+ enable-cache: true
48
+ - name: Test with python ${{ matrix.python }}
49
+ run: just test
50
+ - name: Upload Coverage
51
+ uses: codecov/codecov-action@v5
52
+ with:
53
+ files: ./build/coverage.xml
54
+ flags: unittests
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .pytest_cache/
5
+ .coverage
6
+ htmlcov/
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ .ruff_cache/
@@ -0,0 +1,36 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-added-large-files
9
+ - id: check-merge-conflict
10
+ - id: check-toml
11
+ - id: debug-statements
12
+
13
+ - repo: https://github.com/astral-sh/ruff-pre-commit
14
+ rev: v0.14.6
15
+ hooks:
16
+ - id: ruff-check
17
+ args: [--fix]
18
+ - id: ruff-format
19
+
20
+ - repo: https://github.com/tombi-toml/tombi-pre-commit
21
+ rev: v0.7.25
22
+ hooks:
23
+ - id: tombi-format
24
+
25
+ - repo: local
26
+ hooks:
27
+ - id: basedpyright
28
+ name: basedpyright
29
+ language: system
30
+ types: [python]
31
+ pass_filenames: false
32
+ entry: uv
33
+ args:
34
+ - run
35
+ - basedpyright
36
+ - src
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Imbi
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: imbi-plugin-aws
3
+ Version: 0.1.0
4
+ Summary: AWS plugins for Imbi (IAM Identity Center, SSM, CloudWatch Logs)
5
+ Author-email: "Gavin M. Roy" <gavinr@aweber.com>
6
+ License: BSD-3-Clause
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Natural Language :: English
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Python: >=3.14
15
+ Requires-Dist: httpx<1,>=0.27
16
+ Requires-Dist: imbi-common>=0.8.3
17
+ Requires-Dist: pydantic>=2
18
+ Description-Content-Type: text/markdown
19
+
20
+ # imbi-plugin-aws
21
+
22
+ AWS provider for the Imbi project logs and configuration tabs.
23
+
24
+ ## Plugins shipped
25
+
26
+ This package ships (or will ship) three entry points from one
27
+ distribution:
28
+
29
+ | Slug | Type | Status |
30
+ | ---------------------- | --------------- | -------- |
31
+ | `aws-iam-ic` | `identity` | ✅ shipped |
32
+ | `aws-ssm` | `configuration` | planned |
33
+ | `aws-cloudwatch-logs` | `logs` | planned |
34
+
35
+ The identity plugin federates each Imbi user into AWS via IAM Identity
36
+ Center (formerly AWS SSO) and mints short-lived STS credentials per
37
+ call. The data plugins (when shipped) consume those credentials
38
+ transparently — see the contract below.
39
+
40
+ ## Identity consumption contract for the data plugins
41
+
42
+ When a project's `(:Project)-[:USES_PLUGIN]->(:Plugin)` edge or
43
+ project-type fallback names this package's `aws-iam-ic` plugin via the
44
+ `identity_plugin_id` edge property, the host-side
45
+ `hydrate_identity()` helper runs `aws-iam-ic.materialize()` *before*
46
+ calling the data plugin's handler. `materialize()` calls
47
+ `GetRoleCredentials` against the IAM IC Portal API and returns
48
+ short-lived STS keys in `IdentityCredentials.extra`:
49
+
50
+ ```python
51
+ IdentityCredentials(
52
+ access_token=<unchanged IAM IC token>,
53
+ extra={
54
+ 'aws_access_key_id': 'AKIA...',
55
+ 'aws_secret_access_key': '...',
56
+ 'aws_session_token': '...',
57
+ 'aws_region': 'us-east-1',
58
+ 'aws_account_id': '111111111111',
59
+ },
60
+ )
61
+ ```
62
+
63
+ The host attaches this to `PluginContext.identity` and the data plugins
64
+ read it from there. Concretely, when `aws-ssm` (or
65
+ `aws-cloudwatch-logs`) is invoked:
66
+
67
+ ```python
68
+ async def list_keys(self, ctx, credentials):
69
+ if ctx.identity is not None:
70
+ # IAM IC path: credentials dict is empty (no operator-supplied
71
+ # static keys); read STS from ctx.identity.extra.
72
+ aws_creds = ctx.identity.extra
73
+ else:
74
+ # Static-key path: ServiceApplication.plugin_credentials carries
75
+ # access_key_id / secret_access_key / session_token.
76
+ aws_creds = credentials
77
+ session = aiobotocore.session.get_session()
78
+ client = session.create_client(
79
+ 'ssm',
80
+ region_name=aws_creds['aws_region'],
81
+ aws_access_key_id=aws_creds['aws_access_key_id'],
82
+ aws_secret_access_key=aws_creds['aws_secret_access_key'],
83
+ aws_session_token=aws_creds.get('aws_session_token'),
84
+ )
85
+ ...
86
+ ```
87
+
88
+ The data plugin doesn't know whether the caller is federated (via
89
+ `aws-iam-ic`) or running as a service principal (legacy
90
+ `ServiceApplication.plugin_credentials`). Same five well-known keys,
91
+ sourced differently.
92
+
93
+ `requires_identity=true` on a future logs/configuration manifest would
94
+ make the federated path mandatory; today both plugins fall back to the
95
+ service-principal credentials when no `ctx.identity` is set.
96
+
97
+ ## License
98
+
99
+ BSD-3-Clause.