Igor Gentil
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Serverless & EDA Immersion Days @ Cochlear **WORKSHOP LINK**: https://catalog.us-east-1.prod.workshops.aws/join?access-code=335d-015918-b5 **Workshop help/questions**: kechn@amazon.com # Day 2 SURVEY! Please complete before leaving! https://amazonmr.au1.qualtrics.com/jfe/form/SV_blbHTKTeWKRB4dU ![](https://hackmd.io/_uploads/r1mQy4bep.png) # Day 2 ## Serverless Developer Experience Workshop Business workflow: - Agents create contracts and update contracts - Agents create listings - Agents request listing to be evaluated (approved) - Approved approved listings show up in search - Property has address as PK. Contract is related to property. Listing ties together both. Q: Can you please share the lab instructions from Day 1? > A: Sure! See the bottom of this doc [(link)](#Public-Workshop-Links) :slightly_smiling_face: Q: What is the advantage of using a named queue rather than just using asynchronously from api gateway to lambda? > A: It's still perfectly possible to just assynchronously call Lambdas from API Gateway. The reasons we went with an SQS function in between Lambda and API GW include: > - Ease of implementation, including the ability to build in a DLQ for failed messages > - Ability to batch-process API requests in Lambda: if API calls are made in rapid succession, we can leverage SQS Batching to process them in groups by single Lambda invocations. > > Although that doesn't have a large impact on *this* service, it is a good practice overall for larger, more complex systems # Day 1 ## Questions, Challenges, Comments > Please add questions or comments in the list below Q: We have systems that are still running NodeJSv6, how do we enforce ownership and maintenance of IT estate? > A: By defining a **lightweight**, yet powerful Governance framework. It can be as simple as having a rule like "every resource should be tagged with a Owner, that's an actual person - that ultimately responds for that resource. Any non-tagged resource will be deleted". > Write the rules in such a way that following them becomes **the path of least resistence**. Make them such that no resource, component, system can be *orphaned* - anything must belong to *someone*... > ![](https://hackmd.io/_uploads/SyBCgpkg6.jpg) Q: What can we add to AWS Lambda Layers to help improve performance? Q: Is there any networking optimisation that can help expedite routing between various service? > A: In a Serverless context, the network needs to be thought of as *abstracted away*, i.e. not a 'component' to be optimised. Think of the network - in this context - as any other utility in your house. You don't optimise it's delivery, you simply consume it. > > That said, if **in a specific situation** your **application requirements** demand more performance from the network that can be delivered, there are techniques one can leverage for better direct network throughput - **at the expense of abstraction** -> e.g. EC2 instances in a Placement Group. Q: Can we use EDA for applications that are Synchronous in nature? Is there a way to handle this dependency? > A: EDAs are by their very nature assynchronous. 99.9% of the time, synchronicity can be **engineered away** of an application by good architecture and some *lateral thinking*. > > *Personally* I see very few situations where synchronicity is an **absolute hard requirement**. One example would be real-time systems, hardware controllers, etc. But those are definitely the exception, not the rule... Q: When migrating an on-prem application to cloud, would it be better to do a lift and shift first and then think of re-platform to serverless architecture? > A: It really depends on a *number* of factors, most important of which include: > - What is the impact of said application to your business & customers? > - What is the cost (direct & opportunity) of modernising VS the risk of the app stop working > > Basically, what to do with legacy applications **needs** to be evaluated on a case-by-case basis, but there are well-defined strategies and '*frameworks*' that we can help you leverage to simplify this analysis. Q: Culture of decentralized sounds great. But wouldnt it create an environment of silo when the teams is empowered to decide what language to write or what technology stack to use? An organization will end up 1000s of technologies to pay/license/support.. how do you manage this? > A: In my experience the degree of *technology sprawl* that *actually* occurs in a de-centralised structure is never this large, for a few reasons: > - There's not that many *valid* permutations of technologies (even when we consider the many JavaScript frameworks out in the wild :) > - People often tend to leverage - where it makes sense - technologies already implemented/proven by their peers. We can even **supercharge** that by **fostering a culture of cross-polination**[1] across our teams. > > Finally, like most things in IT, it's a trade-off. I propose that the gains of a decentralised structure - agility, independence, scalability, ... - far outweight the potential drawbacks - e.g. tech sprawl - if managed by some **simple** governance rules. Q: In EDA is the contract between the producer and the consumer? > A: I guess you could say that... Technically, the contract is **published by the Producer**, who guarantees that events **emitted** will respect the contract, and **leveraged by the Consumers**, who depend on the **guarantee** above to build their own systems and have a **stable** (or at least well-managed) interface with the outside world. Q: How can we protect sensitive info in Event if any? > A: **Great question!!** There are a number of techniques we can leverage to protect sensitive information in Events. Which one to use will depend on architecture, organisational and technology characteristics of *your* environment. > > One technique is to published *sensitive* data in the events, but encrypted with a key that the producer then controls access to - i.e., only services authorised to use the key will be able to decrypt the sensitive data. > > Another technique would be to *not publish* sensitive data in the events, instead 'hiding' it behind an API, that needs to be accessed by the Consumers. Access control is then managed at the API layer. **Yes, this breaks the EDA dependency** model, but it *could* potentially be a valid approach, dependind on the situation... > > Finally, there's something to be said about trying to **architect your way out of the problem**... By this I mean: ask if there's nothing you can do to *change your requirements* so to **not need to expose** sensitive information outside of a Domain... Not always possible, but worth investigating :) Q: How can we ensure ordering of events? For example, if producer publishes a create event followed by an update event. How can consumers know to follow the same order? > A: Short answer: *most* of the time we can't do that *directly*. Let me explain: > > There are services that guarantee delivery ordering, like SQS FIFO queues, or Kafka Topics (ordering is preserved *within each partition*). That, however, comes at a cost: scalability. Everything is a trade-off. By enforcing ordering **in a distributed system**, we have to sacrifice something (see [CAP theorem](https://en.wikipedia.org/wiki/CAP_theorem) ): either *partition tolerance* or *availability*. > > [IMHO](https://dictionary.cambridge.org/dictionary/english/imho), the question we should be asking is: `Is there any way we don't need to depend on ordering?` > > This is another good example of when we should try to **engineer ourselves out of the problem**... Q: Does Lambda takes care of guaranteed message delivery as well? > A: I assume you mean messages delivered *to* Lambda via the Event Sources? If so, the Lambda control plane offers [At Least Once](https://blog.bytebytego.com/p/at-most-once-at-least-once-exactly) delivery. You can check out the details in the [Lambda docs](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html#:~:text=Lambda%20event%20source%20mappings%20process,duplicate%20events%20in%20rare%20situations.). Q: State Manager / Stream tracker --> Is that part of the event source, like Kafka or Kinesis? Or does Lambda manages the counsumer state? > A: State Manager is an **internal** component of the Lambda service. It acts as a Kafka/Kinesis **client**, by consuming messages from the stream and invoking Lambda functions with the messages as payload. Q: If we use custom runtime, is there an option to select the runtime as custom while we deploy. For example, we choose nodejs 18 or python 3.7 as runtime while deployment. How does it change when we use custom runtime within our function? > A: By using a Custom Runtime you necessarily need to choose the `provided.al2` runtime option, as described [here](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html#runtimes-custom-use:~:text=To%20use%20a%20custom%20runtime%2C%20set%20your%20function%27s%20runtime%20to%20provided.al2) Q: Are there best practices on what goes in to the handler function and what should be defined outside of it? > A: Absolutely! The rule of thumb is: keep on the *lambda handler* **ONLY WHAT NEEDS TO RUN ON EVERY INVOCATION**. > Things that can usually go **outside** include, but are not limited to: > - Initialise DB connection objects > - Loading configurations from disk or env vars > - Load static files from disk/s3 > - The list goes on and on and on > You can check out some of the best practices [here](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html) # Comments, Concerns, and literally anything else *Comment*: Love the decentralised mindset, some challenges we see is inter-team dependencies, and knowledge gap in smaller teams. Q: Tried this command from Creating contracts and got this error. ``` $ poetry run pytest tests/unit/ ImportError while loading conftest '/home/ec2-user/environment/unicorn/unicorn_contracts/tests/unit/conftest.py'. tests/unit/conftest.py:6: in <module> from aws_lambda_powertools.utilities.typing import LambdaContext E ModuleNotFoundError: No module named 'aws_lambda_powertools' ``` > A: Please run `poetry add aws-lambda-powertools`, then try again :thumbsup: Q: I'm getting errors when running npm test after updating the contract ``` During handling of the above exception, another exception occurred: self = <tests.integration.test_create_contract_apigw.TestCreateContract testMethod=test_create_contract_valid_payload_1> def test_create_contract_valid_payload_1(self): prop_number = randint(1, 9999) payload = override_payload_number(get_event_payload('create_contract_valid_payload_1'), prop_number) # Call API to create new Contract response = requests.post(f'{self.api_endpoint}contracts', json=payload) self.properties.append(payload['property_id']) self.assertEqual(response.status_code, 200) self.assertDictEqual(response.json(), response.json() | {"message": "OK"}) sleep(5) try: eb_event = next(get_cw_logs_values(self.eb_log_group, payload['property_id'])) except Exception: > raise Exception(f'Unable to get EventBridge Event from CloudWatch Logs group {self.eb_log_group}') E Exception: Unable to get EventBridge Event from CloudWatch Logs group arn:aws:logs:ap-southeast-2:975435656176:log-group:/aws/events/local/unicorn.contracts-catchall tests/integration/test_create_contract_apigw.py:58: Exception ``` > A: Please check if the EventBridge Pipe is implemented. It is required for the end-to-end integration tests. # Public Workshop Links - (Day 1) [Building Event-Driven Architectures in AWS](https://catalog.workshops.aws/building-event-driven-architectures-on-aws) - (Day 2) [Serverless Developer Experience Workshop](https://catalog.workshops.aws/serverless-developer-experience) # Further reading, listening, or watching - Blog: [How does lambda scaling compare to other compute options?](https://www.vladionescu.me/posts/scaling-containers-on-aws-in-2022/) - Blog: [Lambas automatically pre-warm sometimes...](https://aaronstuyvenberg.com/posts/understanding-proactive-initialization) - YouTube: [Best practices for advanced serverless developers](https://www.youtube.com/watch?v=PiQ_eZFO2GU) - YouTube: [Advanced serverless workflow patterns and best practices](https://www.youtube.com/watch?v=o6-7BAUWaqg) - YouTube: [Building Serverlesspresso](https://www.youtube.com/watch?v=qs0U0LdNkV0) - YouTube: [Idempotency](https://www.youtube.com/watch?v=Jxugill-rOM) - YouTube: [Shuffling and Sampling](https://www.youtube.com/watch?v=cZ3JEbp4oO0) - Blog post: [Building and operating a pretty big storage system called S3](https://www.allthingsdistributed.com/2023/07/building-and-operating-a-pretty-big-storage-system.html) # Fun Corner AI Terminal Assistant: https://www.warp.dev/warp-ai (not AWS endorsed) [xkcd.com](https://xkcd.com) !! ![XKCD: Compiling](https://imgs.xkcd.com/comics/compiling.png) ![XKCD: Sudo](https://imgs.xkcd.com/comics/sandwich.png) ![XKCD: Windows Copy](https://imgs.xkcd.com/comics/estimation.png) ![XKCD: Compiler Complaint](https://imgs.xkcd.com/comics/compiler_complaint.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully