Skip to content

Commit a5cc74f

Browse files
authored
docs: add SSM examples to docs (#3577)
1 parent 2c27c5e commit a5cc74f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Diff for: docs/index.md

+27
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ You can use Powertools for AWS Lambda (TypeScript) by installing it with your fa
129129
- !Sub arn:aws:lambda:${AWS::Region}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:19
130130
```
131131

132+
You can also use AWS SSM Parameter Store to dynamically add Powertools for AWS Lambda. The `{version}` placeholder is the semantic version number (e,g. 2.1.0) for a release or `_latest_`.
133+
134+
```yaml hl_lines="5"
135+
MyLambdaFunction:
136+
Type: AWS::Serverless::Function
137+
Properties:
138+
Layers:
139+
- {{resolve:ssm:/aws/service/powertools/typescript/generic/all/{version}}}
140+
```
141+
132142
If you use `esbuild` to bundle your code, make sure to exclude `@aws-lambda-powertools/*` and `@aws-sdk/*` from being bundled since the packages are already present the layer:
133143

134144
```yaml hl_lines="5-14"
@@ -195,6 +205,23 @@ You can use Powertools for AWS Lambda (TypeScript) by installing it with your fa
195205
}
196206
```
197207

208+
You can use [data sources](https://developer.hashicorp.com/terraform/language/data-sources) to resolve the SSM Parameter Store in your code, allowing you to pin to `_latest_` or a specific Powertools for AWS Lambda version.
209+
210+
```terraform
211+
data "aws_ssm_parameter" "powertools_version" {
212+
# Replace {version} with your chosen Powertools for AWS Lambda version or latest
213+
name = "/aws/service/powertools/python/generic/all/{version}"
214+
}
215+
216+
resource "aws_lambda_function" "test_lambda" {
217+
...
218+
219+
runtime = "nodejs22.x"
220+
221+
layers = [data.aws_ssm_parameter.powertools_version.value]
222+
}
223+
```
224+
198225
=== "Pulumi"
199226

200227
```typescript hl_lines="11"

0 commit comments

Comments
 (0)