Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EdgeFunction: Does not respect custom qualifier #27361

Closed
sachitsac opened this issue Sep 30, 2023 · 5 comments
Closed

EdgeFunction: Does not respect custom qualifier #27361

sachitsac opened this issue Sep 30, 2023 · 5 comments
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@sachitsac
Copy link

Describe the bug

I am trying to use the experimental EdgeFunction construct. But it fails due to usage of a custom qualifier. Here's some information:

  • I have my application stack that reside in the ap-southeast-2 region
  • I have a custom construct that deploys a react website to s3 with cloud front distribution in front of it
  • I have bootstrapped two regions in my aws account: us-east-1 and ap-southeast-2
  • Both of the accounts have been bootstrapped with a custom qualifier: xxx-cdk

So in my custom construct ( L3 pattern ) that deploys the react app to S3, i am trying to add an edge function like this:

Default Synthesiser with qualifier

Screenshot 2023-09-30 at 12 51 09 pm

Edge auth function

MicrosoftTeams-image (3)

Distribution config

MicrosoftTeams-image (2)

Expected Behavior

Upon synthesis, the edge function stack should respect the custom qualifier name provided to the stack. Given that i am initialising the edge function from within my cloudfront stack, ( kinda like nested stack ), i should be able to use to inherit the custom qualifier.

Current Behavior

Its not respecting the custom qualifier provided upon stack initialisation.

Reproduction Steps

  • Bootstrap cdk in us-east-1 and ap-southeast-2 regions with a custom qualifier
  • Create a Main stack with a custom qualifier
  • Use a custom construct to create a S3ToCloudfront pattern
  • Add an edge auth lambda using the EdgeFunction construct.
  • Synthesise the stack

There will be an error trying to create the edge lambda function in the us-east-1 as its not using the custom qualifier passed to the parent Main stack.

Possible Solution

Two things i can think of:

  • The EdgeFunction either needs to respect the custom qualifier given its creating a new stack
  • Or The EdgeFunction stack need to be able to take in the custom qualifier as a synthesis property
  • Or The EdgeFunction stack needs to take in the instance of synthesiser

I believe for the sake of simplicity, the first option should be the default as in most circumstances but the third offers most flexibility as we could possibly bootstrap different regions with different qualifiers.

Additional Information/Context

No response

CDK CLI Version

2.95.1

Framework Version

2.95.1

Node.js Version

18

OS

macos 14.0

Language

Typescript

Language Version

5

Other information

No response

@sachitsac sachitsac added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 30, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Sep 30, 2023
@rv2673
Copy link
Contributor

rv2673 commented Oct 1, 2023

@sachitsac
If you want to only customize qualifier, and only use single qualifier per Stage(or App if you don't have stages).

You could set context variable, @aws-cdk/core:bootstrapQualifier, on Stage/App containing the stack with EdgeLambda or in cdk.json(if it is for entire app).

Which is where synthesizer looks for value(if not provided), before falling back to default value.

(I am not from cdk team)

@sachitsac
Copy link
Author

Thanks @rv2673

I think you are right I'm passing it at the stack level. I'll try passing it at the app level. Might even resolve an issue I was having with the certificate construct where it wasn't respecting permission boundary.

Thanks

@github-actions
Copy link

github-actions bot commented Oct 1, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@sachitsac
Copy link
Author

Closed as this is resolved by @rv2673 comment. No action needed.

@rv2673
Copy link
Contributor

rv2673 commented Oct 2, 2023

@sachitsac I do think your suggestion for lambda stack to inherit the synthesizer from the containing stack still has merit, though maybe less prio. The context setting only works for qualifier customization, not for other customizations to the synthesizer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants