Skip to content

Commit 58da8ea

Browse files
authored
docs(cfn-lang-ext): correct language-extensions precedence order (#9042)
The activation precedence was documented as CLI > env var > samconfig.toml, but the actual behavior is CLI > samconfig.toml > env var. samconfig values are loaded into Click's default_map by configuration_callback, so by the time resolve_language_extensions_enabled runs, flag_value is already non-None and the env var is never consulted. Reorder the methods to match runtime behavior, drop the misleading word "equivalent", and add brief notes explaining why samconfig outranks the env var and when the env var is actually read.
1 parent 1f7fd05 commit 58da8ea

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

docs/cfn-language-extensions.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The original template (with `Fn::ForEach` intact) is preserved for CloudFormatio
1717

1818
## Enabling Language Extensions
1919

20-
Local processing of `AWS::LanguageExtensions` is opt-in per command. Three equivalent activation methods, in priority order:
20+
Local processing of `AWS::LanguageExtensions` is opt-in per command. Three activation methods, in priority order (highest first):
2121

2222
1. **CLI flag** — pass `--language-extensions` on a single invocation:
2323

@@ -27,19 +27,9 @@ Local processing of `AWS::LanguageExtensions` is opt-in per command. Three equiv
2727
sam deploy --language-extensions ...
2828
```
2929

30-
`--no-language-extensions` explicitly disables, overriding the env var below.
30+
`--no-language-extensions` explicitly disables, overriding both samconfig.toml and the env var below.
3131

32-
2. **Environment variable** — set `SAM_CLI_ENABLE_LANGUAGE_EXTENSIONS=1` to enable for the current shell:
33-
34-
```bash
35-
export SAM_CLI_ENABLE_LANGUAGE_EXTENSIONS=1
36-
sam build
37-
sam local invoke MyFunction
38-
```
39-
40-
Truthy values (case-insensitive): `1`, `true`, `yes`. Anything else, including empty string, is off.
41-
42-
3. **`samconfig.toml`** — persist the choice per project:
32+
2. **`samconfig.toml`** — persist the choice per project:
4333

4434
```toml
4535
[default.build.parameters]
@@ -67,6 +57,18 @@ Local processing of `AWS::LanguageExtensions` is opt-in per command. Three equiv
6757
language_extensions = true
6858
```
6959

60+
A `samconfig.toml` entry is loaded into Click's defaults, so it takes effect as if the flag were passed — and therefore wins over the env var.
61+
62+
3. **Environment variable** — set `SAM_CLI_ENABLE_LANGUAGE_EXTENSIONS=1` to enable for the current shell:
63+
64+
```bash
65+
export SAM_CLI_ENABLE_LANGUAGE_EXTENSIONS=1
66+
sam build
67+
sam local invoke MyFunction
68+
```
69+
70+
Truthy values (case-insensitive): `1`, `true`, `yes`. Anything else, including empty string, is off. The env var is consulted only when neither the CLI flag nor samconfig.toml sets a value.
71+
7072
**Each command needs its own activation.** Passing `--language-extensions` to `sam build` does not propagate to a later `sam local invoke` — local processing is decided per command invocation. Use the env var or samconfig entry to enable across commands without repeating the flag.
7173

7274
## Fn::ForEach

0 commit comments

Comments
 (0)