Skip to content

Commit 8fd9e0c

Browse files
docs(homepage): add Pulumi code example (#1652)
Co-authored-by: Leandro Damascena <[email protected]>
1 parent 67532d7 commit 8fd9e0c

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

Diff for: docs/index.md

+72
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,42 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
209209
}
210210
```
211211

212+
=== "Pulumi"
213+
214+
```python
215+
import json
216+
import pulumi
217+
import pulumi_aws as aws
218+
219+
role = aws.iam.Role("role",
220+
assume_role_policy=json.dumps({
221+
"Version": "2012-10-17",
222+
"Statement": [
223+
{
224+
"Action": "sts:AssumeRole",
225+
"Principal": {
226+
"Service": "lambda.amazonaws.com"
227+
},
228+
"Effect": "Allow"
229+
}
230+
]
231+
}),
232+
managed_policy_arns=[aws.iam.ManagedPolicy.AWS_LAMBDA_BASIC_EXECUTION_ROLE]
233+
)
234+
235+
lambda_function = aws.lambda_.Function("function",
236+
layers=[pulumi.Output.concat("arn:aws:lambda:",aws.get_region_output().name,":017000801446:layer:AWSLambdaPowertoolsPythonV2:11")],
237+
tracing_config={
238+
"mode": "Active"
239+
},
240+
runtime=aws.lambda_.Runtime.PYTHON3D9,
241+
handler="index.handler",
242+
role=role.arn,
243+
architectures=["x86_64"],
244+
code=pulumi.FileArchive("lambda_function_payload.zip")
245+
)
246+
```
247+
212248
=== "Amplify"
213249

214250
```zsh
@@ -341,6 +377,42 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
341377

342378
```
343379

380+
=== "Pulumi"
381+
382+
```python
383+
import json
384+
import pulumi
385+
import pulumi_aws as aws
386+
387+
role = aws.iam.Role("role",
388+
assume_role_policy=json.dumps({
389+
"Version": "2012-10-17",
390+
"Statement": [
391+
{
392+
"Action": "sts:AssumeRole",
393+
"Principal": {
394+
"Service": "lambda.amazonaws.com"
395+
},
396+
"Effect": "Allow"
397+
}
398+
]
399+
}),
400+
managed_policy_arns=[aws.iam.ManagedPolicy.AWS_LAMBDA_BASIC_EXECUTION_ROLE]
401+
)
402+
403+
lambda_function = aws.lambda_.Function("function",
404+
layers=[pulumi.Output.concat("arn:aws:lambda:",aws.get_region_output().name,":017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:11")],
405+
tracing_config={
406+
"mode": "Active"
407+
},
408+
runtime=aws.lambda_.Runtime.PYTHON3D9,
409+
handler="index.handler",
410+
role=role.arn,
411+
architectures=["arm64"],
412+
code=pulumi.FileArchive("lambda_function_payload.zip")
413+
)
414+
```
415+
344416
=== "Amplify"
345417

346418
```zsh

0 commit comments

Comments
 (0)