Skip to content

Commit 3534d1d

Browse files
committed
moved cdk to examples
1 parent 2e22c7b commit 3534d1d

File tree

3 files changed

+51
-47
lines changed

3 files changed

+51
-47
lines changed

docs/index.md

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,7 @@ You can install Powertools for AWS Lambda (Python) using your favorite dependenc
9797
=== "CDK"
9898

9999
```python hl_lines="16 21"
100-
from aws_cdk import (
101-
Stack,
102-
aws_lambda,
103-
Aws
104-
)
105-
from constructs import Construct
106-
107-
class SampleApp(Stack):
108-
109-
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
110-
super().__init__(scope, construct_id, **kwargs)
111-
112-
powertools_layer = aws_lambda.LayerVersion.from_layer_version_arn(
113-
self,
114-
id="lambda-powertools",
115-
layer_version_arn=f"arn:aws:lambda:{Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2:69"
116-
)
117-
aws_lambda.Function(self,
118-
'sample-app-lambda',
119-
runtime=aws_lambda.Runtime.PYTHON_3_12,
120-
layers=[powertools_layer],
121-
# other props...
122-
)
100+
--8<-- "examples/install/x86_64/cdk.py"
123101
```
124102

125103
=== "Terraform"
@@ -256,30 +234,7 @@ You can install Powertools for AWS Lambda (Python) using your favorite dependenc
256234
=== "CDK"
257235

258236
```python hl_lines="16 21"
259-
from aws_cdk import (
260-
Stack,
261-
aws_lambda,
262-
Aws
263-
)
264-
from constructs import Construct
265-
266-
class SampleApp(Stack):
267-
268-
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
269-
super().__init__(scope, construct_id, **kwargs)
270-
271-
powertools_layer = aws_lambda.LayerVersion.from_layer_version_arn(
272-
self,
273-
id="lambda-powertools",
274-
layer_version_arn=f"arn:aws:lambda:{Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2:69"
275-
)
276-
aws_lambda.Function(self,
277-
'sample-app-lambda',
278-
runtime=aws_lambda.Runtime.PYTHON_3_12,
279-
layers=[powertools_layer],
280-
architecture=aws_lambda.Architecture.ARM_64
281-
# other props...
282-
)
237+
--8<-- "examples/install/arm64/cdk.py"
283238
```
284239

285240
=== "Terraform"

examples/install/arm64/cdk.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from aws_cdk import (
2+
Stack,
3+
aws_lambda,
4+
Aws
5+
)
6+
from constructs import Construct
7+
8+
class SampleApp(Stack):
9+
10+
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
11+
super().__init__(scope, construct_id, **kwargs)
12+
13+
powertools_layer = aws_lambda.LayerVersion.from_layer_version_arn(
14+
self,
15+
id="lambda-powertools",
16+
layer_version_arn=f"arn:aws:lambda:{Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2:69"
17+
)
18+
aws_lambda.Function(self,
19+
'sample-app-lambda',
20+
runtime=aws_lambda.Runtime.PYTHON_3_12,
21+
layers=[powertools_layer],
22+
architecture=aws_lambda.Architecture.ARM_64,
23+
code=aws_lambda.Code.from_asset('lambda'),
24+
handler='hello.handler'
25+
)

examples/install/x86_64/cdk.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from aws_cdk import (
2+
Stack,
3+
aws_lambda,
4+
Aws
5+
)
6+
from constructs import Construct
7+
8+
class SampleApp(Stack):
9+
10+
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
11+
super().__init__(scope, construct_id, **kwargs)
12+
13+
powertools_layer = aws_lambda.LayerVersion.from_layer_version_arn(
14+
self,
15+
id="lambda-powertools",
16+
layer_version_arn=f"arn:aws:lambda:{Aws.REGION}:017000801446:layer:AWSLambdaPowertoolsPythonV2:69"
17+
)
18+
aws_lambda.Function(self,
19+
'sample-app-lambda',
20+
runtime=aws_lambda.Runtime.PYTHON_3_12,
21+
layers=[powertools_layer],
22+
code=aws_lambda.Code.from_asset('lambda'),
23+
handler='hello.handler'
24+
)

0 commit comments

Comments
 (0)