Gerard van den Bosch

IT Specialist

WordPress Front page include multiple page

In WordPress a static front page can be created by using the file front-page.php, we can give this front page a template name in following way:

/**
* Template Name: Front Page
*/

Then when we create a page for example Home, configure it as a static page and select the template Front Page. This will then include the Home page in the front page and call the post content by simply doing this:

<?php 
//title
echo the_title();
//content
echo the_content();
?>

This all works fine for one page, but in case we want to include content from multiple pages in the Front Page this doesn’t work.

However it can be done by adding some custom code to the front-page.php file.

Continue reading

SAM CLI restrict API Gateway access

When deploying a Serverless with SAM CLI, normally SAM CLI will create an API Gateway instance automatically.

API Gateway has three modes PRIVATE , REGIONAL or EDGE. In a PRIVATE configuration the API gateway is restricted to a IAM resource or a VPC, this article handles a public API gateway which can be REGIONAL or EDGE.

The goal is to restrict a public API Gateway access to a certain IP address.

Continue reading

Multiple Serverless Offline instances

Serverless framework uses AWS CloudFormation to deploy the designed application. Cloudformation has a hard limit of 500 components in order to force the developer to design micro services and not creating a mega project.

This leads to multiple serverless projects as backend in a large project. The frontend will call the backend project it needs.

In order to test this on the developer’s computer, Serverless Offline can be used. This will simulate the lambda functions on the local computer and provides a local HTTP server interface for the frontend to interact with.

When the frontend needs to interact with multipe backend projects we can start multiple Serverless Offline instances. However for this we will need to adjust the port numbers.

Continue reading

Lambda NodeJS HTML to PDF Conversion

Most HTML to PDF conversion or creation libraries have system dependencies. Because in Lambda we only have the code and Lambda itself takes care of the underlying infrastructure, we can not install dependencies, however there is a solution to this.

By using Lambda Layers an environment can be created for an executable which can interact with the system itself. The well known library wkhtmltopdf has a zip archive for a Lambda Layer available.

The Lambda Layer will be consumed by a Lambda function which will call the binary inside the Lambda Layer in order to do the actual conversion.

This all can be setup in a few simple steps.

Continue reading