Skip to content

Index with Algolia #7

@j4jefferson

Description

@j4jefferson

In lesson 06/05 'Securely Handle Algolia API key', I received an error:

"errorMessage": "Invalid value \"undefined\" for header \"x-algolia-api-key\"",
"code": "ERR_HTTP_INVALID_HEADER_VALUE",

I checked the @middy/ssm docs and changed the ssm middleware implementation in functions/sync-users-to-algolia.js to:

.use(
	ssm({
		cache: true,
		cacheExpiry: 5 * 60 * 1000,
		fetchData: {
			ALGOLIA_APP_ID: `/${STAGE}/algolia-app-id`,
			ALGOLIA_WRITE_KEY: `/${STAGE}/algolia-admin-key`,
		},
		setToContext: true,
		throwOnFailedCall: true,
	})
)

This resolved the error from the Lambda function and successfully got data into the Algolia index.
Dependencies are:
"@middy/core": "^2.5.7",
"@middy/ssm": "^2.5.7",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions