Use AWS Parameters and Secrets Lambda Extension for lambda in my own extension

0

Hi,

I'd like to use the AWS Parameters and Secrets Lambda Extension in my own extension, so that I can retrieve secrets and use them in my lambda execution code, so I tried to write my own extension that is loaded after the AWS Parameters and Secrets Lambda Extension. However, when I then try to call the localhost on port 2773, as referenced here https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html, I get a connection refused error. When I try to use the extension directly in my function code, it does work as expected.

So my question is, is there any way I can use this AWS provided extension in my own extension? The reason I want to do this is so that my function code itself does not get changed, I only have to add my own custom layer to these functions so that these secrets are available to the function being executed.

In this case, I'd like to use the SSM Parameter Store, not the Secrets Manager.

meesk
asked a month ago42 views
1 Answer
0

To use the AWS Parameters and Secrets Lambda Extension within your own custom Lambda extension, the main challenge is ensuring that your extension accesses the local HTTP endpoint (localhost:2773) after the AWS extension is fully initialized.

The "connection refused" error likely occurs because your custom extension attempts to connect before the AWS Parameters and Secrets extension is ready.

To resolve this, you can implement a retry mechanism with exponential backoff or check the readiness of the extension before making HTTP requests, ensuring your extension runs after the AWS-provided one.

profile picture
EXPERT
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions