DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Latest Articles - DZone

article thumbnail
An Introduction to AWS Step Functions
In this blog, you will get a short introduction into AWS Step Functions. You will also create a workflow from scratch with a lambda. The output of the lambda will be transformed so that it can be used in the workflow. 1. Introduction AWS Step Functions is a low-code, visual workflow service in order to build applications. The goal is to focus on the business logic and to combine services with each other in a visual way. You can make use drag-and-drop in order to create a workflow and to integrate services. More information about AWS Step Functions can be found at the AWS website. The easiest way to discover how it looks like, is to create a workflow by yourself and that is exactly what you are going to do. In the remainder of this blog, you will create an AWS Lambda which has been used in previous blogs. So, you do not need to develop the lambda yourself, you can just make use of it. Around this lambda you will create a workflow. During this exercise, you will encounter some problems which will be solved along the way. 2. Create Lambda In this section, you will create the lambda which will be used in the workflow. Navigate to the AWS Lambda service and click the Create Function button. Choose Author from scratch, give the lambda the name MyStepFunctionsLambda and choose as runtime Java 11 (Corretto). Click the Create function button. Download the jar file of the lambda from the releases page at GitHub. In the Code source section, choose for .zip or .jar file from the Upload from dropdown box. Upload the jar file and click the Save button. In the Runtime settings section, click the Edit button. Fill the following text in the Handler input field. Shell com.mydeveloperplanet.myawslambdajavaplanet.LambdaJava::handleRequest Click the Save button. In order to verify whether the lambda functions properly, just click the Test button in the Test tab. As a response "Version 1" is returned. The lambda also can take a JSON as input and will log some data, but you will not use this functionality in this blog. 3. Create Workflow In this section, you will create a basic workflow which will only invoke the lambda function. Navigate to the Step Functions service and click the Create state machine button. In Step 1, choose for Design your workflow visually and choose the Standard type. Click the Next button. In Step 2, the visual workflow designer is shown. Drag the AWS Lambda Invoke component from the Actions menu to Drag first state here in the form. On the right submenu Configuration, navigate to the API parameters section and choose from the dropdown list the MyStepFunctionsLambda as Function name. Click the Next button. In Step 3, the generated code can be reviewed. Besides creating the workflow by means of the visual designer, it is also possible to create the workflow by means of a JSON configuration file. It is less easy to follow the flow when the workflow starts getting a bit more complex, but for small workflows it is quite ok. Besides that, the JSON file can be put into version control which allows you to track the changes made to the workflow. Click the Next button. In Step 4, give the workflow the name MyFirstStepFunctions, scroll to the bottom of the page and click the Create state machine button. Click the Start execution button. A popup window is shown where you can enter some input for the workflow. Leave it as default and click the Start execution button. The workflow is executed and when the lambda is successful, it is marked as green. Click the Step output tab and notice that the expected lambda output is shown. It might be that the following error occurs after executing the step function. Just, wait a bit and try a second time and probably it will work then. Shell Neither the global service principal states.amazonaws.com, nor the regional one is authorized to assume the provided role. 4. Add Choice State The above workflow is quite simple, so let’s try to add a Choice after the lambda which will set the workflow to a success state when Version 1 is returned from the lambda and otherwise the workflow will be set to a failed state. At the top of the page, click the Edit button. In the Edit screen, click the Workflow studio button. In the left menu, select the Flow tab and drag the Choice component between the lambda and the End state. Next, drag the Success component in branch Rule #1 and drag the Fail component in branch Default. Select the Choice component and click the Edit icon in the Configuration tab next to Rule #1. The configuration for Rule #1 is expanded. Click the Add conditions button. In the popup window, the condition for Rule #1 can be configured. Here a problem arises in combination with the lambda you use. The lambda outputs a string as value, but the Variable for the condition must make use of a JsonPath. This means that the lambda should output a JSON instead of a string. Let’s assume for a moment that the lambda will output a version JSON parameter containing the text of the version and when the lambda outputs Version 1, the workflow should be successful. Click the Save conditions button. Next, click the Apply and exit button in order to save the workflow in the visual designer. Strange thing is that after this, the workflow is not yet saved. So, do not forget to click the Save button in the workflow screen. A warning is shown, click the Save anyway button. Start the execution of the workflow. The workflow fails, which is not directly visible from the workfow itself but in the event log below the workflow. The error in the event log. JSON { "error": "States.Runtime", "cause": "An error occurred while executing the state 'Choice' (entered at the event id #7). Invalid path '$.version': The choice state's condition path references an invalid value." } 5. Transform Lambda Output Two options exist now in order to fix the problem with the lambda output: Adapt the lambda in order that it outputs a JSON; Transform the lambda output in the workflow. The last option is chosen here, because when you have to change the code of the lambda each time you need something specific for a workflow, you do not have much benefit of a low-code platform. Navigate to the Workfow Studio, select the lambda and select the Output tab. In this tab, an example is shown of the lambda task result. Copy the contents of this example. In the left menu, choose for Data flow simulator. With this tool it is possible to test the different transformations you want to create. Click the Task Result tab and paste the task result example into the Task result field. In the example, the payload is not the output of the lambda you are using. Therefore, change the payload from: JSON "Payload": { "foo": "bar", "colors": [ "red", "blue", "green" ], "car": { "year": 2008, "make": "Toyota", "model": "Matrix" } }, into: JSON "Payload": "Version 1", Click the ResultSelector tab and paste the following transformation in the ResultSelector field. JSON { "version.$": "$.Payload" } As can be seen in the fields at the bottom of the page, the transformation is exactly what is expected. Now that you know that the transformation is correct, navigate again to the workflow via the Workflow Studio. Select the lambda and the Output tab. Enable Transform result with ResultSelector and paste the transformation JSON into the field. Also, disable Filter output with OutputPath because the output is already in the correct format after the ResultSelector. Save the workflow as you did before and execute the workflow. The success branch is now entered, just as expected. More information about transformations can be found here. 6. Error Handling As seen before, when something goes wrong during execution of the workflow, the workflow does not end gracefully. First, let’s fail the lambda. Navigate to the lambda service, select the lambda and edit the Runtime settings. Remove for example something from the Handler path. In the example below .LambdaJava is removed. Test the lambda and it will fail. Navigate to the workflow again and execute the workflow. The lambda fails, but the workflow does not end gracefully. Edit the workflow, select the lambda and select the Error Handling tab. Click the Add new catcher button. In the Errors field choose for States.ALL in order to catch all failures. In the Fallback state field choose for Add new state. Drag a Fail component after the catch and give it the name Fail after error. Save the workflow and execute it. The workflow now ends gracefully. 7. Conclusion In this blog, AWS Step Functions were introduced mainly by means of an example. The visualization and low-code functions will have their use cases but I do prefer plain coding than a tool like this. It can become quite complex when workflows become large and I doubt that you will have enough overview of what is happening where. Especially when you start transforming inputs and outputs in the workflow. So, it is a nice service of AWS but I do not think I will ever use this.
March 30, 2022
by Gunter Rotsaert DZone Core CORE
· 5,178 Views · 5 Likes
article thumbnail
Designing Your First GraphQL Schema
When designing a GraphQL schema, it's important to know your users, map out a graph of your application, design for specific use cases, and be specific with naming.
March 30, 2022
by Ceora Ford
· 5,031 Views · 5 Likes
article thumbnail
Monitor Kubernetes Events With Falco For Free
Kubernetes is the predilection platform of orchestration. Ensuring the security of the managed resources is essential. In this article, see how Falco can help.
March 30, 2022
by Nicolas Giron
· 7,509 Views · 8 Likes
article thumbnail
Managed vs. Self-Hosted CI/CD
Should your CI/CD system be self-hosted or a managed service? Before deciding which path to take, consider the tradeoffs and advantages of both approaches.
March 30, 2022
by Eric Goebelbecker DZone Core CORE
· 9,697 Views · 2 Likes
article thumbnail
2 Billion MySQL Records
Handling 2 billion MySQL records is actually possible. Sure, you'll need a monster server, and zero indexes or foreign keys during import, but it is possible.
March 30, 2022
by Thomas Hansen DZone Core CORE
· 10,339 Views · 7 Likes
article thumbnail
Automated Tests: You Are Doing It Wrong [Comic]
Over-Engineering: You Are Doing It Right
March 30, 2022
by Daniel Stori DZone Core CORE
· 9,724 Views · 3 Likes
article thumbnail
Building a Buy Now, Pay Later Payment Solution
Convenient payment options often lure customers to buy sooner. See how quick and easy this can be using the Marqeta platform.
March 30, 2022
by John Vester DZone Core CORE
· 115,753 Views · 4 Likes
article thumbnail
Next-Gen Data Pipes With Spark, Kafka, and K8s: Part 2
This detailed guide reviews the Kafka-K8s combination, shares codebases for building new-age data pipes, and looks at various cloud environment implementations.
Updated March 29, 2022
by Abhishek Sinha
· 9,738 Views · 4 Likes
article thumbnail
Release of ActiveMQ v5.17.0
This article takes a look at the new ActiveMQ release: v5.17.0, which is a baseline for modernization and sets the stage for what's to come in future releases.
March 29, 2022
by Matt Pavlovich
· 3,357 Views · 3 Likes
article thumbnail
How To Store File or Retrieve File To/From a Database Table Using JDBC Program?
In the below video tutorial, take a closer look at how to store files or retrieve files to/from a database table using JDBC Program.
March 29, 2022
by Ram N
· 3,471 Views · 4 Likes
article thumbnail
Getting Started With Storing Vue Data in Vuex
Let's look at how to use Vuex to start storing all your Vue data in a single place.
March 29, 2022
by Johnny Simpson
· 3,150 Views · 3 Likes
article thumbnail
4 Key Flow Metrics for Agile Teams
This post shows how to make software delivery faster, smoother, and more reliable with a flow engineering metrics approach.
Updated March 29, 2022
by Ralf Huuck
· 5,123 Views · 6 Likes
article thumbnail
Uploading, Modifying, and Viewing Video Files with the DailyMotion API
This article explores how through three-component APIs, you can access most, if not all, aspects of Dailymotion.
March 29, 2022
by Gilad David Maayan
· 7,486 Views · 2 Likes
article thumbnail
Multi-Threading and Spring Transactions
Developers apply @Transactional annotation provided by the Spring framework and rely on the implemented mechanisms for transaction management. Is this enough?
March 29, 2022
by Daniela Kolarova DZone Core CORE
· 22,733 Views · 14 Likes
article thumbnail
Why a Site Reliability Engineer Is Important to Your CI/CD Pipeline
Written from firsthand SRE experience, this article touches on the importance of SREs and some of the key benefits of their involvement in the CI/CD pipeline.
March 29, 2022
by Alireza C
· 9,095 Views · 4 Likes
article thumbnail
Internationalizing Your Lightning Web Component (LWC)
Even if your LWC does not require internationalization now, it doesn’t hurt to follow the i18n pattern and maintain DRY compliance. Plus it’s easy, too.
March 29, 2022
by John Vester DZone Core CORE
· 51,377 Views · 3 Likes
article thumbnail
What Is Mysqld?
In this article, learn about MySQL daemon, also known as mysqld. Why do developers care about it, and what does it do? Read here to find out the answers.
March 29, 2022
by Everett Berry
· 5,694 Views · 3 Likes
article thumbnail
Functional Interface Explained in Detail Introduced From Java 8
In this article, explore functional interface introduced in Java 8.
Updated March 29, 2022
by Amit Datta
· 70,519 Views · 16 Likes
article thumbnail
7 Factors to Consider When Choosing a Network Performance Solution
A high-performing network is integral for the maintenance of a functioning IT infrastructure in any modern company. Here are seven factors to consider.
March 29, 2022
by Matthew Cooper
· 5,258 Views · 2 Likes
article thumbnail
Old Habits Die Hard, But Getting New Ones is Essential. Tips on Getting the Most Out of TypeScript
This article looks at the main reasons why TypeScript is so popular with developers and gives some tips to help you get the most out of TypeScript.
March 28, 2022
by Sergey Laptick
· 3,848 Views · 2 Likes
  • Previous
  • ...
  • 751
  • 752
  • 753
  • 754
  • 755
  • 756
  • 757
  • 758
  • 759
  • 760
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×