Skip to content

Commit

Permalink
Merge pull request #6 from fbuchlak/main
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli authored Jun 29, 2023
2 parents b12804b + 4f5987e commit ab01888
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function functionLayer(

return LayerVersion.fromLayerVersionArn(
scope,
'BrefFunctionLayer',
'Bref001FunctionLayer',
functionLayerArn(region, phpVersion, platform)
);
}
Expand All @@ -27,11 +27,11 @@ export function fpmLayer(

return LayerVersion.fromLayerVersionArn(
scope,
'BrefFpmLayer',
'Bref101FpmLayer',
fpmLayerArn(region, phpVersion, platform)
);
}

export function consoleLayer(scope: Construct, region: string): ILayerVersion {
return LayerVersion.fromLayerVersionArn(scope, 'BrefConsoleLayer', consoleLayerArn(region));
return LayerVersion.fromLayerVersionArn(scope, 'Bref201ConsoleLayer', consoleLayerArn(region));
}
15 changes: 15 additions & 0 deletions test/function/ConsoleFunction.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import { ConsoleFunction } from '../../src';
import { compileTestStack } from '../helper';
import { cx_api } from 'aws-cdk-lib';
import { Architecture } from 'aws-cdk-lib/aws-lambda';
import { mapValues } from 'lodash';

Expand All @@ -19,6 +20,20 @@ describe('ConsoleFunction', () => {
expect(layers[1]).to.match(/arn:aws:lambda:us-east-1:534081306603:layer:console:\d+/);
});

it('adds the console layer with recognizeLayerVersion flag', () => {
const template = compileTestStack((stack) => {
new ConsoleFunction(stack, 'Console', {
handler: 'index.php',
});
}, { context: { [cx_api.LAMBDA_RECOGNIZE_LAYER_VERSION]: true } });

const consoleFunction = template.findResources('AWS::Lambda::Function');
const layers = consoleFunction.Console63CA37A7.Properties.Layers;
expect(layers).length(2);
expect(layers[0]).to.match(/arn:aws:lambda:us-east-1:534081306603:layer:php-81:\d+/);
expect(layers[1]).to.match(/arn:aws:lambda:us-east-1:534081306603:layer:console:\d+/);
});

it('supports ARM', () => {
const template = compileTestStack((stack) => {
new ConsoleFunction(stack, 'Console', {
Expand Down
7 changes: 4 additions & 3 deletions test/helper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Stack } from 'aws-cdk-lib';
import { App, AppProps, Stack } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import { mapValues } from 'lodash';

export function compileTestStack(definition: (stack: Stack) => void): Template {
const stack = new Stack(undefined, 'app', {
export function compileTestStack(definition: (stack: Stack) => void, appProps: AppProps = undefined): Template {
const app = new App(appProps);
const stack = new Stack(app, 'app', {
env: { region: 'us-east-1' },
});
definition(stack);
Expand Down

0 comments on commit ab01888

Please sign in to comment.