diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd5b1ca..9f1b651 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,8 +29,8 @@ jobs: - name: Install CDK run: | - npm install -g aws-cdk-local aws-cdk - cdklocal --version + npm install -g @localstack/lstk aws-cdk + cdk --version - name: Install dependencies run: | @@ -39,16 +39,14 @@ jobs: - name: Start LocalStack env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} - DNS_ADDRESS: 0 + LOCALSTACK_DNS_ADDRESS: 0 run: | - pip install localstack awscli-local[ver1] - pip install terraform-local docker pull localstack/localstack:latest # Start LocalStack in the background - LS_LOG=trace localstack start -d + LOCALSTACK_LS_LOG=trace lstk start --non-interactive # Wait 30 seconds for the LocalStack container to become ready before timing out echo "Waiting for LocalStack startup..." - localstack wait -t 15 + lstk status echo "Startup complete" - name: Deploy using CDK @@ -58,15 +56,16 @@ jobs: AWS_ACCESS_KEY_ID: test AWS_SECRET_ACCESS_KEY: test run: | - cdklocal bootstrap aws://000000000000/us-east-1 - cdklocal deploy --all --require-approval never + lstk cdk bootstrap aws://000000000000/us-east-1 + lstk cdk deploy --all --require-approval never - name: List the resources run: | - awslocal lambda list-functions - awslocal sqs list-queues - awslocal dynamodb list-tables - awslocal stepfunctions list-state-machines + lstk setup aws --non-interactive --force + lstk aws lambda list-functions + lstk aws sqs list-queues + lstk aws dynamodb list-tables + lstk aws stepfunctions list-state-machines - name: Send a Slack notification if: failure() || github.event_name != 'pull_request' diff --git a/.github/workflows/pods.yml b/.github/workflows/pods.yml index 4cd27bc..5c34eb4 100644 --- a/.github/workflows/pods.yml +++ b/.github/workflows/pods.yml @@ -21,21 +21,18 @@ jobs: with: python-version: '3.10' + - name: Install lstk + run: npm install -g @localstack/lstk + - name: Start LocalStack - uses: LocalStack/setup-localstack@main - with: - image-tag: 'latest' - use-pro: 'true' env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + run: lstk start --non-interactive - - name: Load the Cloud Pod - uses: LocalStack/setup-localstack/cloud-pods@main - with: - name: loan-broker-infra - action: load + - name: Load the Cloud Pod env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + run: lstk snapshot load pod:loan-broker-infra - name: Run integration tests run: | diff --git a/Makefile b/Makefile index 6d967a3..d75a3f0 100644 --- a/Makefile +++ b/Makefile @@ -9,32 +9,30 @@ usage: ## Install dependencies install: - @which localstack || pip install localstack - @which awslocal || pip install awscli-local - @which cdklocal || npm install -g aws-cdk-local aws-cdk + @which lstk || npm install -g @localstack/lstk deploy: test -e node_modules || yarn; \ - cdklocal bootstrap aws://000000000000/us-east-1; \ - cdklocal deploy --all --require-approval never + lstk cdk bootstrap aws://000000000000/us-east-1; \ + lstk cdk deploy --all --require-approval never ## Start LocalStack in detached mode start: @test -n "${LOCALSTACK_AUTH_TOKEN}" || (echo "LOCALSTACK_AUTH_TOKEN is not set. Find your token at https://app.localstack.cloud/workspace/auth-token"; exit 1) - @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d + @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) lstk start --non-interactive ## Stop the Running LocalStack container stop: @echo - localstack stop + lstk stop ## Make sure the LocalStack container is up ready: @echo Waiting on the LocalStack container... - @localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1) + @lstk status && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1) ## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run. logs: - @localstack logs > logs.txt + @lstk logs > logs.txt .PHONY: usage install run start stop ready logs diff --git a/README.md b/README.md index 208c4d9..5b7d670 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ The following diagram shows the architecture that this sample application builds ## Prerequisites -- A valid [LocalStack for AWS license](https://localstack.cloud/pricing). Your license provides a [`LOCALSTACK_AUTH_TOKEN`](https://docs.localstack.cloud/getting-started/auth-token/) to activate LocalStack. -- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli). -- [Cloud Development Kit](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/) with the [`cdklocal`](https://www.npmjs.com/package/aws-cdk-local) installed. -- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/) with the [`awslocal` wrapper](https://docs.localstack.cloud/user-guide/integrations/aws-cli/#localstack-aws-cli-awslocal). +- A valid [LocalStack for AWS license](https://localstack.cloud/pricing). Your license provides a [`LOCALSTACK_AUTH_TOKEN`](https://docs.localstack.cloud/aws/getting-started/auth-token/) to activate LocalStack. +- [`lstk` CLI](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/). +- [Cloud Development Kit](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/). +- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/), required by `lstk aws`. - [Node.js](https://nodejs.org/en/download), and [`yarn`](https://yarnpkg.com/). ## Start LocalStack @@ -50,7 +50,7 @@ make start make ready ``` -We specified DEBUG=1 to get the printed LocalStack logs directly in the terminal to help us see the event-driven architecture in action. If you prefer running LocalStack in detached mode, you can add the `-d` flag to the `localstack start` command, and use Docker Desktop to view the logs. +We specified DEBUG=1 to get the printed LocalStack logs directly in the terminal to help us see the event-driven architecture in action. If you prefer running LocalStack in detached mode, you can add the `--non-interactive` flag to the `lstk start` command, and use Docker Desktop to view the logs. ## Instructions @@ -58,7 +58,7 @@ You can build and deploy the sample application on LocalStack by running our `Ma ### Deploying the application -To create the AWS infrastructure locally, you can use CDK and our `cdklocal` wrapper. Before you can deploy the infrastructure, you need to install the application dependencies: +To create the AWS infrastructure locally, you can use CDK with `lstk cdk`. Before you can deploy the infrastructure, you need to install the application dependencies: ```sh yarn @@ -67,8 +67,8 @@ yarn To deploy the infrastructure, you can run the following command: ```sh -cdklocal bootstrap -cdklocal deploy --all +lstk cdk bootstrap +lstk cdk deploy --all ``` This will deploy the `LoanBroker-RecipientList-Stack` and `LoanBroker-PubSub-Stack` stacks. You will see the following output: @@ -87,7 +87,7 @@ Take a note of the `LoanBroker-RecipientList-Stack.LoanBrokerArn` output. You wi Before you can test the application, you need to pre-populate the `LoanBrokerBanksTable` for the `RecipientsList` stack: ```sh -awslocal dynamodb put-item \ +lstk aws dynamodb put-item \ --table-name=LoanBrokerBanksTable \ --item='{ "Type": { "S": "Home" }, "BankAddress": {"L": [ { "S": "BankRecipientPremium" }, { "S": "BankRecipientUniversal" }, { "S": "BankRecipientPawnshop" } ] } }' ``` @@ -95,7 +95,7 @@ awslocal dynamodb put-item \ We can start the State Machine execution to get quotes from the banks after submitting a loan application. Run the following command: ```sh -awslocal stepfunctions start-execution \ +lstk aws stepfunctions start-execution \ --name=cli-test-run \ --state-machine-arn= \ --input="{\"SSN\": \"123-45-6789\", \"Amount\": 500000, \"Term\": 30 }" @@ -113,7 +113,7 @@ Replace `` with the `LoanBroker-RecipientList-Stack.LoanBroke You can use the Execution ARN to see the output of the State Machine execution: ```sh -awslocal stepfunctions describe-execution \ +lstk aws stepfunctions describe-execution \ --execution-arn= \ --query="output" | jq -r '. | fromjson' ``` diff --git a/package.json b/package.json index 40da200..8e34720 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@aws-sdk/util-dynamodb": "^3.301.0", "@types/jest": "^26.0.10", "@types/node": "10.17.27", - "aws-cdk": "2.70.0", + "aws-cdk": "2.1133.0", "jest": "^26.4.2", "ts-jest": "^26.2.0", "ts-node": "^9.0.0", diff --git a/yarn.lock b/yarn.lock index 800fc17..b648dcb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1583,12 +1583,10 @@ aws-cdk-lib@2.70.0: semver "^7.3.8" yaml "1.10.2" -aws-cdk@2.70.0: - version "2.70.0" - resolved "https://registry.yarnpkg.com/aws-cdk/-/aws-cdk-2.70.0.tgz#95377f7ddc8f5a0a625f5feb15e610b32b70e3cf" - integrity sha512-B12e+h8FNNS2BGgBKzKrU541shC/9CWeC1Z/CwX2NKxPgbeP2eGtgR1hCfT/VaotcfJ8+dSd4I32nNNc+wz+QA== - optionalDependencies: - fsevents "2.3.2" +aws-cdk@2.1133.0: + version "2.1133.0" + resolved "https://registry.yarnpkg.com/aws-cdk/-/aws-cdk-2.1133.0.tgz#ff1028d329939da96edeb6bfb8b1f0b975ddf378" + integrity sha512-DGlCBwqxSHTe1u/IoT5WV+Bbd2K3UhwFHsdMqb2nQa1fkJmaQgoNFu0It+p3HxyMWeW+gKsVzT5KcjQPQ6Kzuw== babel-jest@^26.6.3: version "26.6.3" @@ -2298,7 +2296,7 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@2.3.2, fsevents@^2.1.2: +fsevents@^2.1.2: version "2.3.2" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==