meta_desc: The cloud is complicated enough. With Architecture Templates, Pulumi takes on some of the work involved in deploying your application to the cloud.
meta_image: meta.png
authors:
- kat-cosgrove
tags:
- templates
- serverless
- arch-templates
---
Whether you're building a new application or moving an existing application over from another provider, the basic framework of your infrastructure probably isn't something you want to worry about if you don't have to. The cloud is complicated enough as it is. With Architecture Templates, Pulumi takes on some of the work involved in deploying your application to the cloud provider of your choice. Let's take a tour of the new Serverless Templates for AWS, GCP, and Azure!
<!--more-->
### Serverless on any Cloud, in any Language
If you need a serverless application, whether that's AWS Lambda, Google Cloud Functions, or Azure Functions, one of these templates can give you the starting point you need in any language Pulumi supports. Each template deploys a serverless function for you, with all necessary permissions to make it publicly available. While each of them does deploy a small sample function, these are designed to be extensible; we give you all the necessary tools to begin building your own application, without having to fuss around standing up the infrastructure yourself.
Generating the necessary starter code happens with a single CLI command, regardless of which cloud and language you choose:
#### AWS
{{% chooser language "typescript,python,go,csharp,yaml" / %}}
{{% choosable language typescript %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-aws-typescript
```
{{% /choosable %}}
{{% choosable language python %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-aws-python
```
{{% /choosable %}}
{{% choosable language go %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-aws-go
```
{{% /choosable %}}
{{% choosable language csharp %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-aws-csharp
```
{{% /choosable %}}
{{% choosable language yaml %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-aws-yaml
```
{{% /choosable %}}
#### GCP
{{% chooser language "typescript,python,go,csharp,yaml" / %}}
{{% choosable language typescript %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-gcp-typescript
```
{{% /choosable %}}
{{% choosable language python %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-gcp-python
```
{{% /choosable %}}
{{% choosable language go %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-gcp-go
```
{{% /choosable %}}
{{% choosable language csharp %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-gcp-csharp
```
{{% /choosable %}}
{{% choosable language yaml %}}
```bash
$ mkdir my-serverless-app && cd my-serverless-app
$ pulumi new serverless-gcp-yaml
```
{{% /choosable %}}
#### Azure
{{% chooser language "typescript,python,go,csharp,yaml" / %}}
Each of these commands will generate some boilerplate for you, and includes defaults you can accept or modify (such as the name of the project, or the application directory). Run `pulumi up` from this directory, ensuring that you've connected the [Pulumi CLI](/docs/get-started/) to your preferred cloud provider, and your starting point is online, ready for you to sub in your own application code. For the purposes of this demonstration, I've accepted the defaults. I've also left the provided application and function code in place. Let's examine what Pulumi creates for us here, using Python for AWS, Go for GCP, and Typescript for Azure.
Here Pulumi has provided an IAM execution role to use for the Lambda function, the Lambda function itself, and a REST API gateway to handle request routing. The Lambda function is pointed at an included `./function` directory, which contains a Python function that returns the latest datetime. This can be replaced with your own code, or you can change the directory the Pulumi code is pointed at to your own. Similarly, the API gateway is pointed at a `www` directory containing a simple website to display the current datetime, ready to be replaced with your own content.
Here Pulumi is defining your application's initial configuration values, including the directories it should be checking for your serverless application code and the index and error pages for the website it stands up. It then creates two storage buckets, each with appropriate IAM roles for access, one containing your serverless function and another configured to act like a website. We also have the Cloud Function declaration itself, and all configurations necessary for it, followed by exporting the URL for you.
Here, Pulumi first defines the configuration options for your project, including the directories to look at for your application code and your website, as well as what the index and error documents should be. It then goes on to set up your blob storage account and containers for your website and serverless function, before uploading the serverless function itself with all permissions and configurations necessary to operate.
{{% /choosable %}}
## Extending Templates
In addition to the Pulumi code above, each template includes a simple website that utilizes a provided serverless function to display the current time and date, constantly updating. With only two CLI commands, you have deployed the core infrastructure necessary to get your serverless application online in the cloud, without writing a single line of code yourself.
From here, you're ready to drop in your own application code. Pulumi has already handled the boring work for you, complying with best practices from the beginning so you only have to worry about building your own application, not how to get the infrastructure online!
[Pulumi Architecture Templates](/templates/) exist for a variety of applications and common use-cases, including containerized applications and kubernetes, with more being added over time. Keep an eye out for new additions and ways to make engineering for the cloud less painful!