-
Notifications
You must be signed in to change notification settings - Fork 4
Properly orders php layers to allow extension #4
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
Closed
FlorianRiquelme
wants to merge
2
commits into
brefphp:main
from
FlorianRiquelme:properly-orders-php-layers-to-allow-extension
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,48 @@ | ||
| import { Stack } from 'aws-cdk-lib'; | ||
| import {Duration, Stack} from 'aws-cdk-lib'; | ||
| import { Construct } from 'constructs'; | ||
| import { consoleLayer } from '../layers'; | ||
| import { PhpFunction, PhpFunctionProps } from './PhpFunction'; | ||
| import {consoleLayer, functionLayer} from '../layers'; | ||
| import {Function, FunctionProps, Runtime} from "aws-cdk-lib/aws-lambda"; | ||
| import {IVpc} from "aws-cdk-lib/aws-ec2"; | ||
| import {VpcForServerlessApp} from "../vpc/VpcForServerlessApp"; | ||
| import {functionDefaults, vpcDefaults} from "./defaults"; | ||
| import {packagePhpCode} from "../package"; | ||
|
|
||
| export class ConsoleFunction extends PhpFunction { | ||
| constructor(scope: Construct, id: string, props: PhpFunctionProps) { | ||
| super(scope, id, props); | ||
| export type PhpConsoleFunctionProps = Partial<FunctionProps> & { | ||
| phpVersion?: '8.0' | '8.1' | '8.2'; | ||
| handler: string; | ||
| vpc?: IVpc | VpcForServerlessApp; | ||
| }; | ||
|
|
||
| this.addLayers(consoleLayer(this, Stack.of(scope).region)); | ||
| export class ConsoleFunction extends Function { | ||
| constructor(scope: Construct, id: string, props: PhpConsoleFunctionProps) { | ||
| const defaults = { | ||
| runtime: Runtime.PROVIDED_AL2, | ||
| code: props.code ?? packagePhpCode(), | ||
| timeout: Duration.seconds(6), | ||
| memorySize: functionDefaults.memorySize, | ||
| }; | ||
|
|
||
| const layers = props.layers ?? []; | ||
|
|
||
| super(scope, id, { | ||
| ...props, | ||
| ...vpcDefaults(props.vpc), | ||
| layers: [], | ||
| ...defaults, | ||
| }); | ||
|
|
||
| this.addLayers( | ||
| ...layers, | ||
| consoleLayer( | ||
| this, | ||
| Stack.of(scope).region | ||
| ), | ||
| // Adds the function layer last so that others(in this case console depends on it) can override it | ||
| functionLayer( | ||
| this, | ||
| Stack.of(scope).region, | ||
| props.phpVersion ?? functionDefaults.phpVersion, | ||
| props.architecture ?? functionDefaults.architecture) | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking into this but I really don't understand how this could be what we want 🤔
The test ensures that the console layer is first, but it should be last, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been testing with
masterand it is working out fine, here is the CloudFormation template output:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested the deployed function and everything was working correctly. TBH I don't think there is a problem to solve?
Maybe you are on a bugged CDK version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: another report here: brefphp/bref#1580
Not sure why I can't reproduce this, this is so weird!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I am (and still am) on vacation, I'll try to keep a closer eye on this conversation :)
Using the
ConsoleFunctionfrom the constructs yields the same result that you are seeing, deployed the layers are still reversed for me.Now the interesting part: If i create a lambda function myself and setting the layers property to use php first and then console, the CF template looks the same(console first, php last), but deployed it is now in the correct order. 😕
I used cdk version
2.8.0initially and just checked with the latest2.8.5and the behaviour is still the same