Skip to main content

Deploying your code

You should now be in a position to deploy your code.

Package code

Before uploading the code, first package it.

To make sure any of your logging statements reach the AWS CloudWatch logs, build your Java code to a jar file that includes log bindings for SLF4J. For example, you could use logback as follows in Gradle:

build.gradle
plugins {
id 'java'
id "com.github.johnrengelman.shadow" version "7.1.2"
}

shadowJar {
archiveClassifier = 'jar-with-dependencies'
dependencies {
include(dependency('ch.qos.logback:logback-classic:.*'))
include(dependency('ch.qos.logback:logback-core:.*'))
}
}

task buildZip(type: Zip)
}

Then, by running ./gradlew buildZip you will have a ready-to-upload zip file with your code under the build/distributions directory of your codebase.

Not necessary to include the Java SDK itself

Note that you don't need to bundle the Java SDK itself as part of your code package. The SDK will be used automatically via the AWS Lambda layer we created earlier.

Upload code

  1. Navigate back to your AWS Lambda functions console.

  2. From the Functions list, click the function you want to deploy your code into.

  3. On the Code tab:

    Java

  4. In the upper-right of the Code source table, click Upload from and then .zip or .jar file.

  5. Use the Upload button to select the zip file containing your code.

  6. In the lower-right of the dialog click the Save button to deploy your code.

  7. Scroll down to the Runtime settings table and in the upper-right click the Edit button.

  8. Change the Handler to the canonical class name for the new class you wrote that extends AbstractLambdaHandler and implements AtlanEventHandler.

  9. In the lower-right, click the Save button.

    Python

  10. In the Code source table you can either:

    • (Recommended) Copy / paste the code from your new module (file) into the editor window for lambda_function.py.
    • In the upper-right, click Upload from and choose the location of your code.
  11. Towards the middle of the Code source table, click the Deploy button to deploy your code.

  12. If you uploaded your own code:

    1. Scroll down to the Runtime settings table and in the upper-right click the Edit button.
    2. Change the Handler to the module (file) name for the new module you wrote that extends AtlanEventHandler and implements the simple lambda_handler(event, context) function. The value should be: <module_name>.lambda_handler.
    3. In the lower-right, click the Save button.

Unit test code

Finally, to confirm your code is all set up to work as expected, you can run a quick test.

  1. Change to the Test tab of your AWS Lambda function.
  2. For Event name enter something like webhook-validation.
  3. In the Event JSON code area, paste in the following payload:
Event JSON
{
"version": "2.0",
"routeKey": "$default",
"rawPath": "/",
"rawQueryString": "",
"headers": {
"content-length": "85",
"x-amzn-tls-cipher-suite": "ECDHE-RSA-AES128-GCM-SHA256",
"x-amzn-tls-version": "TLSv1.2",
"x-amzn-trace-id": "Root=1-64931f85-02856e0b115997577ed16d97",
"x-forwarded-proto": "https",
"host": "uo8rokyifhnhubgagp106xhrpvgmuqhx.lambda-url.us-east-1.on.aws",
"x-forwarded-port": "443",
"content-type": "text/plain; charset=utf-8",
"x-forwarded-for": "34.194.9.164",
"accept-encoding": "gzip",
"user-agent": "go-resty/1.12.0 (https://github.com/go-resty/resty)"
},
"requestContext": {
"accountId": "anonymous",
"apiId": "uo8rokyifhnhubgagp106xhrpvgmuqhx",
"domainName": "uo8rokyifhnhubgagp106xhrpvgmuqhx.lambda-url.us-east-1.on.aws",
"domainPrefix": "uo8rokyifhnhubgagp106xhrpvgmuqhx",
"http": {
"method": "POST",
"path": "/",
"protocol": "HTTP/1.1",
"sourceIp": "34.194.9.164",
"userAgent": "go-resty/1.12.0 (https://github.com/go-resty/resty)"
},
"requestId": "27539f31-d444-419e-b1ad-4382657b7e04",
"routeKey": "$default",
"stage": "$default",
"time": "21/Jun/2023:16:04:21 +0000",
"timeEpoch": 1687363461544
},
"body": "{\"atlan-webhook\": \"Hello, humans of data! It worked. Excited to see what you build!\"}",
"isBase64Encoded": false
}
  1. In the upper-right of the Test event table, click the Test button.
  2. This first time the code runs it may take a number of seconds to complete.

When completed, you should see a dialog at the top of the Test tab similar to the following, indicating a successful run and including log output:

Executing function: suceeded (logs )

The area below shows the last 4 KB of the execution log.

null

Summary

  • Code SHA-256: hVSS2lGvNZii3XkecExrI3urKloxTSFgZfK670kKPOs=
  • Request ID: 5d1bb1ab-0652-4f8c-8f57-f3d9f7cb86e6
  • Init duration: 6140.29 ms
  • Duration: 1.61 ms
  • Billed duration: 2 ms
  • Resources configured: 128 MB
  • Max memory used: 126 MB

Log output

The section below shows the logging calls in your code. Click here to view the corresponding CloudWatch log group.

START RequestId: 5d1bb1ab-0652-4f8c-8f57-f3d9f7cb86e6 Version: $LATEST # (1), 'requestContext': {'accountId': 'anonymous', 'apiId': 'uo8rokyifhnhubgagp106xhrpvgmuqhx', 'domainName': 'uo8rokyifhnhubgagp106xhrpvgmuqhx.lambda-url.us-east-1.on.aws', 'domainPrefix': 'uo8rokyifhnhubgagp106xhrpvgmuqhx', 'http': {'method': 'POST', 'path': '/', 'protocol': 'HTTP/1.1', 'sourceIp': '34.194.9.164', 'userAgent': 'go-resty/1.12.0 (https://github.com/go-resty/resty)'}, 'requestId': '27539f31-d444-419e-b1ad-4382657b7e04', 'routeKey': '$default', 'stage': '$default', 'time': '21/Jun/2023:16:04:21 +0000', 'timeEpoch': 1687363461544}, 'body': '{"atlan-webhook": "Hello, humans of data! It worked. Excited to see what you build!"}', 'isBase64Encoded': False}
Matches a validation request - doing nothing and succeeding. # (2)
END RequestId: 5d1bb1ab-0652-4f8c-8f57-f3d9f7cb86e6 # (3)
REPORT RequestId: 5d1bb1ab-0652-4f8c-8f57-f3d9f7cb86e6 Duration: 1.61 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 126 MB Init Duration: 6140.29 ms
  1. You should see an opening line indicating the unique ID (GUID) of the individual request representing the test run itself. (This may be followed by other logging output, depending on your code's logic.)
  2. For this particular payload, you should see a message indicating that what was received was a validation request, and thus any custom code won't execute and will simply succeed.
  3. You should see some closing lines, indicating the same unique ID (GUID) of the request and the duration of the processing.
Was this page helpful?