iam-floyd 0.847.0 → 0.849.0

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 (51) hide show
  1. package/.markdownlint-cli2.yaml +16 -0
  2. package/.prettierignore +5 -0
  3. package/.yamllint.yaml +13 -0
  4. package/AGENTS.md +64 -16
  5. package/README.md +170 -46
  6. package/doc8.ini +3 -0
  7. package/dotnet/src/IAM.Floyd/IAM.Floyd.csproj +36 -0
  8. package/dotnet/src/IAM.Floyd/Js.cs +272 -0
  9. package/dotnet/src/IAM.Floyd/Json.cs +151 -0
  10. package/eslint.config.mjs +123 -0
  11. package/go/iamfloyd/go.mod +3 -0
  12. package/go/iamfloyd/helpers.go +25 -0
  13. package/go/iamfloyd/internal/js/collections.go +219 -0
  14. package/go/iamfloyd/internal/js/json.go +95 -0
  15. package/go/iamfloyd/internal/js/strings.go +150 -0
  16. package/go/iamfloyd/internal/js/values.go +251 -0
  17. package/java/pom.xml +140 -0
  18. package/java/src/main/java/com/udondan/iamFloyd/Js.java +210 -0
  19. package/java/src/main/java/com/udondan/iamFloyd/Json.java +137 -0
  20. package/lib/collection/allowEc2InstanceDeleteByOwner.d.ts +2 -2
  21. package/lib/collection/allowEc2InstanceDeleteByOwner.js +3 -3
  22. package/lib/collection/index.d.ts +2 -1
  23. package/lib/shared/compact.d.ts +12 -0
  24. package/lib/shared/compact.js +121 -0
  25. package/lib/shared/policy-statement/1-base.d.ts +0 -6
  26. package/lib/shared/policy-statement/1-base.js +0 -7
  27. package/lib/shared/policy-statement/10-final.d.ts +0 -1
  28. package/lib/shared/policy-statement/10-final.js +24 -5
  29. package/lib/shared/policy-statement/2-conditions.d.ts +1 -11
  30. package/lib/shared/policy-statement/2-conditions.js +9 -70
  31. package/lib/shared/policy-statement/3-actions.d.ts +7 -9
  32. package/lib/shared/policy-statement/3-actions.js +61 -109
  33. package/lib/shared/policy-statement/4-resources.d.ts +4 -10
  34. package/lib/shared/policy-statement/4-resources.js +2 -44
  35. package/lib/shared/policy-statement/5-effect.d.ts +0 -6
  36. package/lib/shared/policy-statement/5-effect.js +0 -8
  37. package/lib/shared/policy-statement/8-principals.d.ts +0 -9
  38. package/lib/shared/policy-statement/8-principals.js +0 -23
  39. package/lint/checkstyle-suppressions.xml +16 -0
  40. package/lint/go.mod +28 -0
  41. package/lint/go.sum +45 -0
  42. package/lint/pom.xml +43 -0
  43. package/lint/requirements.txt +6 -0
  44. package/package.json +17 -27
  45. package/python/iam_floyd/__init__.py +42 -0
  46. package/python/iam_floyd/_js.py +104 -0
  47. package/python/iam_floyd/py.typed +0 -0
  48. package/python/pyproject.toml +39 -0
  49. package/ruff.toml +11 -0
  50. package/skills/iam-floyd-usage/SKILL.md +4 -3
  51. package/.eslintrc +0 -31
@@ -0,0 +1,16 @@
1
+ config:
2
+ # Long lines are wrapped by the reader
3
+ MD013: false
4
+ # Line breaks in tables and the collapsible examples per language in README.md
5
+ MD033:
6
+ allowed_elements: [br, details, summary]
7
+ # gofmt indents with tabs
8
+ MD010:
9
+ ignore_code_languages: [go]
10
+ globs:
11
+ - "**/*.md"
12
+ ignores:
13
+ - "**/node_modules/**"
14
+ - CHANGELOG.md
15
+ - dist/**
16
+ - java/target/**
@@ -0,0 +1,5 @@
1
+ # Generated
2
+ CHANGELOG.md
3
+ lib/generated/
4
+ docs/source/_static/managed-policies/
5
+ docs/source/_static/policy-converter/
package/.yamllint.yaml ADDED
@@ -0,0 +1,13 @@
1
+ extends: default
2
+
3
+ ignore-from-file: .gitignore
4
+
5
+ rules:
6
+ # Prettier formats the files and wraps long lines where it can
7
+ line-length: disable
8
+ comments:
9
+ min-spaces-from-content: 1
10
+ document-start: disable
11
+ truthy:
12
+ # `on` is a key in GitHub workflows
13
+ check-keys: false
package/AGENTS.md CHANGED
@@ -16,13 +16,13 @@ IAM Floyd is an AWS IAM policy statement generator with a fluent interface. It g
16
16
  - `lib/generated/aws-managed-policies/` - Generated AWS managed policies (committed)
17
17
  - `lib/shared/` - Hand-written core: `PolicyStatement`, `All`, `Operator`, `AccessLevel`
18
18
  - `lib/collection/` - Predefined policy collection utilities
19
- - `lib/generator/` - Scrapes AWS docs with `cheerio` into the model (`model.ts`), and emits TypeScript from the model with `ts-morph` (`emit/typescript.ts`)
19
+ - `lib/generator/` - Scrapes AWS docs with `cheerio` into the model (`model.ts`), and emits TypeScript from the model with `ts-morph` (`emit/typescript.ts`), and the index of the policy converter (`emit/converter.ts`)
20
20
 
21
21
  ### PolicyStatement Inheritance Chain
22
22
 
23
23
  Built in 10 numbered layers (`lib/shared/policy-statement/`):
24
24
 
25
- ```
25
+ ```text
26
26
  1-base → 2-conditions → 3-actions → 4-resources → 5-effect
27
27
  → 6-arn-defaults → 8-principals → 10-final (PolicyStatement)
28
28
  ```
@@ -44,7 +44,33 @@ One codebase produces two npm packages:
44
44
 
45
45
  `test/jsii/` builds `floyd-consumer`, a jsii library that depends on `cdk-iam-floyd`, and runs the same scenarios in TypeScript (the baseline, without jsii), Python, Java, .NET and Go against `test/jsii/expected.json`. It also runs the examples of the docs in each language (`examples/<name>/<name>.{py,java,cs,go}`, through the runners in `test/jsii/examples/`) and compares them to the `.result` files. Every example needs a file in every language.
46
46
 
47
- Publishing: the npm package of `cdk-iam-floyd` includes the `.jsii` (`make package-jsii publish LANGUAGES=typescript`), Python goes to PyPI and .NET to NuGet (both trusted publishing), Java to Maven Central (`bin/publish-maven`, signed bundle via the Central Portal API). Go has no registry: `bin/go-proxy` writes the module zip, which is attached to the GitHub release, and a static Go module proxy for the newest 30 releases, served by GitHub Pages under `udondan.github.io/iam-floyd/go`.
47
+ Publishing: the npm package of `cdk-iam-floyd` includes the `.jsii` (`make package-jsii publish LANGUAGES=typescript`), Python goes to PyPI and .NET to NuGet (both trusted publishing), Java to Maven Central (`bin/publish-maven`, signed bundle via the Central Portal API). Go has no registry: `bin/go-proxy` writes the module zip, which is attached to the GitHub release, and a static Go module proxy of both modules (`cdkiamfloyd` and the native `iamfloyd`) for the newest 30 releases, served by GitHub Pages under `udondan.github.io/iam-floyd/go` (job `publish-go-proxy`).
48
+
49
+ ### Native Packages (transpiled core)
50
+
51
+ The standalone `iam-floyd` is being built natively for other languages, without jsii and without Node.js. The hand-written code in `lib/shared/` (the core) and `lib/collection/`, and the names of the AWS managed policies (`lib/generated/aws-managed-policies/iam-floyd.ts`), are transpiled with ts-morph by `lib/generator/transpile/` (`index.ts` collects the files of a module in import order, one backend per language: `python.ts`, `java.ts`, `csharp.ts`, `go.ts`). The only imports from outside a module are the generated service classes, imported from their file (e.g. `../generated/policy-statements/ec2`). The transpiler supports only a narrow subset of TypeScript: anything else fails with file and line, so rewrite the code in supported constructs rather than extending the transpiler for single cases. The service classes are emitted from the model by `lib/generator/emit/python.ts`, with the jsii naming rules (snake_case, `if_`, `in_`), into the package `statement/`, which imports a service on first access. `bin/transpile.ts` writes `python/iam_floyd/_shared.py`, `_collection.py`, `_aws_managed_policies.py` and `statement/` (not committed). The package imports the collection and the managed policies on first access. `python/iam_floyd/_js.py` is the hand-written runtime for JavaScript semantics (number formatting, `toISOString`, sorting by UTF-16 code units, regular expressions).
52
+
53
+ Java: the core, the collection and `AwsManagedPolicy` go to the package `com.udondan.iamFloyd`, the service classes (emitted by `lib/generator/emit/java.ts`) and `All` to `com.udondan.iamFloyd.statement`, in `java/src/main/java/` (not committed, except the hand-written runtime `Js.java` and `Json.java`, which writes the JSON like `JSON.stringify`). The classes of the statement are generic (`PolicyStatement<T extends PolicyStatement<T>>`, `Ec2 extends PolicyStatement<Ec2>`), so the fluent methods return the class itself. Optional parameters and union types become overloads, reserved words get a prefix (`doIf`, `doFor`), static properties become constants (`Operator.STRING_EQUALS`).
54
+
55
+ C#: the core, the collection and `AwsManagedPolicy` go to the namespace `IAM.Floyd`, the service classes (emitted by `lib/generator/emit/csharp.ts`) and `All` to `IAM.Floyd.Statement`, in `dotnet/src/IAM.Floyd/` (not committed, except the project `IAM.Floyd.csproj` and the hand-written runtime `Js.cs` and `Json.cs`). Like in Java, the classes of the statement are generic (`PolicyStatement<T> where T : PolicyStatement<T>`, `Ec2 : PolicyStatement<Ec2>`), optional parameters and union types become overloads and static properties constants. Names are PascalCase (`If`, `For`, `ToJSON`), public fields become properties (`Sid`), and the service classes hide methods of the core with the same name with `new` (e.g. `IfAwsRequestTag`).
56
+
57
+ Go: the module `udondan.github.io/iam-floyd/go/iamfloyd` in `go/iamfloyd/` (not committed, except `go.mod`, the hand-written helpers `helpers.go` (`String`, `Strings`, `Number`, `Bool`) and the runtime in `internal/js/`). The core and `AwsManagedPolicy` go to the package `iamfloyd`, the collection to `collection`, the service classes (emitted by `lib/generator/emit/go.ts`) and `All` to `statement`. Inheritance becomes embedding of generic structs (`PolicyStatement[T]`, `type Ec2 struct{ iamfloyd.PolicyStatement[*Ec2] }`) with an `InitX` function per class, and the fluent methods return `T`. Parameters are pointers like in jsii (`*string`, `*[]*string`), optional ones are `nil`, union types `interface{}`. Static properties become constants (`Operator_STRING_EQUALS`), the classes with `toJSON` implement `MarshalJSON`. `bin/transpile.ts` runs `gofmt` on the output.
58
+
59
+ `test/transpile/` runs the scenarios against TypeScript (the baseline) and each language, and diffs the output: those of `scenarios.json`, which test the core, and those that `services.ts` builds from the model, which call every method of every service. Then it runs the examples of the docs (`examples/<name>/<name>.{py,java,cs,go}`) with the native package, through `python/examples.py`, which runs them with `iam_floyd` in place of `cdk_iam_floyd`, `java/Examples.java`, which compiles them with `com.udondan.iamFloyd` and a stand-in of the `PolicyDocument` of the AWS CDK (`java/stubs/`), `dotnet/` (`run.sh` rewrites them for `IAM.Floyd`, the project compiles them with a stand-in of the `PolicyDocument` in `Stubs.cs`) and `go/` (`run.sh` rewrites them for `iamfloyd` and the stand-in `awsiam`, and writes `registry.go` with `registry.ts`, as Go cannot look up classes and constants by name), and compares them to the `.result` files with `test/jsii/examples/compare.py --standalone`, which skips the `*.cdk` examples. Last, it compares the AWS managed policies with those of TypeScript.
60
+
61
+ The Python package is built with hatchling from `python/pyproject.toml`; `bin/transpile.ts` writes the version of package.json into `iam_floyd/_version.py`. It supports Python 3.9 and newer, and has no dependencies at runtime. CI builds it and tests the wheel with the oldest and the newest supported Python; for a release, the tested wheel and sdist go to PyPI as `iam-floyd` (trusted publishing, job `publish-iam-floyd-python`).
62
+
63
+ The Java package is built with Maven from `java/pom.xml` (`-Drevision=<version of package.json>`), with `--release 11`, into the Maven repository `dist/iam-floyd/java`. CI builds it with the newest Java LTS and tests the jar with Java 11 and the newest LTS; for a release, `bin/publish-maven dist/iam-floyd/java` publishes it to Maven Central as `com.udondan:iam-floyd` (job `publish-iam-floyd-java`).
64
+
65
+ The .NET package is built with `dotnet pack` from `dotnet/src/IAM.Floyd/IAM.Floyd.csproj` (`-p:Version=<version of package.json>`), for .NET 8, into `dist/iam-floyd/dotnet`. CI builds it with the newest .NET SDK and tests the package with .NET 8 and the newest .NET (`DOTNET_PACKAGES`, `DOTNET_FRAMEWORK`); for a release, it goes to NuGet as `IAM.Floyd` (trusted publishing, job `publish-iam-floyd-dotnet`).
66
+
67
+ The Go module is zipped by `bin/go-proxy zip` into `dist/iam-floyd/go`, with the LICENSE. It supports Go 1.21 and newer, and has no dependencies. CI tests the zip with Go 1.21 and the newest Go (`GO_MODULE`); for a release, the zip is attached to the GitHub release (job `publish-iam-floyd-go`) and served by the Go module proxy.
68
+
69
+ ### Policy Converter
70
+
71
+ The policy converter of the docs (`docs/source/policy-converter.rst`) converts an IAM policy to IAM Floyd code in TypeScript, JavaScript, Python, Java, C# and Go, for both variants. The conversion is in `docs/source/_static/js/converter.js`, without dependencies, which runs in the browser and in Node.js; `policy-converter.js` is the UI. It knows the classes and actions from `docs/source/_static/policy-converter/services.json`, which `lib/generator/emit/converter.ts` writes from the model on `make emit` and `make generate` (committed, as Read the Docs builds the docs without Node.js).
72
+
73
+ `test/converter/cases.ts` converts the policies of `test/converter/policies/` and all AWS managed policies to JavaScript, runs the code against `lib/` and checks that the policy allows and denies the same as the input. Then it writes the code of the other languages as examples (`converter-<name>`) with their `.result` into a copy of `examples/`, which `test/transpile/run.sh` (Standalone) and `test/jsii/run.sh` (CDK) run with the other examples.
48
74
 
49
75
  ## Development Commands
50
76
 
@@ -54,6 +80,7 @@ Publishing: the npm package of `cdk-iam-floyd` includes the `.jsii` (`make packa
54
80
  make emit # emit lib/generated/policy-statements/ and lib/generated/index.ts from the model
55
81
  make build # emit + tsc --build --force tsconfig.main.json tsconfig.types.json
56
82
  make package # build + npm pack
83
+ make package-native # transpile and build the native packages of iam-floyd into dist/iam-floyd/ (Python: uv build, Java: mvn, .NET: dotnet pack, Go: module zip); LANGUAGES=python limits the languages
57
84
  make clean # remove node_modules, *.js, *.d.ts
58
85
  make install # clean + npm i
59
86
  ```
@@ -75,11 +102,12 @@ make changelog # print the changes of the managed policies and the model s
75
102
  The project has **no unit test framework**. Tests are integration-style: TypeScript examples are compiled, run, and their output is diffed against stored `.result` files.
76
103
 
77
104
  ```bash
78
- make test # compile examples/ + diff against *.result files (standalone)
79
- make test-typescript # same, via Test.TypeScript.Makefile
80
- make cdk-test # CDK test: real deploy + destroy via AWS CDK
81
- make cdk-all # cdk + install + build + cdk-test
82
- make test-jsii # test the packages of `make package-jsii` against TypeScript; LANGUAGES=python limits the languages
105
+ make test-typescript # compile examples/ + diff against *.result files (standalone)
106
+ make test-typescript-cdk # after `make cdk`: same for the CDK examples (examples/**/*.cdk.ts)
107
+ make cdk-test # CDK test: real deploy + destroy via AWS CDK
108
+ make cdk-all # cdk + install + build + cdk-test
109
+ make test-jsii # test the packages of `make package-jsii` against TypeScript; LANGUAGES=python limits the languages
110
+ make test-transpile # transpile, compare the scenarios of test/transpile/ with TypeScript and run the examples; PYTHON_WHEEL=<wheel>, JAVA_JAR=<jar>, DOTNET_PACKAGES=<dir of the nupkg> and GO_MODULE=<zip> test the built packages
83
111
  ```
84
112
 
85
113
  **Run a single example test manually:**
@@ -91,9 +119,6 @@ npx tsc -p tsconfig.test-iam-floyd.json
91
119
  # 2. Run and compare output
92
120
  node examples/allow/allow.js > /tmp/out.txt
93
121
  diff /tmp/out.txt examples/allow/allow.result
94
-
95
- # Or run the integration test harness directly:
96
- npx ts-node test/main.ts
97
122
  ```
98
123
 
99
124
  **Regenerate expected results** (after intentional changes):
@@ -105,9 +130,32 @@ make regenerate-code-example-results
105
130
  ### Linting
106
131
 
107
132
  ```bash
108
- make eslint # npx eslint .
133
+ make lint # emit + bin/lint: all linters, must pass in CI
134
+ make lint-fix # emit + bin/lint --fix: fixes what can be fixed
135
+ make lint-cdk # after `make cdk`: eslint on the CDK variant
109
136
  ```
110
137
 
138
+ `bin/lint` runs:
139
+
140
+ | Linter | Files |
141
+ | ---------------------------- | ------------------------------------------------------- |
142
+ | eslint (`eslint.config.mjs`) | TypeScript and JavaScript, with types |
143
+ | prettier | everything prettier knows, except `.prettierignore` |
144
+ | markdownlint-cli2 | Markdown |
145
+ | exact versions | the dependencies of all `package.json` files |
146
+ | ruff, ruff format | Python (`ruff.toml`, the examples are not formatted) |
147
+ | yamllint | YAML (`.yamllint.yaml`) |
148
+ | doc8 | reStructuredText in `docs/source` (`doc8.ini`) |
149
+ | zizmor, actionlint | GitHub workflows |
150
+ | shellcheck, shfmt | shell scripts, found by their shebang |
151
+ | gofmt | Go |
152
+ | dotnet format whitespace | C# in `examples/`, `test/` and the runtime of `dotnet/` |
153
+ | checkstyle (Google style) | Java in `examples/` and `test/jsii/` (`lint/pom.xml`) |
154
+
155
+ The versions of the linters are pinned, so Renovate updates them: npm packages in `package.json`, Python tools in `lint/requirements.txt` (run with `uv`), Go tools in `lint/go.mod` (`go tool`) and checkstyle in `lint/pom.xml`. Locally, linters whose runtime (uv, Go, .NET, Maven) is missing are skipped; in CI they fail. In the CDK variant, eslint uses `tsconfig.lint-cdk.json`, which resolves `cdk-iam-floyd` to `lib/`, and prettier is off because `mkcdk` writes unformatted code.
156
+
157
+ The actions in the workflows are pinned to commit SHAs with the version as comment.
158
+
111
159
  ### CDK Variant
112
160
 
113
161
  ```bash
@@ -177,13 +225,13 @@ Allowed manual edits:
177
225
  - **No trailing whitespace**
178
226
  - Line endings: LF (`\n`)
179
227
 
180
- Run `make eslint` to check; Prettier is enforced via `eslint-plugin-prettier`.
228
+ Run `make lint` to check; Prettier is enforced via `eslint-plugin-prettier` and for the other files by `bin/lint`. `.editorconfig` sets 4 spaces for Python and C#, and tabs for Go.
181
229
 
182
230
  ### TypeScript
183
231
 
184
232
  Strict settings enforced in `tsconfig.json`:
185
233
 
186
- ```
234
+ ```text
187
235
  strict: true
188
236
  noImplicitAny: true
189
237
  strictNullChecks: true
@@ -198,7 +246,7 @@ target: ES2020, module: CommonJS
198
246
  - **Unused vars**: Prefix with `_` to suppress (`argsIgnorePattern: ^_`).
199
247
  - **Naming conventions**: Enforced via `@typescript-eslint/naming-convention`. Use `camelCase` for variables/functions, `PascalCase` for classes/interfaces.
200
248
  - **Template literals**: Prefer `` `${x}` `` over `'a' + x` (`prefer-template: error`).
201
- - **Deprecated APIs**: `deprecation/deprecation` rule is set to `error` — do not use deprecated APIs.
249
+ - **Deprecated APIs**: `@typescript-eslint/no-deprecated` rule is set to `error` — do not use deprecated APIs.
202
250
  - **No `require()`**: Use ES `import`/`export`.
203
251
 
204
252
  ### Imports
@@ -261,6 +309,6 @@ Follow conventional commits:
261
309
  - `index-managed-policies.yml` - Weekly on Sunday: updates managed policies, opens a `feat:` PR with `automerge` label
262
310
  - `release-please.yml` - On push to main: release-please maintains the release PR (version in `package.json` and `docs/source/conf.py`, `CHANGELOG.md`). After each run, `bin/changelog-add-iam-changes` adds the changes of the managed policies and the model since the last release to the new changelog entry of the PR. Merging the PR creates the tag and a draft release, and starts `test-and-publish.yml` with the tag
263
311
  - `automerge-schedule.yml` - Weekly on Monday: merges the release PR
264
- - `test-and-publish.yml` - On PR: `make install test-typescript` + CDK deploy test + `make package-jsii test-jsii` per language. Started by `release-please.yml` with a tag: builds the packages from the tag, publishes to npm, PyPI, NuGet, Maven Central and the Go module proxy on GitHub Pages, sets the notes of the release from `CHANGELOG.md` and publishes the release
312
+ - `test-and-publish.yml` - On PR: `make install lint` (job `lint`), `make install test-typescript` + `make lint-cdk` + CDK deploy test + `make package-jsii test-jsii` per language + `make package-native test-transpile` against the built Python, Java, .NET and Go packages. Started by `release-please.yml` with a tag: builds the packages from the tag, publishes to npm, PyPI, NuGet, Maven Central and the Go module proxy on GitHub Pages, sets the notes of the release from `CHANGELOG.md` and publishes the release
265
313
  - `automerge.yml` - Auto-merges PRs labeled `automerge` after tests pass
266
314
  - `test-docs.yml` - Builds Sphinx docs on `docs/**` changes
package/README.md CHANGED
@@ -1,68 +1,171 @@
1
1
  # IAM Floyd
2
2
 
3
- [![Source](https://img.shields.io/github/stars/udondan/iam-floyd?logo=github&label=GitHub%20Stars)][source]
4
- [![iam-floyd](https://img.shields.io/github/v/release/udondan/iam-floyd)][source]
5
- [![Packages](https://img.shields.io/badge/Packages-npm%20%7C%20PyPI%20%7C%20Maven%20%7C%20NuGet%20%7C%20Go-yellow)][packages]
6
- [![Documentation](https://img.shields.io/badge/Documentation-Read%20the%20Docs-orange)][documentation]
7
- [![GitHub](https://img.shields.io/github/license/udondan/iam-floyd)][license]
8
-
9
- <!-- put back - when we actually have tests
10
- [![Test Coverage](https://api.codeclimate.com/v1/badges/cdb84b5646c6805b1a23/test_coverage)](https://codeclimate.com/github/udondan/iam-floyd/test_coverage)
11
- -->
12
-
13
- **AWS [IAM policy statement][statement] generator with fluent interface.**
3
+ [![Release](https://img.shields.io/github/v/release/udondan/iam-floyd?label=release)](https://github.com/udondan/iam-floyd/releases)
4
+ [![Documentation](https://img.shields.io/readthedocs/iam-floyd?label=docs)](https://iam-floyd.readthedocs.io/en/latest/)
5
+ [![Construct Hub](https://img.shields.io/badge/Construct%20Hub-cdk--iam--floyd-blue)](https://constructs.dev/packages/cdk-iam-floyd)
6
+ [![License](https://img.shields.io/github/license/udondan/iam-floyd)](https://github.com/udondan/iam-floyd/blob/main/LICENSE)
7
+
8
+ **AWS [IAM policy statement][statement] generator with a fluent interface, for TypeScript, JavaScript, Python, Java, C# and Go.**
9
+
10
+ IAM Floyd has a class for every AWS service, with a method for every action, resource type and condition key. Your IDE completes them and shows their documentation, so you neither look up action names and ARN formats, nor deploy policies with typos.
11
+
12
+ ```ts
13
+ import { Statement } from 'iam-floyd';
14
+
15
+ const statement = new Statement.Ec2()
16
+ .allow()
17
+ .toStartInstances()
18
+ .toStopInstances()
19
+ .ifResourceTag('Owner', '${aws:username}');
20
+ ```
21
+
22
+ ```json
23
+ {
24
+ "Condition": {
25
+ "StringLike": {
26
+ "ec2:ResourceTag/Owner": "${aws:username}"
27
+ }
28
+ },
29
+ "Action": ["ec2:StartInstances", "ec2:StopInstances"],
30
+ "Resource": "*",
31
+ "Effect": "Allow"
32
+ }
33
+ ```
34
+
35
+ <details>
36
+ <summary>Python</summary>
37
+
38
+ ```python
39
+ from iam_floyd import Statement
40
+
41
+ statement = (
42
+ Statement.Ec2()
43
+ .allow()
44
+ .to_start_instances()
45
+ .to_stop_instances()
46
+ .if_resource_tag('Owner', '${aws:username}')
47
+ )
48
+ ```
49
+
50
+ </details>
51
+
52
+ <details>
53
+ <summary>Java</summary>
54
+
55
+ ```java
56
+ import com.udondan.iamFloyd.statement.Ec2;
57
+
58
+ Ec2 statement = new Ec2()
59
+ .allow()
60
+ .toStartInstances()
61
+ .toStopInstances()
62
+ .ifResourceTag("Owner", "${aws:username}");
63
+ ```
64
+
65
+ </details>
66
+
67
+ <details>
68
+ <summary>C#</summary>
69
+
70
+ ```csharp
71
+ using Statement = IAM.Floyd.Statement;
72
+
73
+ var statement = new Statement.Ec2()
74
+ .Allow()
75
+ .ToStartInstances()
76
+ .ToStopInstances()
77
+ .IfResourceTag("Owner", "${aws:username}");
78
+ ```
79
+
80
+ </details>
81
+
82
+ <details>
83
+ <summary>Go</summary>
84
+
85
+ ```go
86
+ import (
87
+ "udondan.github.io/iam-floyd/go/iamfloyd"
88
+ "udondan.github.io/iam-floyd/go/iamfloyd/statement"
89
+ )
90
+
91
+ s := statement.NewEc2(nil).
92
+ Allow().
93
+ ToStartInstances().
94
+ ToStopInstances().
95
+ IfResourceTag(iamfloyd.String("Owner"), iamfloyd.String("${aws:username}"), nil)
96
+ ```
97
+
98
+ </details>
14
99
 
15
100
  <!-- stats -->
101
+
16
102
  Support for:
17
103
 
18
104
  - 455 Services
19
105
  - 22036 Actions
20
106
  - 2329 Resource Types
21
107
  - 2484 Condition keys
108
+
22
109
  <!-- /stats -->
23
110
 
24
- ![EXPERIMENTAL](https://img.shields.io/badge/stability-experimantal-orange?style=for-the-badge)**<br>This is an early version of the package. The API will change while I implement new features. Therefore make sure you use an exact version in your `package.json` before it reaches 1.0.0.**
111
+ ## Features
25
112
 
26
- ## Documentation
113
+ - **Complete**: generated from the [AWS documentation][aws-docs], and updated every week
114
+ - **Access levels**: add all actions of an access level, e.g. `allReadActions()` or `allWriteActions()`
115
+ - **Regular expressions**: add all actions that match a pattern with `allMatchingActions('/vpn/i')`
116
+ - **Resources**: build ARNs with a method per resource type, e.g. `onBucket('example-bucket')`, with defaults for partition, region and account
117
+ - **Conditions**: a method per condition key, with operators like `ForAnyValue:StringEquals` or `IfExists`
118
+ - **AWS CDK**: `cdk-iam-floyd` statements are an [`iam.PolicyStatement`][cdk-policy-statement] of the AWS CDK
119
+ - **Collections** of common statements, and the names of all AWS managed policies
120
+ - **Policy converter**: turn an existing JSON policy into IAM Floyd code with the [online converter][converter]
27
121
 
28
- Find the documentation at [Read the Docs][documentation].
122
+ ## Packages
29
123
 
30
- [![Auto completion demo](https://raw.githubusercontent.com/udondan/iam-floyd/main/docs/movie-preview.png)](https://www.youtube.com/watch?v=4dHY8qPHbKA 'Auto completion demo')
124
+ IAM Floyd comes in two variants, with the same API and the same version number in every language:
31
125
 
32
- ## Packages
126
+ - **`iam-floyd`** creates statements as JSON, for the AWS SDKs, CloudFormation, Terraform or anything else that takes an IAM policy. The packages have no dependencies. In Python, Java, C# and Go, they are native and do not need Node.js.
127
+ - **`cdk-iam-floyd`** creates statements of the [AWS CDK][aws-cdk] v2. In Python, Java, C# and Go, they are built with [jsii][jsii], like the AWS CDK itself, and need Node.js.
33
128
 
34
- There are two different package variants available:
129
+ | Language | `iam-floyd` | `cdk-iam-floyd` |
130
+ | ----------------------- | -------------------------------------- | ---------------------------------------------- |
131
+ | TypeScript / JavaScript | [![npm][npm-badge]][npm] | [![npm][cdk-npm-badge]][cdk-npm] |
132
+ | Python | [![PyPI][pypi-badge]][pypi] | [![PyPI][cdk-pypi-badge]][cdk-pypi] |
133
+ | Java | [![Maven Central][maven-badge]][maven] | [![Maven Central][cdk-maven-badge]][cdk-maven] |
134
+ | C# / .NET | [![NuGet][nuget-badge]][nuget] | [![NuGet][cdk-nuget-badge]][cdk-nuget] |
135
+ | Go | [![Go][go-badge]][go] | [![Go][go-badge]][cdk-go] |
35
136
 
36
- - **iam-floyd**: Can be used in AWS SDK or for whatever you need an IAM policy statement for <br>[![npm](https://img.shields.io/npm/dt/iam-floyd?label=npm&color=blueviolet)](https://www.npmjs.com/package/iam-floyd)
37
- - **cdk-iam-floyd**: Integrates into [AWS CDK] and extends [`iam.PolicyStatement`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.PolicyStatement.html)<br>[![npm](https://img.shields.io/npm/dt/cdk-iam-floyd?label=npm&color=orange)](https://www.npmjs.com/package/cdk-iam-floyd)
137
+ ### Installation
38
138
 
39
- **Starting with version 0.300.0, the packages are compatible with CDK v2.** For CDK v1 you can use any version up to:<br>
40
- [![npm CDK v1](https://img.shields.io/badge/npm-0.286.0-yellow)](https://www.npmjs.com/package/cdk-iam-floyd/v/0.286.0)
139
+ ```bash
140
+ # TypeScript / JavaScript
141
+ npm install iam-floyd # or cdk-iam-floyd
41
142
 
42
- cdk-iam-floyd is also available for Python, Java, .NET and Go:<br>
43
- [![PyPI](https://img.shields.io/pypi/v/cdk-iam-floyd?label=PyPI)](https://pypi.org/project/cdk-iam-floyd/)
44
- [![Maven Central](https://img.shields.io/maven-central/v/com.udondan/cdk-iam-floyd?label=Maven%20Central)](https://central.sonatype.com/artifact/com.udondan/cdk-iam-floyd)
45
- [![NuGet](https://img.shields.io/nuget/v/CDK.IAM.Floyd?label=NuGet)](https://www.nuget.org/packages/CDK.IAM.Floyd)
46
- `go get udondan.github.io/iam-floyd/go/cdkiamfloyd`
143
+ # Python
144
+ pip install iam-floyd # or cdk-iam-floyd
47
145
 
48
- ## CDK Compatibility Matrix
146
+ # Java (Maven), with the version of the release
147
+ # com.udondan:iam-floyd # or com.udondan:cdk-iam-floyd
49
148
 
50
- | CDK | cdk-iam-floyd |
51
- | ---------- | -------------------------- |
52
- | <= 1.151.0 | <= 0.285.0 |
53
- | >= 1.152.0 | 0.286.0 |
54
- | >= 1.158.0 | **No compatible version!** |
55
- | >= 2.0.0 | >= 0.300.0 |
56
- | >= 2.20.0 | >= 0.351.0 |
57
- | >= 2.26.0 | >= 0.377.0 |
58
- | 2.29.x | **No compatible version!** |
59
- | >= 2.30.0 | >= 0.391.0 |
149
+ # C# / .NET
150
+ dotnet add package IAM.Floyd # or CDK.IAM.Floyd
60
151
 
61
- ---
152
+ # Go
153
+ go get udondan.github.io/iam-floyd/go/iamfloyd # or .../go/cdkiamfloyd
154
+ ```
155
+
156
+ IAM Floyd has not reached 1.0.0 yet, and the API can still change between releases. Pin the exact version.
157
+
158
+ The requirements of each package and the compatibility with the AWS CDK are listed in the [documentation][packages].
159
+
160
+ ## Documentation
161
+
162
+ The [documentation][documentation] explains all features, with examples in every language.
163
+
164
+ [![Auto completion demo](https://raw.githubusercontent.com/udondan/iam-floyd/main/docs/movie-preview.png)](https://www.youtube.com/watch?v=4dHY8qPHbKA 'Auto completion demo')
62
165
 
63
166
  ## Legal
64
167
 
65
- The service models in the [lib/generated/model](https://github.com/udondan/iam-floyd/tree/main/lib/generated/model) folder, and the code generated from them, are derived from the [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_actions-resources-contextkeys.html). The class- and function-names and their description therefore are property of AWS.
168
+ The service models in the [lib/generated/model](https://github.com/udondan/iam-floyd/tree/main/lib/generated/model) folder, and the code generated from them, are derived from the [AWS documentation][aws-docs]. The class- and function-names and their description therefore are property of AWS.
66
169
 
67
170
  AWS and their services are trademarks, registered trademarks or trade dress of AWS in the U.S. and/or other countries.
68
171
 
@@ -70,10 +173,31 @@ This project is not affiliated, funded, or in any way associated with AWS.
70
173
 
71
174
  IAM Floyd is licensed under [Apache License 2.0][license]. Dependencies might be released under different licenses.
72
175
 
73
- [source]: https://github.com/udondan/iam-floyd
74
- [documentation]: https://iam-floyd.readthedocs.io/en/latest/
75
- [npm]: https://www.npmjs.com/package/iam-floyd
76
- [license]: https://github.com/udondan/iam-floyd/blob/main/LICENSE
77
- [statement]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_statement.html
78
- [packages]: https://iam-floyd.readthedocs.io/en/latest/packages.html
79
- [AWS CDK]: https://aws.amazon.com/cdk/
176
+ [statement]: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_statement.html
177
+ [aws-docs]: https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html
178
+ [aws-cdk]: https://aws.amazon.com/cdk/
179
+ [cdk-policy-statement]: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyStatement.html
180
+ [jsii]: https://aws.github.io/jsii/
181
+ [documentation]: https://iam-floyd.readthedocs.io/en/latest/
182
+ [packages]: https://iam-floyd.readthedocs.io/en/latest/packages.html
183
+ [converter]: https://iam-floyd.readthedocs.io/en/latest/policy-converter.html
184
+ [license]: https://github.com/udondan/iam-floyd/blob/main/LICENSE
185
+ [npm]: https://www.npmjs.com/package/iam-floyd
186
+ [npm-badge]: https://img.shields.io/npm/v/iam-floyd?label=npm&color=3178C6&logo=typescript&logoColor=white
187
+ [pypi]: https://pypi.org/project/iam-floyd/
188
+ [pypi-badge]: https://img.shields.io/pypi/v/iam-floyd?label=PyPI&color=3776AB&logo=python&logoColor=white
189
+ [maven]: https://central.sonatype.com/artifact/com.udondan/iam-floyd
190
+ [maven-badge]: https://img.shields.io/maven-central/v/com.udondan/iam-floyd?label=Maven%20Central&color=ED8B00&logo=openjdk&logoColor=white
191
+ [nuget]: https://www.nuget.org/packages/IAM.Floyd
192
+ [nuget-badge]: https://img.shields.io/nuget/v/IAM.Floyd?label=NuGet&color=512BD4&logo=dotnet&logoColor=white
193
+ [cdk-npm]: https://www.npmjs.com/package/cdk-iam-floyd
194
+ [cdk-npm-badge]: https://img.shields.io/npm/v/cdk-iam-floyd?label=npm&color=3178C6&logo=typescript&logoColor=white
195
+ [cdk-pypi]: https://pypi.org/project/cdk-iam-floyd/
196
+ [cdk-pypi-badge]: https://img.shields.io/pypi/v/cdk-iam-floyd?label=PyPI&color=3776AB&logo=python&logoColor=white
197
+ [cdk-maven]: https://central.sonatype.com/artifact/com.udondan/cdk-iam-floyd
198
+ [cdk-maven-badge]: https://img.shields.io/maven-central/v/com.udondan/cdk-iam-floyd?label=Maven%20Central&color=ED8B00&logo=openjdk&logoColor=white
199
+ [cdk-nuget]: https://www.nuget.org/packages/CDK.IAM.Floyd
200
+ [cdk-nuget-badge]: https://img.shields.io/nuget/v/CDK.IAM.Floyd?label=NuGet&color=512BD4&logo=dotnet&logoColor=white
201
+ [go]: https://pkg.go.dev/udondan.github.io/iam-floyd/go/iamfloyd
202
+ [cdk-go]: https://pkg.go.dev/udondan.github.io/iam-floyd/go/cdkiamfloyd
203
+ [go-badge]: https://img.shields.io/github/v/release/udondan/iam-floyd?label=Go&color=00ADD8&logo=go&logoColor=white
package/doc8.ini ADDED
@@ -0,0 +1,3 @@
1
+ [doc8]
2
+ # Prose isn't wrapped
3
+ ignore = D001
@@ -0,0 +1,36 @@
1
+ <!--
2
+ The native .NET package of iam-floyd. Most of the sources are written by bin/transpile.ts.
3
+ `make package-native` packs it with the version of package.json into dist/iam-floyd/dotnet.
4
+ -->
5
+ <Project Sdk="Microsoft.NET.Sdk">
6
+ <PropertyGroup>
7
+ <TargetFramework>net8.0</TargetFramework>
8
+ <LangVersion>12</LangVersion>
9
+ <Nullable>disable</Nullable>
10
+ <ImplicitUsings>disable</ImplicitUsings>
11
+ <RootNamespace>IAM.Floyd</RootNamespace>
12
+ <AssemblyName>IAM.Floyd</AssemblyName>
13
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
14
+ <!-- protected members have no documentation -->
15
+ <NoWarn>$(NoWarn);CS1591</NoWarn>
16
+ <Deterministic>true</Deterministic>
17
+ <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
18
+
19
+ <Version>0.0.0</Version>
20
+ <PackageId>IAM.Floyd</PackageId>
21
+ <Title>iam-floyd</Title>
22
+ <Description>AWS IAM policy statement generator with fluent interface</Description>
23
+ <Authors>Daniel Schroeder</Authors>
24
+ <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
25
+ <PackageProjectUrl>https://github.com/udondan/iam-floyd</PackageProjectUrl>
26
+ <RepositoryUrl>https://github.com/udondan/iam-floyd.git</RepositoryUrl>
27
+ <RepositoryType>git</RepositoryType>
28
+ <PackageTags>aws;iam;policy;statement;generator</PackageTags>
29
+ <PackageReadmeFile>README.md</PackageReadmeFile>
30
+ </PropertyGroup>
31
+
32
+ <ItemGroup>
33
+ <None Include="../../README.md" Pack="true" PackagePath="/" />
34
+ <None Include="../../../LICENSE" Pack="true" PackagePath="/" />
35
+ </ItemGroup>
36
+ </Project>