You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ADDING_FEATURES.md
+202Lines changed: 202 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Guide for contributors who want to add new frameworks, model servers, or other f
8
8
-[Adding a New Model Server](#adding-a-new-model-server)
9
9
-[Adding a New Test Type](#adding-a-new-test-type)
10
10
-[Adding a New Deployment Target](#adding-a-new-deployment-target)
11
+
-[Adding a New Secret Type](#adding-a-new-secret-type)
11
12
-[Testing Your Changes](#testing-your-changes)
12
13
13
14
---
@@ -506,6 +507,207 @@ if (this.answers.deployTarget === 'lambda') {
506
507
507
508
---
508
509
510
+
## Adding a New Secret Type
511
+
512
+
The secrets system uses a registry-driven architecture. Adding a newsecret type requires only adding an entry to the `Secret_Classification` registry — the CLI, prompt flow, and do-script templates derive behavior from this registry automatically.
513
+
514
+
Let's walk through adding support for a private PyPI token used during build-time `pip install`.
515
+
516
+
### Understanding the Registry
517
+
518
+
The `Secret_Classification` registry lives at `src/lib/secret-classification.js`. Each entry defines all metadata needed for end-to-end integration:
No IAM changes are needed as long as your new secret follows the `mlcc/<type>/<label>` naming convention. The policy grants access to any secret under the `mlcc/` prefix that carries the `mlcc:managed-by` tag.
650
+
651
+
### Tagging Schema
652
+
653
+
Every secret created by the CLI automatically receives these tags:
654
+
655
+
| Tag Key | Value | Purpose |
656
+
|---------|-------|---------|
657
+
| `mlcc:managed-by` | `ml-container-creator` | Identifies mlcc-managed secrets for IAM scoping |
658
+
| `mlcc:created-by` | `secrets` | Identifies the creation source |
659
+
| `mlcc:secret-type` | `<identifier>` (e.g., `pypi-token`) | Links to the Secret_Classification entry |
660
+
661
+
These tags are applied automatically by the `SecretsCommandHandler` and cannot be overridden by the user. If a user provides conflicting `mlcc:` tags via `--json`, the system values take precedence and a warning is displayed.
662
+
663
+
### Naming Convention
664
+
665
+
All managed secrets follow the pattern:
666
+
667
+
```
668
+
mlcc/<secret-type>/<user-provided-label>
669
+
```
670
+
671
+
Examples:
672
+
- `mlcc/hf-token/production`
673
+
- `mlcc/ngc-token/team-shared`
674
+
- `mlcc/pypi-token/ci-pipeline`
675
+
676
+
This naming convention maps directly to the IAM policy resource pattern `arn:aws:secretsmanager:*:*:secret:mlcc/*`, ensuring that any new secret type is automatically covered without IAM policy changes.
677
+
678
+
### Step 5: Add Tests
679
+
680
+
Add a test verifying the new entry has all required fields in `test/property/secret-classification-completeness.property.test.js` (the existing property test validates all entries automatically).
681
+
682
+
Add unit tests for the new do-script resolution logic in `test/unit/secrets-template-output.test.js`.
683
+
684
+
### Validation Checklist
685
+
686
+
After adding a new secret type, verify:
687
+
688
+
- [ ] The new type appears in `secrets create` interactive type selection prompt
689
+
- [ ] `secrets create --type <new-type> --name test --secret-value xxx` creates a secret with the correct name (`mlcc/<type>/test`)
690
+
- [ ] The prompt flow lists managed secrets of the new type during project generation
691
+
- [ ] Do-scripts resolve the secret at the correct stage (build-time, runtime, or both)
692
+
- [ ] The IAM policy covers the new naming path (automatic if using `mlcc/` prefix)
693
+
- [ ] Mutual exclusion validation rejects both `--<type>` and `--<type>-arn` flags together
694
+
- [ ] The `do/config` template exports the correct `_ARN` variable when an ARN is configured
695
+
- [ ] Existing plaintext flows remain unchanged when no ARN is provided
696
+
- [ ] All property tests pass (`npm test`)
697
+
698
+
### Files to Update Summary
699
+
700
+
| File | Change |
701
+
|------|--------|
702
+
| `src/lib/secret-classification.js` | Add new entry to `SECRET_CLASSIFICATIONS` array |
0 commit comments