DenCowboy
DenCowboy

Reputation: 15106

How to add environment variable to CloudFront function in CDK?

I've created an CloudFront function in CDK:

func = cloudfront.Function(
    self,
    "redirect",
    code=cloudfront.FunctionCode.from_file(
        file_path="lambda/function.js",
    ),
)

How can I add an environment variable to this function?

Upvotes: 0

Views: 4370

Answers (2)

user1148920
user1148920

Reputation: 228

Why would you need to use environment variables in this case?

Just bake the variables into the function itself.

Upvotes: -3

kgiannakakis
kgiannakakis

Reputation: 104188

These are the restrictions for edge functions. Environmental Variables are clearly not supported for Lambda@Edge functions. From Cloud Formation documentation for Cloud Functions, it seems that there is no way to add environmental variables.

This is to be expected, as Cloud Functions are supposed to be lightweight functions that need to be replicated across all edges. (A normal lambda function runs in a specific region in it's own environment.)

Upvotes: 2

Related Questions