Skip to content

Commit 21ee8f6

Browse files
Fokko Bucysjaidisido
andauthored
docs(install): Improved CDK usage guidance (#1105)
* docs(install): Improved CDK usage guidance The way how the AWS Data Wrangler Layer can used within CDK and SAR is improved. Resolves: #1097 * Minor fixes Co-authored-by: jaidisido <[email protected]>
1 parent e0619cb commit 21ee8f6

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

docs/source/install.rst

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,57 @@ Serverless Application Repository (SAR)
8080

8181
AWS Data Wrangler layers are also available in the `AWS Serverless Application Repository <https://serverlessrepo.aws.amazon.com/applications>`_ (SAR).
8282

83-
Here is an example of how to create the Lambda layer in your CDK app:
83+
The app deploys the Lambda layer version in your own AWS account and region via a CloudFormation stack.
84+
This option provides the ability to use semantic versions (i.e. library version) instead of Lambda layer versions.
85+
86+
.. list-table:: AWS Data Wrangler Layer Apps
87+
:widths: 25 25 50
88+
:header-rows: 1
89+
90+
* - App
91+
- ARN
92+
- Description
93+
* - aws-data-wrangler-layer-py3-7
94+
- arn:aws:serverlessrepo:us-east-1:336392948345:applications/aws-data-wrangler-layer-py3-7
95+
- Layer for ``Python 3.7.x`` runtimes
96+
* - aws-data-wrangler-layer-py3-8
97+
- arn:aws:serverlessrepo:us-east-1:336392948345:applications/aws-data-wrangler-layer-py3-8
98+
- Layer for ``Python 3.8.x`` runtimes
99+
* - aws-data-wrangler-layer-py3-9
100+
- arn:aws:serverlessrepo:us-east-1:336392948345:applications/aws-data-wrangler-layer-py3-9
101+
- Layer for ``Python 3.9.x`` runtimes
102+
103+
Here is an example of how to create and use the AWS Data Wrangler Lambda layer in your CDK app:
84104

85105
.. code-block:: python
106+
107+
from aws_cdk import core, aws_sam as sam, aws_lambda
86108
87-
CfnApplication(
88-
self,
89-
"wrangler-layer",
90-
location=CfnApplication.ApplicationLocationProperty(
91-
application_id="arn:aws:serverlessrepo:us-east-1:336392948345:applications/aws-data-wrangler-layer-py3-8",
92-
semantic_version="2.12.0",
93-
),
94-
)
109+
class DataWranglerApp(core.Construct):
110+
def __init__(self, scope: core.Construct, id_: str):
111+
super.__init__(scope,id)
95112
113+
wrangler_layer = sam.CfnApplication(
114+
self,
115+
"wrangler-layer",
116+
location=CfnApplication.ApplicationLocationProperty(
117+
application_id="arn:aws:serverlessrepo:us-east-1:336392948345:applications/aws-data-wrangler-layer-py3-8",
118+
semantic_version="2.13.0", # Get the latest version from https://github.com/awslabs/aws-data-wrangler/releases
119+
),
120+
)
121+
122+
wrangler_layer_arn = wrangler_layer.get_att("Outputs.WranglerLayer38Arn").to_string()
123+
wrangler_layer_version = aws_lambda.LayerVersion.from_layer_version_arn(self, "wrangler-layer-version", wrangler_layer_arn)
124+
125+
aws_lambda.Function(
126+
self,
127+
"wrangler-function",
128+
runtime=aws_lambda.Runtime.PYTHON_3_8,
129+
function_name="sample-wrangler-lambda-function",
130+
code=aws_lambda.Code.asset("./src/wrangler-lambda"),
131+
handler='lambda_function.lambda_handler',
132+
layers=[wrangler_layer_version]
133+
)
96134
97135
AWS Glue Python Shell Jobs
98136
--------------------------

0 commit comments

Comments
 (0)