Thankful for the AWS Community Builders Program & Building
Tags: communitybuilders, thankfulforest2024, aws, firevalleyrocks
Published: 2023-12-15 20:27:01

As the saying goes, "If you want to go fast, go alone. If you want to go far, go together." 

Over the last few years, I've benefited so much from being a part of the [AWS Community Builders Program](https://aws.amazon.com/developer/community/community-builders/) - a global community, network, and program. From meeting super talented, smart, and amazing mentors and peers, to receiving exclusive trainings and insights from the teams building the cutting edge technologies powering modern software, I have immense appreciation for this program and everyone who makes it so meaningful.

There are SO many benefits for Community Builders! Here are my top 5:
🌎 Global network
🏋️ Exclusive trainings
💡 Amazing mentors/peers
🗣️ Speaking opportunities
👕 Super cool swag

If you like building, sharing what you learn, and contributing to a great community, then you should definitely consider applying to the AWS Community Builders program! You can add your name to the [waitlist here](https://aws.amazon.com/developer/community/community-builders/)

Now, since we are in the holiday spirit, we thought it would be fun to create holiday-themed AWS Step Function state machines that model a tree as a thank you to all of the amazing AWS Leaders who make the AWS Community Builders Program so special 🎄🥳 So, let's analyze what goes into a Step Machine and build one together while we thank our incredible AWS Leaders for all that they do...

## Step 1: Go to Amazon Step Functions in the console

You will want to search for "Step Functions" in the top search bar. Click on the first AWS service in the dropdown. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yda8ie2sbku2f3pa5kv4.png)

This will direct you to the Step Functions page, where you'll either see a list of your currently active Step Functions or nothing listed out in which you'll be able to click that Orange button in the top right to make your very first Step Function state machine on AWS:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qyqgansvdnt9wtnmimxd.png)


## Step 2: Pick a template or start from scratch

While we are going to start from scratch by selecting "Blank", there are so many options for very cool Step function flows if you want to architect something more complicated. We are making a tree design, so it is not going to involve that many services or features.

Here's a few of the cool ones:

- Distributed Map to process a CSV file in S3: Use Distributed Map to iterate over the rows of a generated CSV file in S3. Each row has order and shipping information. The distributed map item processor iterates over a batch of these rows to detect delayed order using a Lambda function. It then send a message to SQS queue for every delayed order

- Generate invoices using Stripe: Use the HTTP task to call Stripe APIs for an invoice-generation workflow. Retrieves a list of customers, summarizes their payment methods, and either generates invoices or reports missing/expired credit cards.

- Perform AI prompt-chaining with Amazon Bedrock:
Use AI prompt-chaining with Amazon Bedrock to build high-quality chatbots. By chaining prompts, the LLM can use conversation history to provide more relevant responses.

- Call a microservice with API Gateway: Make a call to an API Gateway endpoint that fronts an ECS container microservice. (Amazon API Gateway, Amazon ECS)

- ETL job in Amazon Redshift: This sample project demonstrates how to use Step Functions and the Amazon Redshift Data API to run an ETL/ELT workflow that loads data into the Amazon Redshift data warehouse.

- Tune a machine learning model: Tune hyperparameters of a machine learning model and batch transform a test dataset (Amazon SageMaker, AWS Lambda, Amazon S3)

... The list just truly goes on from there.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ipjgphrpzvs8sa6r9xje.png)

## Step 3: Setup your Step Function workspace for success
When you create your first state machine, there will be 2 main views to develop within:
- **A drag-and-drop UI**: this view is helpful to search for various services and simply add them as steps into your state machine.
- **A JSON editor**: this is the view I prefer the most because I find that the code is easier to think about, especially with how steps chain together.

For this blog post, we are going to look at the JSON code editor view.

## Step 4: Write your Step Function Logic

Thanks to the amazing @jennworks40 - we were able to start building a template for our state machine very rapidly with her initial Step Function template.

Here is my finished code if you want to check it out:
```json
{
  "Comment": "Building a tree is fun!",
  "StartAt": "I'm grateful to learn and grow",
  "States": {
    "I'm grateful to learn and grow": {
      "Type": "Pass",
      "Next": "From webinars to IRL community events"
    },
    "From webinars to IRL community events": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:us-east-1:xxxxxxxxxx:function:Thankful",
      "Catch": [
        {
          "ErrorEquals": [
            "States.TaskFailed"
          ],
          "Next": "All run by amazing AWS leaders and visionaries..."
        }
      ],
      "Next": "All run by amazing AWS leaders and visionaries..."
    },
    "All run by amazing AWS leaders and visionaries...": {
      "Type": "Pass",
      "Next": "Who care about the AWS Community and make sure we are content."
    },
    "Who care about the AWS Community and make sure we are content.": {
      "Type": "Parallel",
      "Branches": [
        {
          "StartAt": "AWS leaders who help,",
          "States": {
            "AWS leaders who help,": {
              "Type": "Succeed"
            }
          }
        },
        {
          "StartAt": "AWS leaders who care,",
          "States": {
            "AWS leaders who care,": {
              "Type": "Task",
              "Resource": "arn:aws:lambda:us-east-1:xxxxxxxxxx:function:Thankful",
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.TaskFailed"
                  ],
                  "Next": "We ❤️‍🔥 you all!"
                }
              ],
              "End": true
            },
            "We ❤️‍🔥 you all!": {
              "Type": "Pass",
              "Result": "Love em",
              "End": true
            }
          }
        },
        {
          "StartAt": "And AWS leaders who are always there.",
          "States": {
            "And AWS leaders who are always there.": {
              "Type": "Succeed"
            }
          }
        }
      ],
      "Next": "It's no small task, the immense work they do"
    },
    "It's no small task, the immense work they do": {
      "Type": "Parallel",
      "Next": "Thank you for all that you do. We all love you!",
      "Branches": [
        {
          "StartAt": "Helping us reach for the stars,",
          "States": {
            "Helping us reach for the stars,": {
              "Type": "Pass",
              "End": true
            }
          }
        },
        {
          "StartAt": "Climb to new heights,",
          "States": {
            "Climb to new heights,": {
              "Type": "Task",
              "Resource": "arn:aws:lambda:us-east-1:xxxxxxxxxx:function:Thankful",
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.TaskFailed"
                  ],
                  "Next": "We ❤️‍🔥 the ☁️"
                }
              ],
              "End": true
            },
            "We ❤️‍🔥 the ☁️": {
              "Type": "Pass",
              "Result": "Beautiful",
              "End": true
            }
          }
        },
        {
          "StartAt": "Believe in ourselves,",
          "States": {
            "Believe in ourselves,": {
              "Type": "Pass",
              "End": true
            }
          }
        },
        {
          "StartAt": "Always work hard,",
          "States": {
            "Always work hard,": {
              "Type": "Task",
              "Resource": "arn:aws:lambda:us-east-1:xxxxxxxxxx:function:Thankful",
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.TaskFailed"
                  ],
                  "Next": "We ❤️‍🔥 to build!"
                }
              ],
              "End": true
            },
            "We ❤️‍🔥 to build!": {
              "Type": "Pass",
              "Result": "Good company",
              "End": true
            }
          }
        },
        {
          "StartAt": "And share some cool swag, always something new.",
          "States": {
            "And share some cool swag, always something new.": {
              "Type": "Pass",
              "End": true
            }
          }
        }
      ]
    },
    "Thank you for all that you do. We all love you!": {
      "Type": "Pass",
      "End": true
    }
  }
}
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ps0qe8qw88f9vx903dt1.png)

In case you are wondering where the `arn`'s come from, check out Step 5 below.


## Step 5: Create a Lambda Function

Creating a Lambda function — a serverless script that can run in AWS and connect to various AWS resources, apps, and more —  is very easy. First, search for "Lambda" in the search bar at the top and you should click on the first item that shows up in the dropdown:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gw84dacnpj5um3iwa3um.png)

Next, we'll decide to create a lambda function with the orange button. This will bring up the Lambda function setup screen to select all the options, including a name and runtime, which we will select Python 3.11:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdhtkhgwgag34o4mimp3.png)

After we select to create the Lambda function, we'll then be redirected to the Lambda console with our new function:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ux7fjb2rd1imvbq0qgtz.png)

Notice the code that was auto-generated for us. It's not much, but we love to see it:
```py
import json

def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }
```

Pay particularly close notice to the `arn` that is generated for the function. This `arn` is like it's identification tag in AWS - we will use this in our step function flow in the above. 

ARNs follow a specific format like this (yours will look a bit different with the variables): `arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME`

We will drop our arn's into the step function to correspond to the Lambda function we want to run. I just made one Lambda function, but you may have more and want to configure those in each of the state machine's places

This is what it looks like:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fk6grlyp8u90zns1t7vw.png)

## Step 6: Light it up! 🎄
To create our state machine, we will need to create some IAM permissions to allow the state machine to interact with Lambd and also do some xray tracing. Approve these automatically suggested changes:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bohgy0zot4v4e4tbxyiq.png)

We will wait a second and then we should see the confirmation green banner notification saying that the IAM role was created successfully. We may need to wait up to 1-2 minutes for the role to be fully updated.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n1m0l7ju483gsv8em8dh.png)


That was easy! Now our role is configured with all the right permissions for the step function flow. 

Now for the fun part! Let's run our step function with a custom comment like this:

```json
{
  "Comment": "Thank you so much amazing AWS Leaders!!❤️‍🔥"
}
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3hljs3ubonj9o1x157p.png)

Now, when the function runs, we'll see green, meaning it worked 🎄

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfox1cv17r3xeydyob6n.png)

The state machine will go from blueprint mode...

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08sulkrpxzk6bk1oyc2e.png)

To lights on mode... 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k524oowgdfh67c4c6xmg.png)


## What Step Functions have to do with the AWS Community Builders Program

While you might be thinking that Step Functions is "just another AWS service", it embodies many of the attributes that makes the AWS Community Builders program so strong. Step Functions at their core link complex, powerful, or intricate processes together in a chain so that they all flow together and achieve synchronized movement. When working together, the parts create a well oiled machine that can deliver performance. Let's see how:

- Orchestrated Processes and Orchestrated Learning: the ability to orchestrate complex systems and events is a powerful skill, and we are lucky to have amazing leaders and mentors who can orchestrate transformative career growth for us all. 

- State Management and Growth: growth and transformation should not be stagnant, and the AWS Leaders make sure to keep us dynamic, engaged, and on top of the latest trends and opportunities. State machines are always triaging new events down the flow of the pipeline to where they need to go, and the AWS Leaders make sure that we are moving forward in our careers and lives just like step functions.

- Error Handling and Support Systems: like a good QA engineer, we need to have a safe space to test, debug, and work out the code before we ship it live. The Community Builders Program is such a space, where we can all feel comfortable supporting one another, testing out pitches and talks, and being there for each other through job interviews, major projects, and more.

- Infinite Scalability: with a global community, you have an ever replenishing support community and circle from all around the globe. It is an incredible feeling to have friends from almost all parts of the world, and especially getting the chance to meet up with the AWS Community at various events like re:Invent, Summits, and meetups are truly so special.

- Networking and Collaboration: just like we had to provision that IAM role to connect all of the various services and components of the step function flow together, the AWS Leaders who support the AWS Community Builders program serve this very important role too. By being able to bring leaders, product managers, and mentors together for us to build, learn, and co-create together, the AWS Leadership becomes this very glue, like IAM, that unites all of us together.

I am so thankful to have been a part of the AWS Community Builders program for the past few years, and while I am now an AWS DevTools Hero, I still champion the AWS Community Builders program whenever I can. It is truly what got me into myh development career and helped accelerate where my career has taken me so far. I am so thankful and grateful to everyone I have met through the AWS Community Builders program and the banner of this blog post is just a small sample of the many photos I have with folks I am honored to call friends, colleagues, mentors, and role models. Thank you, AWS Community Builders, for serving and continuing to serve such an important support community to me and everyone in the Community Builders program. 

We ❤️‍🔥 and appreciate you all.

- Brian