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/cfn-language-extensions.md
+59-3Lines changed: 59 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,71 @@ SAM CLI now supports templates that use the `AWS::LanguageExtensions` transform,
4
4
5
5
## How it works
6
6
7
-
When SAM CLI detects `AWS::LanguageExtensions` in a template's `Transform` section, it expands language extension constructs locally before running SAM transforms. This enables `sam build`, `sam package`, `sam deploy`, `sam sync`, `sam validate`, `sam local invoke`, and `sam local start-api` to work with templates that use these constructs.
7
+
When SAM CLI detects `AWS::LanguageExtensions` in a template's `Transform` section*and* the customer has opted in to local processing, it expands language extension constructs locally before running SAM transforms. This enables `sam build`, `sam package`, `sam deploy`, `sam sync`, `sam validate`, `sam local invoke`, `sam local start-api`, and `sam local start-lambda` to work with templates that use these constructs.
8
8
9
-
The expansion happens in two phases:
9
+
**Local processing is off by default.** When off, SAM CLI passes the template through unchanged; CloudFormation processes the `AWS::LanguageExtensions` transform server-side at deploy time (the pre-1.160.0 behavior).
10
+
11
+
The expansion happens in two phases when enabled:
10
12
11
13
1.**Phase 1 (Language Extensions)** — `Fn::ForEach` loops are expanded, intrinsic functions are resolved where possible, and the template is converted to standard CloudFormation.
12
14
2.**Phase 2 (SAM Transform)** — The expanded template is processed by the SAM Translator as usual.
13
15
14
16
The original template (with `Fn::ForEach` intact) is preserved for CloudFormation deployment, since CloudFormation processes the `AWS::LanguageExtensions` transform server-side.
15
17
18
+
## Enabling Language Extensions
19
+
20
+
Local processing of `AWS::LanguageExtensions` is opt-in per command. Three equivalent activation methods, in priority order:
21
+
22
+
1.**CLI flag** — pass `--language-extensions` on a single invocation:
23
+
24
+
```bash
25
+
sam build --language-extensions
26
+
sam package --language-extensions ...
27
+
sam deploy --language-extensions ...
28
+
```
29
+
30
+
`--no-language-extensions` explicitly disables, overriding the env var below.
31
+
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:
43
+
44
+
```toml
45
+
[default.build.parameters]
46
+
language_extensions = true
47
+
48
+
[default.package.parameters]
49
+
language_extensions = true
50
+
51
+
[default.deploy.parameters]
52
+
language_extensions = true
53
+
54
+
[default.sync.parameters]
55
+
language_extensions = true
56
+
57
+
[default.local_invoke.parameters]
58
+
language_extensions = true
59
+
60
+
[default.local_start_api.parameters]
61
+
language_extensions = true
62
+
63
+
[default.local_start_lambda.parameters]
64
+
language_extensions = true
65
+
66
+
[default.validate.parameters]
67
+
language_extensions = true
68
+
```
69
+
70
+
**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.
71
+
16
72
## Fn::ForEach
17
73
18
74
`Fn::ForEach` generates multiple resources, conditions, or outputs from a single template definition:
@@ -302,4 +358,4 @@ The following template issues are caught locally before the SAM transform runs:
302
358
303
359
## Telemetry
304
360
305
-
SAM CLI tracks usage of `AWS::LanguageExtensions` via the `CFNLanguageExtensions` telemetry feature flag. No template content is transmitted.
361
+
SAM CLI emits a `CFNLanguageExtensions` telemetry event when a command is invoked with `--language-extensions` (or its env-var equivalent) **and** the template declares the `AWS::LanguageExtensions` transform. The event fires once per invocation; no template content is transmitted. When local processing is off (the default), no event fires.
0 commit comments