Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ jobs:
- name: Execute tests
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
DEBUG: 1
LOCALSTACK_DEBUG: 1
timeout-minutes: 100
run: make test-ci-all
3 changes: 2 additions & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ usage: ## Show this help

start: ## Start LocalStack
@test -n "${LOCALSTACK_AUTH_TOKEN}" || (echo "LOCALSTACK_AUTH_TOKEN is not set" && exit 1);
DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) $(LSTK) start
LOCALSTACK_DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) $(LSTK) start
$(LSTK) setup aws --force

stop: ## Stop LocalStack
$(LSTK) stop
Expand Down
3 changes: 1 addition & 2 deletions s3-static-website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ The `deploy.ps1` script supports the following switches:
- `-Deploy`: Creates a bucket, sets a bucket policy, syncs a local directory to the bucket, and sets up a website on the bucket.
- `-Start`: Starts LocalStack in detached mode.
- `-Stop`: Stops LocalStack.
- `-Ready`: Waits for LocalStack to be ready for use.
- `-Logs`: Writes LocalStack logs to a text file.

For example, to install dependencies and start LocalStack, you would run:

```powershell
.\deploy.ps1 -InstallDependencies -Start -Ready -Deploy
.\deploy.ps1 -InstallDependencies -Start -Deploy
```

### Makefile
Expand Down
35 changes: 9 additions & 26 deletions s3-static-website/deploy.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# This script is used to deploy the static website to LocalStack S3 bucket.
# It uses the LocalStack CLI to start the LocalStack container, wait for it to be ready, create an S3 bucket, upload the website files to the bucket, and configure the bucket as a static website.
# It uses the lstk CLI to start the LocalStack container, create an S3 bucket, upload the website files to the bucket, and configure the bucket as a static website.

param(
[switch]$InstallDependencies,
[switch]$Deploy,
[switch]$Start,
[switch]$Stop,
[switch]$Ready,
[switch]$Logs
)

Expand All @@ -20,34 +19,18 @@ function Deploy-Website {
[switch]$Deploy,
[switch]$Start,
[switch]$Stop,
[switch]$Ready,
[switch]$Logs
[switch]$Logs
)

if ($InstallDependencies) {
if (-not (Get-Command -Name 'localstack' -ErrorAction SilentlyContinue)) {
pip install localstack
Write-Host "LocalStack CLI installed successfully!"
}
if (-not (Get-Command -Name 'lstk' -ErrorAction SilentlyContinue)) {
pip install awscli-local
Write-Host "AWS CLI installed successfully!"
npm install -g @localstack/lstk
Write-Host "lstk CLI installed successfully!"
}
}

if ($Start) {
localstack start -d
}

if ($Ready) {
Write-Host "Waiting on the LocalStack container..."
localstack wait -t 30
if ($?) {
Write-Host "Localstack is ready to use!"
} else {
Write-Host "Gave up waiting on LocalStack, exiting."
exit 1
}
lstk start
}

if ($Deploy) {
Expand All @@ -59,15 +42,15 @@ function Deploy-Website {
}

if ($Stop) {
localstack stop
lstk stop
}
if ($Logs){
localstack logs > logs.txt
lstk logs > logs.txt
}
}

# You can just run all the tasks in one go by calling the function with all the switches set to $true.
# .\deploy.ps1 -InstallDependencies -Start -Ready -Deploy -Logs -Stop
Deploy-Website -InstallDependencies:$InstallDependencies -Deploy:$Deploy -Start:$Start -Stop:$Stop -Ready:$Ready -Logs:$Logs
# .\deploy.ps1 -InstallDependencies -Start -Deploy -Logs -Stop
Deploy-Website -InstallDependencies:$InstallDependencies -Deploy:$Deploy -Start:$Start -Stop:$Stop -Logs:$Logs


2 changes: 1 addition & 1 deletion sample-archive/apigateway-appsync-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ More about it [here](https://docs.localstack.cloud/user-guide/aws/appsync/#graph
Start LocalStack with a specific endpoint configuration:

```bash
GRAPHQL_ENDPOINT_STRATEGY=domain localstack start
LOCALSTACK_GRAPHQL_ENDPOINT_STRATEGY=domain lstk start
```

```bash
Expand Down
2 changes: 1 addition & 1 deletion sample-archive/apigateway-appsync-integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
set -x

rm terraform.tfstate* || true
tflocal init; tflocal apply --auto-approve
lstk tf init; lstk tf apply --auto-approve

restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
curl -X POST "http://$restapi.execute-api.us-east-1.localhost.localstack.cloud:4566/dev/graphql"
2 changes: 1 addition & 1 deletion sample-archive/apigateway-aws-lambda/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -x

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)

Expand Down
12 changes: 6 additions & 6 deletions sample-archive/apigateway-cognito-authorizer/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

set -x

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

client_id=$(tflocal output -json | jq -r .user_pool_client_id.value)
pool_id=$(tflocal output -json | jq -r .user_pool_id.value)
client_id=$(lstk tf output -json | jq -r .user_pool_client_id.value)
pool_id=$(lstk tf output -json | jq -r .user_pool_id.value)

sleep 5

secret=$(awslocal cognito-idp --endpoint-url=http://localhost:4566 describe-user-pool-client --user-pool-id $pool_id --client-id $client_id | jq -r .UserPoolClient.ClientSecret)
secret=$(lstk aws cognito-idp --endpoint-url=http://localhost:4566 describe-user-pool-client --user-pool-id $pool_id --client-id $client_id | jq -r .UserPoolClient.ClientSecret)
hash=$(python secret_hash.py test@localstack.com $client_id $secret)

access_token=$(awslocal cognito-idp initiate-auth --auth-flow USER_PASSWORD_AUTH --client-id $client_id --auth-parameters USERNAME="test@localstack.com",PASSWORD="L0c4lst4ck!",SECRET_HASH=$hash | jq -r .AuthenticationResult.AccessToken)
access_token=$(lstk aws cognito-idp initiate-auth --auth-flow USER_PASSWORD_AUTH --client-id $client_id --auth-parameters USERNAME="test@localstack.com",PASSWORD="L0c4lst4ck!",SECRET_HASH=$hash | jq -r .AuthenticationResult.AccessToken)

restapi=$(awslocal apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
restapi=$(lstk aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
curl $restapi.execute-api.localhost.localstack.cloud:4566/local/demo -H "X-Auth-Token: Bearer $access_token"
2 changes: 1 addition & 1 deletion sample-archive/apigateway-custom-domain/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -x

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
curl $restapi.execute-api.localhost.localstack.cloud:4566/dev/test -H "Host: api.example.com"
2 changes: 1 addition & 1 deletion sample-archive/apigateway-eventbridge-integration/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

tflocal init; tflocal plan; tflocal apply -auto-approve
lstk tf init; lstk tf plan; lstk tf apply -auto-approve

restapi=$(aws --endpoint-url=http://localhost:4566 apigateway get-rest-apis | jq -r .items[0].id)
curl --location --request POST "$restapi.execute-api.localhost.localstack.cloud:4566/local/orders" --header 'Content-Type: application/json' \
Expand Down
2 changes: 1 addition & 1 deletion sample-archive/apigateway-lambda-proxy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -x

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
curl -X POST $restapi.execute-api.localhost.localstack.cloud:4566/dev/1
2 changes: 1 addition & 1 deletion sample-archive/apigateway-openapi-3.0-import/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -x

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
curl -vvv "$restapi.execute-api.localhost.localstack.cloud:4566/dev/api/v1/user/techops+proviosion@gmail.com" -H "X-Authorization: allow"
Expand Down
2 changes: 1 addition & 1 deletion sample-archive/apigateway-rest-lambda-api-key/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export TF_LOG=trace
rm terraform.tfstate* || true

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
apikeyid=$(aws apigateway --endpoint-url=http://localhost:4566 get-api-keys | jq .items[].id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

rm terraform.tfstate || true

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id)
curl -v -H "Content-Type: application/json" -d "{\"httpStatus\": \"400\", \"errorMessage\": \"Test Bad request\"}" "https://$restapi.execute-api.localhost.localstack.cloud:4566/dev/products/abcd-1234/items?status=PENDING\&limit=100"
2 changes: 1 addition & 1 deletion sample-archive/apigatewayv2-http-referer-header/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Both routes do the exact same thing: Return a JSON object of the form

1. Get the LocalStack API Gateway endpoint for the API:
```
$ awslocal apigatewayv2 get-apis
$ lstk aws apigatewayv2 get-apis
{
"Items": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

rm -rf terraform.tfstate* || true

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

secret_token=$(terraform output -raw secret_token)
user_pool_client_id=$(terraform output -raw user_pool_client_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

rm -rf terraform.tfstate* || true

tflocal init; tflocal plan; tflocal apply --auto-approve
lstk tf init; lstk tf plan; lstk tf apply --auto-approve

secret_token=$(terraform output -raw secret_token)
user_pool_client_id=$(terraform output -raw user_pool_client_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

terraform init; terraform plan; terraform apply --auto-approve

awslocal lambda invoke --function-name bash-runtime --payload '{"text":"Hello"}' response.txt
lstk aws lambda invoke --function-name bash-runtime --payload '{"text":"Hello"}' response.txt


api_id=$(aws --endpoint-url=http://localhost:4566 apigatewayv2 get-apis | jq -r .Items[0].ApiId)
Expand Down
2 changes: 1 addition & 1 deletion sample-archive/cloudposse-msk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This example requires LocalStack Pro.
Once you have started LocalStack, proceed to prepare a route53 zone:

```sh
awslocal route53 create-hosted-zone \
lstk aws route53 create-hosted-zone \
--name my-kafka.localhost.localstack.cloud \
--caller-reference cli-invocation-0
```
Expand Down
6 changes: 3 additions & 3 deletions sample-archive/s3-lambda-sqs-notification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* The lambda sends messages to SQS depending on log processing logic

```bash
awslocal s3 cp example-app.log s3://app-logs-structured/example-app-01.log
lstk aws s3 cp example-app.log s3://app-logs-structured/example-app-01.log

awslocal sqs receive-message --wait-time-seconds 20 \
lstk aws sqs receive-message --wait-time-seconds 20 \
--queue-url http://localhost:4566/000000000000/alerts-queue \
| jq -r ".Messages[0].Body"

awslocal sqs receive-message --wait-time-seconds 20 \
lstk aws sqs receive-message --wait-time-seconds 20 \
--queue-url http://localhost:4566/000000000000/alerts-queue \
| jq -r ".Messages[0].Body"
```
Expand Down
6 changes: 3 additions & 3 deletions sample-archive/s3-lambda-sqs-notification/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ terraform apply --auto-approve

# run test

awslocal s3 cp example-app.log s3://app-logs-structured/example-app-01.log
lstk aws s3 cp example-app.log s3://app-logs-structured/example-app-01.log

awslocal sqs receive-message --wait-time-seconds 20 \
lstk aws sqs receive-message --wait-time-seconds 20 \
--queue-url http://localhost:4566/000000000000/alerts-queue \
| jq -r ".Messages[0].Body"

awslocal sqs receive-message --wait-time-seconds 20 \
lstk aws sqs receive-message --wait-time-seconds 20 \
--queue-url http://localhost:4566/000000000000/alerts-queue \
| jq -r ".Messages[0].Body"
Loading