Skip to content

Commit fccc0e1

Browse files
giogranothrau
authored andcommitted
Prepare AWS Builders Day Zuerich
1 parent c0aac67 commit fccc0e1

8 files changed

+72
-19
lines changed

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "image-resizer-sample"]
2+
path = image-resizer-sample
3+
url = https://github.com/localstack/serverless-image-resizer
4+
[submodule "full-sample-pods-ci"]
5+
path = full-sample-pods-ci
6+
url = https://github.com/giograno/serverless-api-ecs-apigateway-sample

README.md

+26-19
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,56 @@ Repository with code samples for the LocalStack workshop.
44

55
Note: The project can either be cloned and installed on your local machine, or you can spin up a remote development environment (Gitpod, or Github Codespaces) to access the project directly from your browser.
66

7-
* **Option 1:** Open project in [Github Codespaces](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=630930347)
8-
* **Option 2:** Open project in [Gitpod](https://gitpod.io/#https://github.com/localstack/localstack-workshop)
9-
* **Option 3:** Run project locally (see instructions below)
7+
* **Option 1:** Open the project in [Github Codespaces](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=630930347)
8+
* **Option 2:** Open the project in [Gitpod](https://gitpod.io/#https://github.com/localstack/localstack-workshop)
9+
* **Option 3:** Run the project locally (see instructions below)
1010

1111
## Prerequisites
1212

1313
* Docker
1414
* Python/`pip`
15-
* Node/`npm` (for CDK tooling)
1615
* LocalStack Pro API key ([free trial key here](https://app.localstack.cloud))
1716

18-
## Installation
17+
## Installation & Getting Started
18+
19+
LocalStack can be started in [different ways](https://docs.localstack.cloud/getting-started/installation/).
20+
The easiest way (the one we recommend) is through the [LocalStack CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli).
1921

2022
First, install the LocalStack command-line interface (CLI):
2123
```
2224
pip install localstack
2325
```
24-
Then we start the LocalStack container locally:
26+
Then we can simply start the LocalStack container locally:
2527
```
2628
export LOCALSTACK_API_KEY=... # insert your API key here
2729
DEBUG=1 localstack start
2830
```
2931

30-
Additionally, we're also installing the following packages, to make the [`awslocal`](https://github.com/localstack/awscli-local), [`tflocal`](https://github.com/localstack/terraform-local) and [`cdklocal`](https://github.com/localstack/aws-cdk-local) commands available:
32+
Once LocalStack is running in the Docker container, we can issue CLI commands to create and interact with AWS resources. Let's say, for instance, that we want to create a S3 bucket.
33+
If you have the [AWS Command Line Interface](https://aws.amazon.com/cli/) installed on your machine, you can simply type:
3134
```
32-
pip install awscli-local[ver1] terraform-local
33-
npm install -g aws-cdk-local aws-cdk
35+
aws --endpoint=http://localhost.localstack.cloud:4566 s3 mb s3://demo-bucket
3436
```
3537

36-
## Workshop Sections
37-
38-
### Part 1: Getting Started - Serverless Apps
38+
To make things simpler, you might want to install [`awslocal`](https://github.com/localstack/awscli-local), i.e., our wrapper around the AWS CLI. This way, you don't need to set up the endpoint for every CLI command. The previous command would just be:
39+
```
40+
awslocal s3 mb s3://demo-bucket
41+
```
3942

40-
...
43+
You can create and browse resources in LocalStack also from the research browser.
44+
Simply, go to our [Web App](https://app.localstack.cloud/), log in, and click on _Resources_ in the top navigation bar. You will gain access to our research browser, where each service has a console to manage its resources.
4145

42-
### Part 2: Infrastructure-as-Code Tools
46+
### Hello World
4347

44-
...
48+
Every programming language tutorial starts with printing a _Hello World_. Let us have the [equivalent](https://github.com/localstack/localstack-workshop/tree/update-after-aws-zurich/hello-world) in LocalStack.
4549

46-
### Part 3: LocalStack in CI Pipelines
50+
## Deploy a Serverless App on LocalStack
4751

48-
...
52+
It's time now to deploy a meaningful [serverless application](https://github.com/localstack/serverless-image-resizer/tree/a882f4c050dd8ec4594c35fa5002d4db31c5a834).
4953

50-
### Part 4: LocalStack Persistence and Cloud Pods
54+
## Infrastructure-as-Code Tools - Cloud Pods - LocalStack in CI
5155

52-
...
56+
We mostly interacted with LocalStack through the CLI so far.
57+
However, large systems are hardly built this way.
58+
Luckily, LocalStack supports a [wide range of integrations](https://docs.localstack.cloud/user-guide/integrations/) that will cover your favorite Infrastructure-as-Code (IaC) tool.
59+
In the following [sample](https://github.com/giograno/serverless-api-ecs-apigateway-sample/tree/4bae4b7920da518034237bd95d6b6d0ab607a29d), we will first deploy a complex application with either Terraform or CloudFormation. Then, we will write a small unit test. Finally, we will close the loop by deploying and testing this app in CI with LocalStack.

full-sample-pods-ci

Submodule full-sample-pods-ci added at 4bae4b7

hello-world/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Hello World in LocalStack
2+
3+
This simple serverless app is the Hello World of LocalStack.
4+
It will deploy an s3 static website with a simple _"Hello World"_.
5+
6+
For more information, visit our [docs](https://docs.localstack.cloud/tutorials/s3-static-website-terraform/).
7+
8+
## How to run
9+
10+
Simply start LocalStack with `localstack start -d` and then run the `deploy.sh` script.
11+
12+
**Note**: If you are executing in Github Codespaces, you can right-click on port 4566, then "Copy Local Address", and then append the suffix /testwebsite/index.html to the URL. For example, the final URL may look something like this: https://yourusername-vigilant-umbrella-q94554wwv-4566.preview.app.github.dev/testwebsite/index.html

hello-world/bucket-policy.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Sid": "PublicReadGetObject",
6+
"Effect": "Allow",
7+
"Principal": "*",
8+
"Action": "s3:GetObject",
9+
"Resource": "arn:aws:s3:::aws-day/*"
10+
}
11+
]
12+
}

hello-world/deploy.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
awslocal s3api create-bucket --bucket testwebsite
4+
5+
awslocal s3api put-bucket-policy --bucket testwebsite --policy file://bucket-policy.json
6+
7+
awslocal s3 sync ./ s3://testwebsite
8+
9+
awslocal s3 website s3://testwebsite/ --index-document index.html
10+
11+
echo "Visit http://testwebsite.s3-website.localhost.localstack.cloud:4566/"

hello-world/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<html>
2+
Hello world
3+
</html>

image-resizer-sample

Submodule image-resizer-sample added at a882f4c

0 commit comments

Comments
 (0)