AWS Databases and Serverless
This page covers four AWS services: AWS Lambda, Amazon DynamoDB, Amazon Athena, and AWS Step Functions. The practice run tests the example function of AWS Lambda, runs the AWS tutorial for DynamoDB on your own machine, and models two rules. It needs no AWS account. It comes after AWS Identity and Security and before Terraform and Infrastructure as Code.
58 min read58 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 44 sources44টি সোর্স · updated Nov 2026আপডেট: Nov 2026
Cold start and scaling of a functionফাংশনের কোল্ড স্টার্ট ও স্কেলিং
Send bursts of events at a Lambda function and see cold starts, reused environments and the timeout.একটা Lambda ফাংশনে একসঙ্গে অনেক ইভেন্ট পাঠান আর দেখুন কোল্ড স্টার্ট, পুনর্ব্যবহার হওয়া এনভায়রনমেন্ট ও টাইমআউট।
You’ll learnআপনি শিখবেন
- What Init and Invoke each doInit আর Invoke প্রতিটা কী করে
- Why an environment is reusedএনভায়রনমেন্ট কেন পুনর্ব্যবহার হয়
- Why a burst makes cold startsবার্স্টে কেন কোল্ড স্টার্ট হয়
- What the timeout and the role doটাইমআউট ও role কী করে
What it is
AWS Lambda. AWS Lambda is a serverless compute service Source 1সোর্স 1. With Lambda, you can run code without provisioning or managing servers Source 1সোর্স 1. Lambda automatically manages the underlying infrastructure, including server maintenance, capacity provisioning, scaling, and patching Source 1সোর্স 1. Lambda provides three compute primitives Source 1সোর্স 1. This page covers Event Functions, which is the name for the original Lambda function type Source 1সোর্স 1. An Event Function runs code in response to events or API calls without managing servers Source 1সোর্স 1.
Amazon DynamoDB. Amazon DynamoDB is a serverless, fully managed, distributed NoSQL database with single-digit millisecond performance at any scale Source 9সোর্স 9. A table is a collection of items, and each item is a collection of attributes Source 10সোর্স 10. DynamoDB uses primary keys to uniquely identify each item in a table Source 10সোর্স 10. DynamoDB doesn't support a JOIN operator Source 9সোর্স 9. AWS recommends that you denormalize your data model Source 9সোর্স 9.
Amazon Athena. Amazon Athena is an interactive query service that makes it easy to analyze data directly in Amazon S3 using standard SQL Source 24সোর্স 24. You can use Athena to run ad-hoc queries using ANSI SQL, without the need to aggregate or load the data into Athena Source 25সোর্স 25. Athena helps you analyze unstructured, semi-structured, and structured data stored in Amazon S3 Source 25সোর্স 25. Examples include CSV, JSON, or columnar data formats such as Apache Parquet and Apache ORC Source 25সোর্স 25.
AWS Step Functions. With AWS Step Functions, you can create workflows, also called State machines, to build distributed applications, automate processes, orchestrate microservices, and create data and machine learning pipelines Source 32সোর্স 32. Each step in a workflow is called a state Source 32সোর্স 32. Instances of running workflows performing tasks are called executions Source 32সোর্স 32. A Task state represents a unit of work that another AWS service performs Source 32সোর্স 32. The Amazon States Language is a JSON-based, structured language used to define your state machine, a collection of states Source 33সোর্স 33.
What you pay for. Lambda has pay-per-use billing, with no upfront commitments Source 1সোর্স 1. DynamoDB on-demand mode offers pay-per-request pricing for read and write requests Source 12সোর্স 12. In Athena, you pay only for the queries that you run Source 24সোর্স 24. Standard workflows of Step Functions are priced by state transition Source 32সোর্স 32. Express workflows are priced by the number and the duration of executions Source 32সোর্স 32.
সহজ English
AWS Lambda. AWS Lambda is a serverless compute service Source 1সোর্স 1. With Lambda, you can run code without provisioning or managing servers Source 1সোর্স 1. Lambda automatically manages the underlying infrastructure, including server maintenance, capacity provisioning, scaling, and patching Source 1সোর্স 1. Lambda provides three compute primitives Source 1সোর্স 1. This page covers Event Functions, which is the name for the original Lambda function type Source 1সোর্স 1. An Event Function runs code in response to events or API calls without managing servers Source 1সোর্স 1.
Amazon DynamoDB. Amazon DynamoDB is a serverless, fully managed, distributed NoSQL database with single-digit millisecond performance at any scale Source 9সোর্স 9. A table is a collection of items, and each item is a collection of attributes Source 10সোর্স 10. DynamoDB uses primary keys to uniquely identify each item in a table Source 10সোর্স 10. DynamoDB doesn't support a JOIN operator Source 9সোর্স 9. AWS recommends that you denormalize your data model Source 9সোর্স 9.
Amazon Athena. Amazon Athena is an interactive query service that makes it easy to analyze data directly in Amazon S3 using standard SQL Source 24সোর্স 24. You can use Athena to run ad-hoc queries using ANSI SQL, without the need to aggregate or load the data into Athena Source 25সোর্স 25. Athena helps you analyze unstructured, semi-structured, and structured data stored in Amazon S3 Source 25সোর্স 25. Examples include CSV, JSON, or columnar data formats such as Apache Parquet and Apache ORC Source 25সোর্স 25.
AWS Step Functions. With AWS Step Functions, you can create workflows, also called State machines, to build distributed applications, automate processes, orchestrate microservices, and create data and machine learning pipelines Source 32সোর্স 32. Each step in a workflow is called a state Source 32সোর্স 32. Instances of running workflows performing tasks are called executions Source 32সোর্স 32. A Task state represents a unit of work that another AWS service performs Source 32সোর্স 32. The Amazon States Language is a JSON-based, structured language used to define your state machine, a collection of states Source 33সোর্স 33.
What you pay for. Lambda has pay-per-use billing, with no upfront commitments Source 1সোর্স 1. DynamoDB on-demand mode offers pay-per-request pricing for read and write requests Source 12সোর্স 12. In Athena, you pay only for the queries that you run Source 24সোর্স 24. Standard workflows of Step Functions are priced by state transition Source 32সোর্স 32. Express workflows are priced by the number and the duration of executions Source 32সোর্স 32.
বাংলা ব্যাখ্যা
AWS Lambda। AWS Lambda হলো একটা serverless compute service Source 1সোর্স 1। Lambda দিয়ে আপনি server provision বা পরিচালনা না করেই code চালাতে পারেন Source 1সোর্স 1। Lambda নিচের infrastructure নিজে পরিচালনা করে, যার মধ্যে আছে server-এর রক্ষণাবেক্ষণ, capacity provisioning, scaling আর patching Source 1সোর্স 1। Lambda তিনটা compute primitive দেয় Source 1সোর্স 1। এই page Event Function নিয়ে, যা Lambda-র আদি function ধরনের নাম Source 1সোর্স 1। একটা Event Function server পরিচালনা না করেই event বা API call-এর জবাবে code চালায় Source 1সোর্স 1।
Amazon DynamoDB। Amazon DynamoDB হলো একটা serverless, fully managed, distributed NoSQL database, যা যেকোনো scale-এ single-digit millisecond performance দেয় Source 9সোর্স 9। table হলো item-এর একটা সংগ্রহ, আর প্রতিটা item হলো attribute-এর একটা সংগ্রহ Source 10সোর্স 10। DynamoDB একটা table-এর প্রতিটা item-কে আলাদাভাবে চেনার জন্য primary key ব্যবহার করে Source 10সোর্স 10। DynamoDB JOIN operator সমর্থন করে না Source 9সোর্স 9। AWS সুপারিশ করে, আপনি যেন আপনার data model denormalize করেন Source 9সোর্স 9।
Amazon Athena। Amazon Athena হলো একটা interactive query service, যা standard SQL দিয়ে সরাসরি Amazon S3-এর data বিশ্লেষণ করা সহজ করে Source 24সোর্স 24। আপনি data Athena-য় জড়ো বা load না করেই ANSI SQL দিয়ে ad-hoc query চালাতে Athena ব্যবহার করতে পারেন Source 25সোর্স 25। Athena Amazon S3-এ রাখা unstructured, semi-structured আর structured data বিশ্লেষণে সাহায্য করে Source 25সোর্স 25। উদাহরণ হলো CSV, JSON, বা Apache Parquet আর Apache ORC-র মতো columnar data format Source 25সোর্স 25।
AWS Step Functions। AWS Step Functions দিয়ে আপনি workflow বানাতে পারেন, যাকে State machine-ও বলে, যাতে distributed application বানানো, process automate করা, microservice orchestrate করা আর data ও machine learning pipeline বানানো যায় Source 32সোর্স 32। একটা workflow-র প্রতিটা ধাপকে state বলে Source 32সোর্স 32। কাজ করতে থাকা workflow-র চলমান instance-গুলোকে execution বলে Source 32সোর্স 32। একটা Task state এমন একটা কাজের একক বোঝায়, যা অন্য একটা AWS service করে Source 32সোর্স 32। Amazon States Language হলো একটা JSON-ভিত্তিক, কাঠামোবদ্ধ ভাষা, যা দিয়ে আপনার state machine সংজ্ঞায়িত করা হয়, যা state-এর একটা সংগ্রহ Source 33সোর্স 33।
কিসের জন্য টাকা দিতে হয়। Lambda-র billing হলো ব্যবহার অনুযায়ী, কোনো আগাম প্রতিশ্রুতি ছাড়া Source 1সোর্স 1। DynamoDB-র on-demand mode read আর write request-এর জন্য request-প্রতি দাম দেয় Source 12সোর্স 12। Athena-য় আপনি শুধু যে query চালান তার জন্য দাম দেন Source 24সোর্স 24। Step Functions-এর Standard workflow-এর দাম ঠিক হয় state transition ধরে Source 32সোর্স 32। Express workflow-এর দাম ঠিক হয় execution-এর সংখ্যা আর স্থায়িত্ব ধরে Source 32সোর্স 32।
How it works
Lambda: the function, the event, and the handler. In Python, a Lambda function can contain more than one Python function, but the handler function is always the entry point to your code Source 2সোর্স 2. When your function is invoked, Lambda runs this method Source 2সোর্স 2. The handler takes two arguments, event and context Source 2সোর্স 2.
An event in Lambda is a JSON formatted document that contains data for your function to process Source 2সোর্স 2. If another AWS service invokes your function, the event object contains information about the event that caused the invocation Source 2সোর্স 2. Lambda passes the context object to your function automatically Source 2সোর্স 2. The context object contains information about the function invocation and execution environment Source 2সোর্স 2.
With Python, you can use either a print statement or a Python logging library to send information to your function's log Source 2সোর্স 2. In a production application, AWS recommends a logging library Source 2সোর্স 2. When you invoke your function outside of the Lambda console, you must use CloudWatch Logs to view your function's execution results Source 2সোর্স 2.
Lambda: how a function is invoked. After you deploy your function, you can invoke it in several ways Source 3সোর্স 3. One way is the aws lambda invoke AWS CLI command Source 3সোর্স 3. Another way is a function URL, which is a dedicated HTTP(S) endpoint Source 3সোর্স 3.
Some services can invoke a function with each new event, and this is called a trigger Source 3সোর্স 3. For stream and queue-based services, Lambda invokes the function with batches of records, which is called an event source mapping Source 3সোর্স 3.
With synchronous invocation, you wait for the function to process the event and return a response Source 3সোর্স 3. With asynchronous invocation, Lambda queues the event for processing and returns a response immediately Source 3সোর্স 3. The InvocationType parameter decides which one: RequestResponse means synchronous, and Event means asynchronous Source 3সোর্স 3.
For an error in a synchronous invocation, you view the error message in the response and retry the invocation manually Source 3সোর্স 3. For asynchronous invocations, Lambda handles retries automatically and can send invocation records to a destination Source 3সোর্স 3.
Lambda: the execution role and the settings. A function's execution role is an IAM role that grants the function permission to access AWS services and resources Source 4সোর্স 4. Lambda automatically assumes your execution role when you invoke your function Source 4সোর্স 4. The trust policy of the role must specify the Lambda service principal, lambda.amazonaws.com, as a trusted service Source 4সোর্স 4. In the Lambda console, Lambda creates an execution role with minimal permissions by default Source 4সোর্স 4. This role includes the AWSLambdaBasicExecutionRole managed policy, which gives basic permissions to log events to Amazon CloudWatch Logs Source 4সোর্স 4.
Timeout is the maximum amount of time in seconds that a Lambda function can run Source 5সোর্স 5. The default is 3 seconds, and you can adjust it in increments of 1 second up to a maximum value of 1,800 seconds (30 minutes) Source 5সোর্স 5. For functions using AWS Lambda Managed Instances, asynchronous invocations and event source mapping invocations (except Amazon MQ and Amazon DocumentDB) support a maximum allowed value of 5,400 seconds (90 minutes) Source 5সোর্স 5. The update-function-configuration command sets the timeout, in seconds Source 5সোর্স 5.
Lambda: the execution environment, cold starts, and scaling. Lambda invokes your function in an execution environment, which provides a secure and isolated runtime environment Source 6সোর্স 6. In the Init phase, Lambda performs three tasks Source 6সোর্স 6. It starts all extensions, bootstraps the runtime, and runs the static code of the function Source 6সোর্স 6. The Init phase is limited to 10 seconds Source 6সোর্স 6. The timeout setting of the function limits the duration of the entire Invoke phase Source 6সোর্স 6.
After an invocation, Lambda keeps the execution environment for some time, in anticipation of another invocation Source 6সোর্স 6. Objects declared outside of the handler remain initialized when the function is invoked again Source 6সোর্স 6. The /tmp directory keeps its content while the environment is frozen Source 6সোর্স 6. Background processes that did not complete when the function ended resume if Lambda reuses the environment Source 6সোর্স 6. Lambda terminates execution environments every few hours Source 6সোর্স 6. So you should not assume that the environment persists indefinitely Source 6সোর্স 6. If a function crashes or times out during the Invoke phase, Lambda resets the environment Source 6সোর্স 6.
When Lambda has to initialize a new environment to carry out an invocation, this is known as a cold start Source 7সোর্স 7. A cold start adds latency to the invocation duration, and you are charged for this time Source 6সোর্স 6. Cold starts typically occur in under 1% of invocations Source 6সোর্স 6. They are typically more common in development and test functions than in production workloads Source 6সোর্স 6. The reason is that development and test functions are usually invoked less frequently Source 6সোর্স 6.
Concurrency is the number of in-flight requests that a function is handling at the same time Source 7সোর্স 7. For each concurrent request, Lambda provisions a separate instance of your execution environment Source 7সোর্স 7. By default, an account has a total limit of 1,000 concurrent executions across all Event Functions in a Region Source 7সোর্স 7. If a function runs out of available concurrency, it experiences throttling, which means that it starts to drop requests Source 7সোর্স 7. Reserved concurrency reserves a portion of the concurrency of your account for a function Source 7সোর্স 7. There is no charge for configuring it Source 7সোর্স 7. Provisioned concurrency pre-initializes environment instances, which reduces cold start latencies Source 7সোর্স 7. Using provisioned concurrency incurs additional charges Source 7সোর্স 7.
DynamoDB: tables, items, and keys. When you create a table, in addition to the table name, you must specify its primary key Source 10সোর্স 10. The primary key uniquely identifies each item in the table, so that no two items can have the same key Source 10সোর্স 10. DynamoDB uses the value of the partition key as input to an internal hash function Source 10সোর্স 10. The output of the hash function determines the partition in which the item is stored Source 10সোর্স 10. In a table that has only a partition key, no two items can have the same partition key value Source 10সোর্স 10.
With a partition key and a sort key, all items with the same partition key value are stored together, in sorted order by sort key value Source 10সোর্স 10. Multiple items can have the same partition key value, but they must have different sort key values Source 10সোর্স 10. In the Music example of AWS, if you provide only the value for Artist, DynamoDB retrieves all of the songs by that artist Source 10সোর্স 10. In the Music example, each item must have both key attributes Source 10সোর্স 10. Other than the primary key, the Music table is schemaless Source 10সোর্স 10. Each primary key attribute must be a scalar Source 10সোর্স 10. The only data types allowed for primary key attributes are string, number, or binary Source 10সোর্স 10.
A secondary index lets you query the data in the table using an alternate key, in addition to queries against the primary key Source 10সোর্স 10. A global secondary index has a partition key and sort key that can be different from those of the table Source 10সোর্স 10. A local secondary index has the same partition key as the table, but a different sort key Source 10সোর্স 10. Each table has a quota of 20 global secondary indexes (default quota) and 5 local secondary indexes Source 10সোর্স 10.
DynamoDB: reads, writes, capacity, and expiry. When your application writes to a table and receives an HTTP 200 response, the write completed successfully and has been durably persisted Source 11সোর্স 11. Tables and local secondary indexes offer two read consistency options: eventually consistent, which is the default, and strongly consistent reads Source 11সোর্স 11. All reads from global secondary indexes and streams are eventually consistent Source 11সোর্স 11. An eventually consistent read might not reflect the results of a recently completed write Source 11সোর্স 11. If you set ConsistentRead to true, DynamoDB returns the most up-to-date data, reflecting the updates from all prior successful writes Source 11সোর্স 11. Strongly consistent reads from a global secondary index or a stream are not supported Source 11সোর্স 11. Eventually consistent reads are half the cost of strongly consistent reads Source 11সোর্স 11.
On-demand mode is the default and recommended throughput option for most workloads Source 12সোর্স 12. In provisioned mode, you must specify the number of reads and writes per second that you require Source 12সোর্স 12. You are charged for the capacity that you provisioned, not for the capacity that you consumed Source 12সোর্স 12.
Time To Live (TTL) is a method for deleting items that are no longer relevant Source 13সোর্স 13. The expiration timestamp must be stored as a Number in Unix epoch time format at the seconds granularity Source 13সোর্স 13. The TTL process ignores items with a TTL attribute that is not a Number Source 13সোর্স 13. The system might delete items with valid, expired TTL attributes at any time, typically within a few days after their expiration Source 13সোর্স 13. You can use filter expressions to remove expired items from Scan and Query results Source 13সোর্স 13.
DynamoDB local. With the downloadable version of DynamoDB, you can develop and test applications without accessing the DynamoDB web service Source 20সোর্স 20. It is available as a download that requires a JRE, as an Apache Maven dependency, or as a Docker image Source 20সোর্স 20. When you are ready for production, you remove the local endpoint in the code, and it points to the DynamoDB web service Source 20সোর্স 20. The AWS CLI cannot use it as a default endpoint, so you must specify --endpoint-url with each AWS CLI command Source 22সোর্স 22. DynamoDB local uses port 8000 by default Source 21সোর্স 21. The AWS page says that it requires credentials to work, and it shows the made-up values fakeMyKeyId, fakeSecretAccessKey, and fakeRegion Source 21সোর্স 21. The page names the Docker image amazon/dynamodb-local:latest Source 21সোর্স 21.
With the -inMemory option, DynamoDB runs in memory, and none of the data is saved when you stop it Source 22সোর্স 22. DynamoDB local collects telemetry, such as generic usage metrics, systems and environment information, and errors Source 23সোর্স 23. If telemetry remains on, it sends the data in the background Source 23সোর্স 23. With the -disableTelemetry option, DynamoDB local will not send any telemetry Source 22সোর্স 22.
The downloadable version is intended for development and testing purposes only Source 22সোর্স 22. It differs from the web service in several ways Source 22সোর্স 22. Provisioned throughput settings are ignored, even though CreateTable requires them Source 22সোর্স 22. Scan operations are performed sequentially, and parallel scans are not supported Source 22সোর্স 22. Table operations occur immediately, and table state is always ACTIVE Source 22সোর্স 22. Read operations are eventually consistent, but most reads appear to be strongly consistent because of the speed of the local copy Source 22সোর্স 22. It doesn't support point-in-time recovery Source 22সোর্স 22. It always returns null for billingModeSummary Source 22সোর্স 22. AWS Regions and distinct AWS accounts are not supported at the client level Source 22সোর্স 22.
Athena: tables, the data catalog, and partitions. In Athena, catalogs, databases, and tables are containers for the metadata definitions that define a schema for underlying source data Source 30সোর্স 30. A database is a group of tables, and a table is data organized as a group of rows or columns Source 30সোর্স 30. The metadata in a table tells Athena where the data is located in Amazon S3, and specifies the structure of the data Source 30সোর্স 30. Before querying data, a table must be registered in Athena Source 30সোর্স 30. You can create a table automatically using an AWS Glue crawler Source 30সোর্স 30. Athena integrates with the AWS Glue Data Catalog, which offers a persistent metadata store Source 25সোর্স 25.
In the AWS tutorial, the sample log data is in tab-separated values (TSV) format Source 28সোর্স 28. The LOCATION clause names an Amazon S3 folder, not a specific file, because Athena expects to scan all of the files in a folder Source 28সোর্স 28. Athena keeps queries for 45 days Source 29সোর্স 29.
By partitioning your data, you can restrict the amount of data scanned by each query, thus improving performance and reducing cost Source 31সোর্স 31. If you query a partitioned table and specify the partition in the WHERE clause, Athena scans the data only from that partition Source 31সোর্স 31. Athena can use Hive style partitions, whose data paths contain key value pairs connected by equal signs Source 31সোর্স 31. The MSCK REPAIR TABLE command loads new Hive partitions, and it works only with Hive-style partitions Source 31সোর্স 31. For non-Hive style partitions, you use ALTER TABLE ADD PARTITION to add the partitions manually Source 31সোর্স 31.
Step Functions: state machines and workflow types. State machines are defined using JSON text Source 34সোর্স 34. StartAt and States are required Source 34সোর্স 34. The value of StartAt must exactly match, and is case sensitive, the name of one of the state objects Source 34সোর্স 34. States is an object containing a comma-delimited set of states Source 34সোর্স 34. TimeoutSeconds is optional, and it sets the maximum number of seconds an execution can run Source 34সোর্স 34. If an execution runs longer, it fails with the error name States.Timeout Source 34সোর্স 34.
A Choice state adds conditional logic to a state machine Source 35সোর্স 35. When it runs, Step Functions evaluates each Choice Rule to true or false Source 35সোর্স 35. Default is the name of the state to transition to if no Choice Rule evaluates to true Source 35সোর্স 35. If no rule is true and there is no Default, the state machine throws an error Source 35সোর্স 35.
Step Functions has two workflow types. Standard workflows are ideal for long-running, auditable workflows Source 32সোর্স 32. They have exactly-once workflow execution, and they can run for up to one year Source 32সোর্স 32. Express workflows are ideal for high-event-rate workloads Source 32সোর্স 32. They have at-least-once workflow execution, and they can run for up to five minutes Source 32সোর্স 32. So one or more steps in an Express workflow can potentially run more than once Source 32সোর্স 32. AWS SDK integrations call any AWS service directly from your state machine Source 32সোর্স 32.
Step Functions: errors and the TestState API. All states except Pass and Wait states can encounter runtime errors Source 36সোর্স 36. The causes include a Choice state without a matching rule, and a task failure such as an exception in a Lambda function Source 36সোর্স 36. When a state reports an error, Step Functions defaults to failing the entire state machine execution Source 36সোর্স 36. Task, Parallel, and Map states can have a field named Retry Source 36সোর্স 36. Catchers are available for Task, Parallel and Map states, but not for top-level state machine execution failures Source 36সোর্স 36. Step Functions identifies errors using case-sensitive strings, known as error names Source 36সোর্স 36.
The TestState API accepts the definition of a state and executes it Source 37সোর্স 37. It allows you to test a state without creating a state machine or updating an existing one Source 37সোর্স 37. It has three inspection levels, INFO, DEBUG, and TRACE Source 37সোর্স 37. INFO is the default Source 37সোর্স 37. At the DEBUG level, a successful test shows the state output and the result of input and output data processing Source 37সোর্স 37. A mock lets you test state logic without calling the actual service Source 37সোর্স 37. When you specify a mock, the role becomes optional Source 37সোর্স 37. The TestState API enables you to write unit tests for your state machines Source 37সোর্স 37.
সহজ English
Lambda: the function, the event, and the handler. In Python, a Lambda function can contain more than one Python function, but the handler function is always the entry point to your code Source 2সোর্স 2. When your function is invoked, Lambda runs this method Source 2সোর্স 2. The handler takes two arguments, event and context Source 2সোর্স 2.
An event in Lambda is a JSON formatted document that contains data for your function to process Source 2সোর্স 2. If another AWS service invokes your function, the event object contains information about the event that caused the invocation Source 2সোর্স 2. Lambda passes the context object to your function automatically Source 2সোর্স 2. The context object contains information about the function invocation and execution environment Source 2সোর্স 2.
With Python, you can use either a print statement or a Python logging library to send information to your function's log Source 2সোর্স 2. In a production application, AWS recommends a logging library Source 2সোর্স 2. When you invoke your function outside of the Lambda console, you must use CloudWatch Logs to view your function's execution results Source 2সোর্স 2.
Lambda: how a function is invoked. After you deploy your function, you can invoke it in several ways Source 3সোর্স 3. One way is the aws lambda invoke AWS CLI command Source 3সোর্স 3. Another way is a function URL, which is a dedicated HTTP(S) endpoint Source 3সোর্স 3.
Some services can invoke a function with each new event, and this is called a trigger Source 3সোর্স 3. For stream and queue-based services, Lambda invokes the function with batches of records, which is called an event source mapping Source 3সোর্স 3.
With synchronous invocation, you wait for the function to process the event and return a response Source 3সোর্স 3. With asynchronous invocation, Lambda queues the event for processing and returns a response immediately Source 3সোর্স 3. The InvocationType parameter decides which one: RequestResponse means synchronous, and Event means asynchronous Source 3সোর্স 3.
For an error in a synchronous invocation, you view the error message in the response and retry the invocation manually Source 3সোর্স 3. For asynchronous invocations, Lambda handles retries automatically and can send invocation records to a destination Source 3সোর্স 3.
Lambda: the execution role and the settings. A function's execution role is an IAM role that grants the function permission to access AWS services and resources Source 4সোর্স 4. Lambda automatically assumes your execution role when you invoke your function Source 4সোর্স 4. The trust policy of the role must specify the Lambda service principal, lambda.amazonaws.com, as a trusted service Source 4সোর্স 4. In the Lambda console, Lambda creates an execution role with minimal permissions by default Source 4সোর্স 4. This role includes the AWSLambdaBasicExecutionRole managed policy, which gives basic permissions to log events to Amazon CloudWatch Logs Source 4সোর্স 4.
Timeout is the maximum amount of time in seconds that a Lambda function can run Source 5সোর্স 5. The default is 3 seconds, and you can adjust it in increments of 1 second up to a maximum value of 1,800 seconds (30 minutes) Source 5সোর্স 5. For functions using AWS Lambda Managed Instances, asynchronous invocations and event source mapping invocations (except Amazon MQ and Amazon DocumentDB) support a maximum allowed value of 5,400 seconds (90 minutes) Source 5সোর্স 5. The update-function-configuration command sets the timeout, in seconds Source 5সোর্স 5.
Lambda: the execution environment, cold starts, and scaling. Lambda invokes your function in an execution environment, which provides a secure and isolated runtime environment Source 6সোর্স 6. In the Init phase, Lambda performs three tasks Source 6সোর্স 6. It starts all extensions, bootstraps the runtime, and runs the static code of the function Source 6সোর্স 6. The Init phase is limited to 10 seconds Source 6সোর্স 6. The timeout setting of the function limits the duration of the entire Invoke phase Source 6সোর্স 6.
After an invocation, Lambda keeps the execution environment for some time, in anticipation of another invocation Source 6সোর্স 6. Objects declared outside of the handler remain initialized when the function is invoked again Source 6সোর্স 6. The /tmp directory keeps its content while the environment is frozen Source 6সোর্স 6. Background processes that did not complete when the function ended resume if Lambda reuses the environment Source 6সোর্স 6. Lambda terminates execution environments every few hours Source 6সোর্স 6. So you should not assume that the environment persists indefinitely Source 6সোর্স 6. If a function crashes or times out during the Invoke phase, Lambda resets the environment Source 6সোর্স 6.
When Lambda has to initialize a new environment to carry out an invocation, this is known as a cold start Source 7সোর্স 7. A cold start adds latency to the invocation duration, and you are charged for this time Source 6সোর্স 6. Cold starts typically occur in under 1% of invocations Source 6সোর্স 6. They are typically more common in development and test functions than in production workloads Source 6সোর্স 6. The reason is that development and test functions are usually invoked less frequently Source 6সোর্স 6.
Concurrency is the number of in-flight requests that a function is handling at the same time Source 7সোর্স 7. For each concurrent request, Lambda provisions a separate instance of your execution environment Source 7সোর্স 7. By default, an account has a total limit of 1,000 concurrent executions across all Event Functions in a Region Source 7সোর্স 7. If a function runs out of available concurrency, it experiences throttling, which means that it starts to drop requests Source 7সোর্স 7. Reserved concurrency reserves a portion of the concurrency of your account for a function Source 7সোর্স 7. There is no charge for configuring it Source 7সোর্স 7. Provisioned concurrency pre-initializes environment instances, which reduces cold start latencies Source 7সোর্স 7. Using provisioned concurrency incurs additional charges Source 7সোর্স 7.
DynamoDB: tables, items, and keys. When you create a table, in addition to the table name, you must specify its primary key Source 10সোর্স 10. The primary key uniquely identifies each item in the table, so that no two items can have the same key Source 10সোর্স 10. DynamoDB uses the value of the partition key as input to an internal hash function Source 10সোর্স 10. The output of the hash function determines the partition in which the item is stored Source 10সোর্স 10. In a table that has only a partition key, no two items can have the same partition key value Source 10সোর্স 10.
With a partition key and a sort key, all items with the same partition key value are stored together, in sorted order by sort key value Source 10সোর্স 10. Multiple items can have the same partition key value, but they must have different sort key values Source 10সোর্স 10. In the Music example of AWS, if you provide only the value for Artist, DynamoDB retrieves all of the songs by that artist Source 10সোর্স 10. In the Music example, each item must have both key attributes Source 10সোর্স 10. Other than the primary key, the Music table is schemaless Source 10সোর্স 10. Each primary key attribute must be a scalar Source 10সোর্স 10. The only data types allowed for primary key attributes are string, number, or binary Source 10সোর্স 10.
A secondary index lets you query the data in the table using an alternate key, in addition to queries against the primary key Source 10সোর্স 10. A global secondary index has a partition key and sort key that can be different from those of the table Source 10সোর্স 10. A local secondary index has the same partition key as the table, but a different sort key Source 10সোর্স 10. Each table has a quota of 20 global secondary indexes (default quota) and 5 local secondary indexes Source 10সোর্স 10.
DynamoDB: reads, writes, capacity, and expiry. When your application writes to a table and receives an HTTP 200 response, the write completed successfully and has been durably persisted Source 11সোর্স 11. Tables and local secondary indexes offer two read consistency options: eventually consistent, which is the default, and strongly consistent reads Source 11সোর্স 11. All reads from global secondary indexes and streams are eventually consistent Source 11সোর্স 11. An eventually consistent read might not reflect the results of a recently completed write Source 11সোর্স 11. If you set ConsistentRead to true, DynamoDB returns the most up-to-date data, reflecting the updates from all prior successful writes Source 11সোর্স 11. Strongly consistent reads from a global secondary index or a stream are not supported Source 11সোর্স 11. Eventually consistent reads are half the cost of strongly consistent reads Source 11সোর্স 11.
On-demand mode is the default and recommended throughput option for most workloads Source 12সোর্স 12. In provisioned mode, you must specify the number of reads and writes per second that you require Source 12সোর্স 12. You are charged for the capacity that you provisioned, not for the capacity that you consumed Source 12সোর্স 12.
Time To Live (TTL) is a method for deleting items that are no longer relevant Source 13সোর্স 13. The expiration timestamp must be stored as a Number in Unix epoch time format at the seconds granularity Source 13সোর্স 13. The TTL process ignores items with a TTL attribute that is not a Number Source 13সোর্স 13. The system might delete items with valid, expired TTL attributes at any time, typically within a few days after their expiration Source 13সোর্স 13. You can use filter expressions to remove expired items from Scan and Query results Source 13সোর্স 13.
DynamoDB local. With the downloadable version of DynamoDB, you can develop and test applications without accessing the DynamoDB web service Source 20সোর্স 20. It is available as a download that requires a JRE, as an Apache Maven dependency, or as a Docker image Source 20সোর্স 20. When you are ready for production, you remove the local endpoint in the code, and it points to the DynamoDB web service Source 20সোর্স 20. The AWS CLI cannot use it as a default endpoint, so you must specify --endpoint-url with each AWS CLI command Source 22সোর্স 22. DynamoDB local uses port 8000 by default Source 21সোর্স 21. The AWS page says that it requires credentials to work, and it shows the made-up values fakeMyKeyId, fakeSecretAccessKey, and fakeRegion Source 21সোর্স 21. The page names the Docker image amazon/dynamodb-local:latest Source 21সোর্স 21.
With the -inMemory option, DynamoDB runs in memory, and none of the data is saved when you stop it Source 22সোর্স 22. DynamoDB local collects telemetry, such as generic usage metrics, systems and environment information, and errors Source 23সোর্স 23. If telemetry remains on, it sends the data in the background Source 23সোর্স 23. With the -disableTelemetry option, DynamoDB local will not send any telemetry Source 22সোর্স 22.
The downloadable version is intended for development and testing purposes only Source 22সোর্স 22. It differs from the web service in several ways Source 22সোর্স 22. Provisioned throughput settings are ignored, even though CreateTable requires them Source 22সোর্স 22. Scan operations are performed sequentially, and parallel scans are not supported Source 22সোর্স 22. Table operations occur immediately, and table state is always ACTIVE Source 22সোর্স 22. Read operations are eventually consistent, but most reads appear to be strongly consistent because of the speed of the local copy Source 22সোর্স 22. It doesn't support point-in-time recovery Source 22সোর্স 22. It always returns null for billingModeSummary Source 22সোর্স 22. AWS Regions and distinct AWS accounts are not supported at the client level Source 22সোর্স 22.
Athena: tables, the data catalog, and partitions. In Athena, catalogs, databases, and tables are containers for the metadata definitions that define a schema for underlying source data Source 30সোর্স 30. A database is a group of tables, and a table is data organized as a group of rows or columns Source 30সোর্স 30. The metadata in a table tells Athena where the data is located in Amazon S3, and specifies the structure of the data Source 30সোর্স 30. Before querying data, a table must be registered in Athena Source 30সোর্স 30. You can create a table automatically using an AWS Glue crawler Source 30সোর্স 30. Athena integrates with the AWS Glue Data Catalog, which offers a persistent metadata store Source 25সোর্স 25.
In the AWS tutorial, the sample log data is in tab-separated values (TSV) format Source 28সোর্স 28. The LOCATION clause names an Amazon S3 folder, not a specific file, because Athena expects to scan all of the files in a folder Source 28সোর্স 28. Athena keeps queries for 45 days Source 29সোর্স 29.
By partitioning your data, you can restrict the amount of data scanned by each query, thus improving performance and reducing cost Source 31সোর্স 31. If you query a partitioned table and specify the partition in the WHERE clause, Athena scans the data only from that partition Source 31সোর্স 31. Athena can use Hive style partitions, whose data paths contain key value pairs connected by equal signs Source 31সোর্স 31. The MSCK REPAIR TABLE command loads new Hive partitions, and it works only with Hive-style partitions Source 31সোর্স 31. For non-Hive style partitions, you use ALTER TABLE ADD PARTITION to add the partitions manually Source 31সোর্স 31.
Step Functions: state machines and workflow types. State machines are defined using JSON text Source 34সোর্স 34. StartAt and States are required Source 34সোর্স 34. The value of StartAt must exactly match, and is case sensitive, the name of one of the state objects Source 34সোর্স 34. States is an object containing a comma-delimited set of states Source 34সোর্স 34. TimeoutSeconds is optional, and it sets the maximum number of seconds an execution can run Source 34সোর্স 34. If an execution runs longer, it fails with the error name States.Timeout Source 34সোর্স 34.
A Choice state adds conditional logic to a state machine Source 35সোর্স 35. When it runs, Step Functions evaluates each Choice Rule to true or false Source 35সোর্স 35. Default is the name of the state to transition to if no Choice Rule evaluates to true Source 35সোর্স 35. If no rule is true and there is no Default, the state machine throws an error Source 35সোর্স 35.
Step Functions has two workflow types. Standard workflows are ideal for long-running, auditable workflows Source 32সোর্স 32. They have exactly-once workflow execution, and they can run for up to one year Source 32সোর্স 32. Express workflows are ideal for high-event-rate workloads Source 32সোর্স 32. They have at-least-once workflow execution, and they can run for up to five minutes Source 32সোর্স 32. So one or more steps in an Express workflow can potentially run more than once Source 32সোর্স 32. AWS SDK integrations call any AWS service directly from your state machine Source 32সোর্স 32.
Step Functions: errors and the TestState API. All states except Pass and Wait states can encounter runtime errors Source 36সোর্স 36. The causes include a Choice state without a matching rule, and a task failure such as an exception in a Lambda function Source 36সোর্স 36. When a state reports an error, Step Functions defaults to failing the entire state machine execution Source 36সোর্স 36. Task, Parallel, and Map states can have a field named Retry Source 36সোর্স 36. Catchers are available for Task, Parallel and Map states, but not for top-level state machine execution failures Source 36সোর্স 36. Step Functions identifies errors using case-sensitive strings, known as error names Source 36সোর্স 36.
The TestState API accepts the definition of a state and executes it Source 37সোর্স 37. It allows you to test a state without creating a state machine or updating an existing one Source 37সোর্স 37. It has three inspection levels, INFO, DEBUG, and TRACE Source 37সোর্স 37. INFO is the default Source 37সোর্স 37. At the DEBUG level, a successful test shows the state output and the result of input and output data processing Source 37সোর্স 37. A mock lets you test state logic without calling the actual service Source 37সোর্স 37. When you specify a mock, the role becomes optional Source 37সোর্স 37. The TestState API enables you to write unit tests for your state machines Source 37সোর্স 37.
বাংলা ব্যাখ্যা
Lambda: function, event আর handler। Python-এ একটা Lambda function-এ একাধিক Python function থাকতে পারে, কিন্তু handler function-ই সবসময় আপনার code-এর প্রবেশ বিন্দু Source 2সোর্স 2। আপনার function চালু হলে Lambda এই method চালায় Source 2সোর্স 2। handler দুটো argument নেয়, event আর context Source 2সোর্স 2।
Lambda-য় একটা event হলো JSON format-এর একটা document, যাতে আপনার function-এর প্রক্রিয়া করার data থাকে Source 2সোর্স 2। অন্য একটা AWS service আপনার function চালু করলে event object-এ সেই ঘটনার তথ্য থাকে, যা invocation ঘটিয়েছে Source 2সোর্স 2। Lambda context object আপনার function-কে নিজে থেকেই পাস করে Source 2সোর্স 2। context object-এ function invocation আর execution environment-এর তথ্য থাকে Source 2সোর্স 2।
Python-এ আপনি আপনার function-এর log-এ তথ্য পাঠাতে print statement বা Python logging library দুটোর যেকোনোটা ব্যবহার করতে পারেন Source 2সোর্স 2। production application-এ AWS একটা logging library-র সুপারিশ করে Source 2সোর্স 2। Lambda console-এর বাইরে function চালালে তার চালানোর ফল দেখতে CloudWatch Logs ব্যবহার করতেই হয় Source 2সোর্স 2।
Lambda: function কীভাবে চালু হয়। আপনার function deploy করার পর আপনি তাকে কয়েকভাবে চালু করতে পারেন Source 3সোর্স 3। একটা উপায় হলো aws lambda invoke AWS CLI command Source 3সোর্স 3। আরেকটা উপায় হলো function URL, যা একটা নির্দিষ্ট HTTP(S) endpoint Source 3সোর্স 3।
কিছু service প্রতিটা নতুন event-এ একটা function চালু করতে পারে, একে trigger বলে Source 3সোর্স 3। stream আর queue-ভিত্তিক service-এর জন্য Lambda record-এর batch দিয়ে function চালু করে, একে event source mapping বলে Source 3সোর্স 3।
synchronous invocation-এ আপনি অপেক্ষা করেন, যতক্ষণ না function event-টা প্রক্রিয়া করে response ফেরত দেয় Source 3সোর্স 3। asynchronous invocation-এ Lambda event-টা প্রক্রিয়ার জন্য queue-তে রাখে আর সঙ্গে সঙ্গে response ফেরত দেয় Source 3সোর্স 3। InvocationType parameter ঠিক করে কোনটা হবে: RequestResponse মানে synchronous, আর Event মানে asynchronous Source 3সোর্স 3।
synchronous invocation-এর একটা error-এ আপনি response-এ error message দেখেন আর invocation নিজে হাতে আবার চালান Source 3সোর্স 3। asynchronous invocation-এ Lambda নিজে থেকেই retry করে আর invocation record একটা destination-এ পাঠাতে পারে Source 3সোর্স 3।
Lambda: execution role আর setting। একটা function-এর execution role হলো একটা IAM role, যা function-কে AWS service ও resource-এ প্রবেশের permission দেয় Source 4সোর্স 4। আপনি function চালু করলে Lambda নিজে থেকেই আপনার execution role assume করে Source 4সোর্স 4। role-এর trust policy-তে Lambda service principal lambda.amazonaws.com-কে একটা বিশ্বস্ত service হিসেবে উল্লেখ করতে হয় Source 4সোর্স 4। Lambda console-এ Lambda by default ন্যূনতম permission-সহ একটা execution role বানায় Source 4সোর্স 4। এই role-এ AWSLambdaBasicExecutionRole managed policy থাকে, যা Amazon CloudWatch Logs-এ event log করার মৌলিক permission দেয় Source 4সোর্স 4।
Timeout হলো একটা Lambda function সর্বোচ্চ কত সেকেন্ড চলতে পারে Source 5সোর্স 5। default ৩ সেকেন্ড, আর আপনি ১ সেকেন্ড করে বাড়িয়ে সর্বোচ্চ ১,৮০০ সেকেন্ড (৩০ মিনিট) পর্যন্ত বদলাতে পারেন Source 5সোর্স 5। AWS Lambda Managed Instances ব্যবহার করা function-এর জন্য asynchronous invocation আর event source mapping invocation (Amazon MQ আর Amazon DocumentDB ছাড়া) সর্বোচ্চ অনুমোদিত মান হিসেবে ৫,৪০০ সেকেন্ড (৯০ মিনিট) সমর্থন করে Source 5সোর্স 5। update-function-configuration command timeout সেকেন্ডে ঠিক করে Source 5সোর্স 5।
Lambda: execution environment, cold start আর scaling। Lambda আপনার function একটা execution environment-এ চালায়, যা একটা নিরাপদ ও বিচ্ছিন্ন runtime environment দেয় Source 6সোর্স 6। Init phase-এ Lambda তিনটা কাজ করে Source 6সোর্স 6। সে সব extension চালু করে, runtime bootstrap করে আর function-এর static code চালায় Source 6সোর্স 6। Init phase ১০ সেকেন্ডে সীমিত Source 6সোর্স 6। function-এর timeout setting পুরো Invoke phase-এর সময় সীমিত করে Source 6সোর্স 6।
একটা invocation-এর পর Lambda আরেকটা invocation-এর প্রত্যাশায় execution environment কিছু সময় রেখে দেয় Source 6সোর্স 6। handler-এর বাইরে ঘোষণা করা object function আবার চালু হলে initialized-ই থাকে Source 6সোর্স 6। environment frozen থাকার সময় /tmp directory-র content থেকে যায় Source 6সোর্স 6। function শেষ হওয়ার সময় যে background process শেষ হয়নি, Lambda environment আবার ব্যবহার করলে সেগুলো আবার চলতে শুরু করে Source 6সোর্স 6। Lambda প্রতি কয়েক ঘণ্টায় execution environment বন্ধ করে দেয় Source 6সোর্স 6। তাই environment যে অনির্দিষ্টকাল টিকে থাকবে, তা ধরে নেওয়া উচিত নয় Source 6সোর্স 6। Invoke phase-এর সময় function crash করলে বা time out হলে Lambda environment reset করে Source 6সোর্স 6।
Lambda-কে একটা invocation চালাতে নতুন একটা environment initialize করতে হলে একে cold start বলে Source 7সোর্স 7। cold start invocation-এর সময়ে latency যোগ করে, আর সেই সময়ের জন্য আপনার খরচ হয় Source 6সোর্স 6। cold start সাধারণত ১%-এরও কম invocation-এ ঘটে Source 6সোর্স 6। production workload-এর চেয়ে development আর test function-এ এগুলো সাধারণত বেশি ঘটে Source 6সোর্স 6। কারণ development আর test function সাধারণত কম চালু হয় Source 6সোর্স 6।
Concurrency হলো একটা function একই সময়ে যতগুলো in-flight request সামলাচ্ছে তার সংখ্যা Source 7সোর্স 7। প্রতিটা concurrent request-এর জন্য Lambda আপনার execution environment-এর আলাদা একটা instance provision করে Source 7সোর্স 7। by default একটা account-এর একটা Region-এ সব Event Function মিলিয়ে মোট ১,০০০টা concurrent execution-এর সীমা থাকে Source 7সোর্স 7। একটা function-এর available concurrency ফুরিয়ে গেলে সে throttling-এর মুখে পড়ে, মানে request ফেলে দিতে শুরু করে Source 7সোর্স 7। Reserved concurrency আপনার account-এর concurrency-র একটা অংশ একটা function-এর জন্য রেখে দেয় Source 7সোর্স 7। এটা ঠিক করতে কোনো খরচ নেই Source 7সোর্স 7। Provisioned concurrency কিছু environment instance আগে থেকে initialize করে রাখে, যা cold start latency কমায় Source 7সোর্স 7। Provisioned concurrency ব্যবহারে বাড়তি খরচ হয় Source 7সোর্স 7।
DynamoDB: table, item আর key। একটা table বানানোর সময় table-এর নামের পাশাপাশি তার primary key-ও ঠিক করে দিতে হয় Source 10সোর্স 10। primary key table-এর প্রতিটা item-কে আলাদাভাবে চেনায়, ফলে দুটো item-এর key এক হতে পারে না Source 10সোর্স 10। DynamoDB partition key-র মানকে একটা internal hash function-এর input হিসেবে ব্যবহার করে Source 10সোর্স 10। hash function-এর output ঠিক করে item-টা কোন partition-এ রাখা হবে Source 10সোর্স 10। শুধু partition key আছে এমন একটা table-এ দুটো item-এর partition key-র মান এক হতে পারে না Source 10সোর্স 10।
partition key আর sort key থাকলে একই partition key-র মান আছে এমন সব item একসঙ্গে রাখা হয়, sort key-র মান অনুযায়ী সাজানো অবস্থায় Source 10সোর্স 10। একাধিক item-এর partition key-র মান এক হতে পারে, কিন্তু তাদের sort key-র মান আলাদা হতে হবে Source 10সোর্স 10। AWS-এর Music উদাহরণে আপনি শুধু Artist-এর মান দিলে DynamoDB সেই artist-এর সব গান নিয়ে আসে Source 10সোর্স 10। Music উদাহরণে প্রতিটা item-এ দুটো key attribute-ই থাকতে হয় Source 10সোর্স 10। primary key ছাড়া Music table schemaless Source 10সোর্স 10। প্রতিটা primary key attribute scalar হতে হয় Source 10সোর্স 10। primary key attribute-এর জন্য অনুমোদিত data type শুধু string, number বা binary Source 10সোর্স 10।
একটা secondary index আপনাকে primary key-র query-র পাশাপাশি একটা বিকল্প key দিয়ে table-এর data query করতে দেয় Source 10সোর্স 10। একটা global secondary index-এর partition key আর sort key table-এর থেকে আলাদা হতে পারে Source 10সোর্স 10। একটা local secondary index-এর partition key table-এর মতোই, কিন্তু sort key আলাদা Source 10সোর্স 10। প্রতিটা table-এ ২০টা global secondary index (default quota) আর ৫টা local secondary index-এর quota আছে Source 10সোর্স 10।
DynamoDB: read, write, capacity আর মেয়াদ। আপনার application একটা table-এ লিখে HTTP 200 response পেলে তার মানে লেখা সফলভাবে শেষ হয়েছে আর স্থায়ীভাবে জমা হয়েছে Source 11সোর্স 11। table আর local secondary index দুটো read consistency বিকল্প দেয়: eventually consistent, যা default, আর strongly consistent read Source 11সোর্স 11। global secondary index আর stream থেকে সব read eventually consistent Source 11সোর্স 11। একটা eventually consistent read সদ্য শেষ হওয়া লেখার ফল না-ও দেখাতে পারে Source 11সোর্স 11। আপনি ConsistentRead true করলে DynamoDB সবচেয়ে হালনাগাদ data ফেরত দেয়, যাতে আগের সব সফল লেখার পরিবর্তন প্রতিফলিত থাকে Source 11সোর্স 11। একটা global secondary index বা stream থেকে strongly consistent read সমর্থিত নয় Source 11সোর্স 11। eventually consistent read-এর খরচ strongly consistent read-এর অর্ধেক Source 11সোর্স 11।
On-demand mode বেশির ভাগ workload-এর জন্য default আর সুপারিশ করা throughput বিকল্প Source 12সোর্স 12। provisioned mode-এ আপনাকে ঠিক করে দিতে হয় প্রতি সেকেন্ডে কতটা read আর write আপনার লাগে Source 12সোর্স 12। আপনি যে capacity provision করেছেন তার জন্য আপনার খরচ হয়, যে capacity ব্যবহার করেছেন তার জন্য নয় Source 12সোর্স 12।
Time To Live (TTL) হলো যে item আর প্রাসঙ্গিক নয় তা মুছে ফেলার একটা পদ্ধতি Source 13সোর্স 13। মেয়াদ শেষের timestamp একটা Number হিসেবে সেকেন্ড granularity-তে Unix epoch time format-এ রাখতে হয় Source 13সোর্স 13। TTL attribute Number নয় এমন item-কে TTL process উপেক্ষা করে Source 13সোর্স 13। বৈধ, মেয়াদোত্তীর্ণ TTL attribute-সহ item system যেকোনো সময় মুছে ফেলতে পারে, সাধারণত মেয়াদ শেষের কয়েক দিনের মধ্যে Source 13সোর্স 13। মেয়াদোত্তীর্ণ item Scan আর Query-র ফল থেকে বাদ দিতে আপনি filter expression ব্যবহার করতে পারেন Source 13সোর্স 13।
DynamoDB local। DynamoDB-র downloadable version দিয়ে আপনি DynamoDB web service-এ না গিয়েই application develop ও test করতে পারেন Source 20সোর্স 20। এটা পাওয়া যায় এমন download হিসেবে যার জন্য JRE লাগে, Apache Maven dependency হিসেবে, বা Docker image হিসেবে Source 20সোর্স 20। production-এর জন্য তৈরি হলে আপনি code থেকে local endpoint সরিয়ে দেন, আর তখন সেটা DynamoDB web service-কে নির্দেশ করে Source 20সোর্স 20। AWS CLI একে default endpoint হিসেবে ব্যবহার করতে পারে না, তাই প্রতিটা AWS CLI command-এ --endpoint-url দিতে হয় Source 22সোর্স 22। DynamoDB local by default port 8000 ব্যবহার করে Source 21সোর্স 21। AWS-এর page বলে, এটা চলতে credential লাগে, আর সে বানানো মান fakeMyKeyId, fakeSecretAccessKey ও fakeRegion দেখায় Source 21সোর্স 21। page-টা Docker image-টার নাম দেয় amazon/dynamodb-local:latest Source 21সোর্স 21।
-inMemory option-এ DynamoDB memory-তে চলে, আর বন্ধ করলে কোনো data সংরক্ষিত থাকে না Source 22সোর্স 22। DynamoDB local telemetry সংগ্রহ করে, যেমন সাধারণ ব্যবহারের metric, system ও environment-এর তথ্য আর error Source 23সোর্স 23। telemetry চালু থাকলে সে ডেটা background-এ পাঠায় Source 23সোর্স 23। -disableTelemetry option দিলে DynamoDB local কোনো telemetry পাঠাবে না Source 22সোর্স 22।
downloadable version শুধু development আর testing-এর উদ্দেশ্যে Source 22সোর্স 22। web service-এর থেকে এর কয়েকটা পার্থক্য আছে Source 22সোর্স 22। provisioned throughput setting উপেক্ষা করা হয়, যদিও CreateTable সেগুলো চায় Source 22সোর্স 22। Scan operation পরপর চলে, আর parallel scan সমর্থিত নয় Source 22সোর্স 22। table-এর operation সঙ্গে সঙ্গে ঘটে, আর table state সবসময় ACTIVE Source 22সোর্স 22। read operation eventually consistent, কিন্তু local copy-র গতির কারণে বেশির ভাগ read strongly consistent মনে হয় Source 22সোর্স 22। এটা point-in-time recovery সমর্থন করে না Source 22সোর্স 22। এটা billingModeSummary-র জন্য সবসময় null ফেরত দেয় Source 22সোর্স 22। client স্তরে AWS Region আর আলাদা AWS account সমর্থিত নয় Source 22সোর্স 22।
Athena: table, data catalog আর partition। Athena-য় catalog, database আর table হলো সেই metadata সংজ্ঞার container, যা নিচের source data-র একটা schema ঠিক করে Source 30সোর্স 30। একটা database হলো table-এর একটা দল, আর একটা table হলো row বা column আকারে সাজানো data Source 30সোর্স 30। একটা table-এর metadata Athena-কে বলে data Amazon S3-এ কোথায় আছে, আর data-র কাঠামো ঠিক করে Source 30সোর্স 30। data query করার আগে একটা table Athena-য় register করা থাকতে হয় Source 30সোর্স 30। আপনি একটা AWS Glue crawler দিয়ে স্বয়ংক্রিয়ভাবে table বানাতে পারেন Source 30সোর্স 30। Athena AWS Glue Data Catalog-এর সঙ্গে সমন্বিত, যা একটা স্থায়ী metadata store দেয় Source 25সোর্স 25।
AWS-এর tutorial-এ নমুনা log data tab-separated values (TSV) format-এ Source 28সোর্স 28। LOCATION clause Amazon S3-এর একটা folder-কে নির্দেশ করে, নির্দিষ্ট একটা file-কে নয়, কারণ Athena একটা folder-এর সব file scan করতে চায় Source 28সোর্স 28। Athena query-গুলো ৪৫ দিন রাখে Source 29সোর্স 29।
আপনার data partition করে আপনি প্রতিটা query-তে scan হওয়া data-র পরিমাণ সীমিত করতে পারেন, ফলে performance বাড়ে আর খরচ কমে Source 31সোর্স 31। আপনি একটা partitioned table query করে WHERE clause-এ partition উল্লেখ করলে Athena শুধু সেই partition থেকে data scan করে Source 31সোর্স 31। Athena Hive style partition ব্যবহার করতে পারে, যাদের data path-এ সমান চিহ্ন দিয়ে জোড়া key value জোড় থাকে Source 31সোর্স 31। MSCK REPAIR TABLE command নতুন Hive partition load করে, আর এটা শুধু Hive-style partition-এর সঙ্গে কাজ করে Source 31সোর্স 31। Hive style নয় এমন partition-এর জন্য আপনি ALTER TABLE ADD PARTITION দিয়ে partition হাতে যোগ করেন Source 31সোর্স 31।
Step Functions: state machine আর workflow-র ধরন। State machine JSON text দিয়ে সংজ্ঞায়িত হয় Source 34সোর্স 34। StartAt আর States আবশ্যক Source 34সোর্স 34। StartAt-এর মান state object-গুলোর একটার নামের সঙ্গে হুবহু মিলতে হয়, আর এটা case sensitive Source 34সোর্স 34। States হলো কমা দিয়ে আলাদা করা state-এর একটা সেট ধারণকারী object Source 34সোর্স 34। TimeoutSeconds ঐচ্ছিক, আর সেটা ঠিক করে একটা execution সর্বোচ্চ কত সেকেন্ড চলতে পারে Source 34সোর্স 34। একটা execution তার চেয়ে বেশি সময় চললে সেটা States.Timeout error name-সহ ব্যর্থ হয় Source 34সোর্স 34।
একটা Choice state একটা state machine-এ শর্তসাপেক্ষ যুক্তি যোগ করে Source 35সোর্স 35। সেটা চলার সময় Step Functions প্রতিটা Choice Rule true না false তা মূল্যায়ন করে Source 35সোর্স 35। Default হলো সেই state-এর নাম, যেখানে যেতে হবে যদি কোনো Choice Rule true না হয় Source 35সোর্স 35। কোনো rule true না হলে আর Default না থাকলে state machine একটা error ছোড়ে Source 35সোর্স 35।
Step Functions-এ দুই ধরনের workflow আছে। Standard workflow দীর্ঘ-চলমান, নিরীক্ষণযোগ্য workflow-র জন্য আদর্শ Source 32সোর্স 32। এগুলোতে exactly-once workflow execution আছে, আর এগুলো এক বছর পর্যন্ত চলতে পারে Source 32সোর্স 32। Express workflow বেশি-event-হারের workload-এর জন্য আদর্শ Source 32সোর্স 32। এগুলোতে at-least-once workflow execution আছে, আর এগুলো পাঁচ মিনিট পর্যন্ত চলতে পারে Source 32সোর্স 32। তাই একটা Express workflow-র এক বা একাধিক ধাপ সম্ভবত একাধিকবার চলতে পারে Source 32সোর্স 32। AWS SDK integration আপনার state machine থেকে সরাসরি যেকোনো AWS service call করে Source 32সোর্স 32।
Step Functions: error আর TestState API। Pass আর Wait state বাদে সব state runtime error-এর মুখে পড়তে পারে Source 36সোর্স 36। কারণের মধ্যে আছে মিলে যাওয়া rule ছাড়া একটা Choice state, আর Lambda function-এর একটা exception-এর মতো task-এর ব্যর্থতা Source 36সোর্স 36। একটা state error জানালে Step Functions by default পুরো state machine execution ব্যর্থ করে দেয় Source 36সোর্স 36। Task, Parallel আর Map state-এ Retry নামে একটা field থাকতে পারে Source 36সোর্স 36। catcher পাওয়া যায় Task, Parallel আর Map state-এর জন্য, কিন্তু top-level state machine execution-এর ব্যর্থতার জন্য নয় Source 36সোর্স 36। Step Functions error চেনে case-sensitive string দিয়ে, যাদের error name বলে Source 36সোর্স 36।
TestState API একটা state-এর সংজ্ঞা নিয়ে সেটা চালায় Source 37সোর্স 37। এটা আপনাকে state machine না বানিয়ে বা বিদ্যমান একটা state machine হালনাগাদ না করে একটা state test করতে দেয় Source 37সোর্স 37। এর তিনটা inspection level আছে, INFO, DEBUG আর TRACE Source 37সোর্স 37। INFO হলো default Source 37সোর্স 37। DEBUG level-এ একটা সফল test state-এর output আর input ও output data processing-এর ফল দেখায় Source 37সোর্স 37। একটা mock আপনাকে আসল service call না করেই state-এর যুক্তি test করতে দেয় Source 37সোর্স 37। আপনি একটা mock দিলে role ঐচ্ছিক হয়ে যায় Source 37সোর্স 37। TestState API আপনাকে আপনার state machine-এর জন্য unit test লিখতে সক্ষম করে Source 37সোর্স 37।
Try it
The tutorial ran steps 1 to 5 on 2026-11-19 at 13:04 (+06) on Linux 7.0.0-43-generic, with Python 3.14.4, aws-cli/2.41.0, Docker 29.10.0, and bash 5.3.9. Steps 1, 3, and 4 are Python only. Step 2 ran DynamoDB local from the Docker image amazon/dynamodb-local@sha256:6ada631ec7aa5fc83446855eb17233e3dad184fec47477e8140c6c569cfe0c86, which is DynamoDB local 3.3.2. The image takes about 780 MB on disk. The tutorial pulled it before the run, and it was not on the machine before. Steps 1 to 5 need no AWS account. In step 2, the tutorial passed --endpoint-url with every command, and it gave the AWS CLI made-up credentials. The tutorial did not watch the network. In the tutorial's run, no AWS_ variable was set before the steps. After the run, the AWS CLI had created the folder ~/.aws, which did not exist before, with one file in it, cli/cache/session.db. The tutorial removed both. No page that the tutorial read says why the file appears. A separate check ran on 2026-11-19 at 13:29 (+06), with the same AWS CLI and a new, empty HOME for each command: aws --version and the two --generate-cli-skeleton commands of step 5 created no file, and aws dynamodb list-tables --endpoint-url http://127.0.0.1:1, where nothing listens, created .aws/cli/cache/session.db. Step 5 reuses the AWS CLI that step 1 of AWS Compute and Storage installs. The output is from the tutorial's run. Step 6 is a read-along of AWS's own tutorials. The tutorial did not run it, because it needs an account and can cost money.
1. Test the example function of AWS Lambda. The function of this step is the Python function of the AWS tutorial "Create your first Lambda function" Source 2সোর্স 2. The tutorial copied it from the page, and only removed the spaces at the ends of lines. It takes a JSON object with two values, length and width, multiplies them, and returns the area as a JSON string Source 2সোর্স 2. Save it as lambda_function.py:
import json
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
# Get the length and width parameters from the event object. The
# runtime converts the event object to a Python dictionary
length = event['length']
width = event['width']
area = calculate_area(length, width)
print(f"The area is {area}")
logger.info(f"CloudWatch logs group: {context.log_group_name}")
# return the calculated area as a JSON string
data = {"area": area}
return json.dumps(data)
def calculate_area(length, width):
return length*widthThe test file is the tutorial's own. It uses unittest. A test case is the individual unit of testing, and it checks for a specific response to a particular set of inputs Source 41সোর্স 41. TestCase is the base class for new test cases Source 41সোর্স 41. assertEqual fails the test if the two values are not equal Source 41সোর্স 41. assertRaises passes the test if the exception is raised Source 41সোর্স 41. assertLogs tests that at least one message is logged Source 41সোর্স 41. subTest runs the enclosed code block as a subtest Source 41সোর্স 41. The class Context is a fake that stands in for the context object, and a fake is a mock that takes shortcuts to simplify or speed up testing Source 8সোর্স 8. Save the test file as test_handler.py:
import io
import json
import unittest
from contextlib import redirect_stdout
import lambda_function
class Context:
"""The tutorial's stand-in for the context object that Lambda passes in."""
log_group_name = "/aws/lambda/myLambdaFunction"
def call(event):
printed = io.StringIO()
with redirect_stdout(printed):
response = lambda_function.lambda_handler(event, Context())
return response, printed.getvalue()
class AreaHandler(unittest.TestCase):
def test_event_of_the_aws_tutorial(self):
response, printed = call({"length": 6, "width": 7})
self.assertEqual(response, '{"area": 42}')
self.assertEqual(printed, "The area is 42\n")
def test_log_line_names_the_log_group(self):
with self.assertLogs(level="INFO") as logs:
call({"length": 6, "width": 7})
self.assertEqual(logs.output, ["INFO:root:CloudWatch logs group: /aws/lambda/myLambdaFunction"])
def test_missing_width_raises_keyerror(self):
with self.assertRaises(KeyError):
call({"length": 6})
def test_what_the_code_does_with_odd_input(self):
# These cases record what the code does today. They are not a statement of what it should do.
cases = [
({"length": "ab", "width": 3}, '{"area": "ababab"}'),
({"length": -2, "width": 5}, '{"area": -10}'),
({"length": 2.5, "width": 4}, '{"area": 10.0}'),
({"length": True, "width": 7}, '{"area": 7}'),
]
for event, expected in cases:
with self.subTest(event=event):
response, _ = call(event)
self.assertEqual(response, expected)
if __name__ == "__main__":
unittest.main()Run it:
python3 -m unittest -v test_handlerOutput of the tutorial's run:
test_event_of_the_aws_tutorial (test_handler.AreaHandler.test_event_of_the_aws_tutorial) ... ok
test_log_line_names_the_log_group (test_handler.AreaHandler.test_log_line_names_the_log_group) ... ok
test_missing_width_raises_keyerror (test_handler.AreaHandler.test_missing_width_raises_keyerror) ... ok
test_what_the_code_does_with_odd_input (test_handler.AreaHandler.test_what_the_code_does_with_odd_input) ... ok
----------------------------------------------------------------------
Ran 4 tests in 0.009s
OK- The first test uses the event of the AWS tutorial, which has the keys
lengthandwidthSource 2সোর্স 2. The page shows the log lineThe area is 42for it Source 2সোর্স 2. The test checks the response string and the printed line. - The second test checks the log line. The function uses the
log_group_nameof the context to output the name of its CloudWatch log group Source 2সোর্স 2. The fake context holds the log group name that the page shows in its sample output Source 2সোর্স 2. The run shows only test results. The log line of the function is checked inside the test. - The third test shows that the function raises
KeyErrorwhen the event has nowidth. The function does not check the event. - The fourth test records what the code does today with input that nobody planned for. Text for the length gives the area
"ababab", a negative number gives a negative area, a decimal gives a decimal area, andTruegives the area 7. The tests pass because they assert today's behavior. They do not say that the behavior is right. AWS says that a handler should extract and validate data from the incoming event and context objects, and then pass the input to the methods that hold the business logic Source 8সোর্স 8. The example function of AWS does not validate, and the tutorial found this by running it.
This test ran the function as plain Python, outside Lambda. So it says nothing about the timeout, the memory setting, the execution role, or the permission for logs. AWS says that all Lambda function code has a dependency on timeout and memory settings, which could cause the function to fail if those settings are not set properly Source 8সোর্স 8.
2. Run the DynamoDB tutorial on DynamoDB local. DynamoDB local is available as a Docker image Source 21সোর্স 21, and the AWS page names the image amazon/dynamodb-local:latest Source 21সোর্স 21. This step needs Docker. The tutorial pulled the image with docker pull amazon/dynamodb-local:latest before the run, which is the tutorial's own way to get it.
The first block starts the container. The options --cap-drop ALL, --security-opt no-new-privileges, and --memory 1g are the tutorial's own choices, and so is the value of -p. The --publish or -p flag makes a port available outside the host Source 42সোর্স 42. The page of Docker shows the form -p 192.168.1.100:8080:80, which maps port 8080 on the Docker host IP 192.168.1.100 to TCP port 80 in the container Source 42সোর্স 42. The tutorial's value 127.0.0.1:18000:8000 follows that form, with the host IP 127.0.0.1, the host port 18000, and the container port 8000. If you include the localhost IP address (127.0.0.1, or ::1) with the publish flag, only the Docker host can access the published container port Source 42সোর্স 42. The option --rm automatically removes the container and its associated anonymous volumes when it exits Source 43সোর্স 43. With -inMemory, DynamoDB keeps no data after it stops Source 22সোর্স 22. With -disableTelemetry, DynamoDB local sends no telemetry Source 22সোর্স 22. The credentials are the made-up values that the AWS page shows Source 21সোর্স 21. AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE name the files for configuration profiles and access keys, and AWS_EC2_METADATA_DISABLED disables the use of the EC2 instance metadata service Source 40সোর্স 40. Setting them is the tutorial's own choice. The function ddb adds --endpoint-url to each command, because the AWS CLI needs it with each command Source 22সোর্স 22. The function j prints an answer on one line, which is the tutorial's own formatting.
# Start DynamoDB Local in a container, and publish its port 8000 as 127.0.0.1:18000 (the tutorial's own choice).
docker run -d --rm --name ddb-practice --cap-drop ALL --security-opt no-new-privileges --memory 1g \
-p 127.0.0.1:18000:8000 amazon/dynamodb-local:latest -jar DynamoDBLocal.jar -inMemory -disableTelemetry
# DynamoDB Local accepts any credentials. The first line holds the values that the AWS page shows.
export AWS_ACCESS_KEY_ID=fakeMyKeyId AWS_SECRET_ACCESS_KEY=fakeSecretAccessKey AWS_DEFAULT_REGION=fakeRegion
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
# The CLI cannot use DynamoDB Local as a default endpoint, so every command needs --endpoint-url. ddb adds it.
# j prints a JSON answer on one line.
ENDPOINT=http://127.0.0.1:18000
ddb() { aws dynamodb "$@" --endpoint-url "$ENDPOINT"; }
j() { python3 -c 'import json, sys; print(json.dumps(json.load(sys.stdin)))'; }
# Wait up to 30 seconds until DynamoDB Local answers, then list the tables.
for i in $(seq 30); do ddb list-tables > /dev/null 2>&1 && break; sleep 1; done
ddb list-tables | jThe second block holds the commands of the six steps of the AWS tutorial. The tutorial ran the Linux version of each command and put each on fewer lines. The AWS pages say: create-table creates the Music table Source 14সোর্স 14; put-item creates several new items Source 15সোর্স 15; get-item uses --consistent-read to demonstrate strongly consistent reads Source 16সোর্স 16; update-item updates an item Source 17সোর্স 17; query queries the table by the partition key Source 18সোর্স 18; and delete-table deletes the table Source 19সোর্স 19. The check of an item without the sort key is the tutorial's own. It follows from the rule that each item in the Music table must have both key attributes Source 10সোর্স 10.
echo "--- step 1: create the table"
ddb create-table \
--table-name Music \
--attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST \
--table-class STANDARD | grep TableStatus
echo "--- step 2: write data"
ddb put-item --table-name Music --item '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "1"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Howdy"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "2"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "PartiQL Rocks"}, "AlbumTitle": {"S": "Another Album Title"}, "Awards": {"N": "8"}}'
echo "--- step 3: read data"
ddb get-item --consistent-read --table-name Music --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' | j
echo "--- step 4: update data"
ddb update-item --table-name Music --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' --update-expression "SET AlbumTitle = :newval" --expression-attribute-values '{":newval":{"S":"Updated Album Title"}}' --return-values ALL_NEW | j
echo "--- step 5: query data"
ddb query --table-name Music --key-condition-expression "Artist = :name" --expression-attribute-values '{":name":{"S":"Acme Band"}}' | j
echo "--- the tutorial's own check: an item without the sort key"
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}}' 2>&1
echo "--- step 6: delete the table"
ddb delete-table --table-name Music | grep TableStatus
ddb list-tables | jThe third block stops the container with docker stop, which stops one or more running containers Source 44সোর্স 44, and then counts the containers that are named ddb-practice, in the tutorial's own way. The container was started with --rm, so the tutorial expected the count to be 0.
# Stop the container, which was started with --rm. The last line counts the containers named ddb-practice: 0 means that none is left.
docker stop ddb-practice
docker ps -a --filter name=ddb-practice --quiet | wc -lOutput of the tutorial's run:
41f0f5f30c18b931fe55cd4088cc03f6741de47fa0ab65a0bc57238b339ad765
{"TableNames": []}
--- step 1: create the table
"TableStatus": "ACTIVE",
--- step 2: write data
--- step 3: read data
{"Item": {"Artist": {"S": "Acme Band"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"}, "SongTitle": {"S": "Happy Day"}}}
--- step 4: update data
{"Attributes": {"Artist": {"S": "Acme Band"}, "Awards": {"N": "10"}, "AlbumTitle": {"S": "Updated Album Title"}, "SongTitle": {"S": "Happy Day"}}}
--- step 5: query data
{"Items": [{"Artist": {"S": "Acme Band"}, "Awards": {"N": "10"}, "AlbumTitle": {"S": "Updated Album Title"}, "SongTitle": {"S": "Happy Day"}}, {"Artist": {"S": "Acme Band"}, "AlbumTitle": {"S": "Another Album Title"}, "Awards": {"N": "8"}, "SongTitle": {"S": "PartiQL Rocks"}}], "Count": 2, "ScannedCount": 2, "ConsumedCapacity": null}
--- the tutorial's own check: an item without the sort key
aws: [ERROR]: An error occurred (ValidationException) when calling the PutItem operation: One of the required keys was not given a value
--- step 6: delete the table
"TableStatus": "ACTIVE",
{"TableNames": []}
ddb-practice
0- The table was
ACTIVEat once, and the answer ofdelete-tableshowsACTIVEtoo. The sample result ofcreate-tableon the AWS page showsCREATINGSource 14সোর্স 14, and the AWS page says that when DynamoDB finishes creating the table, the value of theTableStatusfield is set toACTIVESource 14সোর্স 14. The sample result ofdelete-tableon the AWS page showsDELETINGSource 19সোর্স 19. DynamoDB local says that table operations occur immediately, and the table state is always ACTIVE Source 22সোর্স 22. get-itemandqueryshowAwardswith the typeN, the type thatput-itemwrote. The sample result of step 3 on the AWS page showsAwardswith the typeSSource 16সোর্স 16, and the sample result of step 5 showsNSource 18সোর্স 18. The tutorial's run matches the sample of step 5 and differs from the sample of step 3. The comparison is the tutorial's own.querylistsHappy DaybeforePartiQL Rocks, the two items ofAcme Band. All items with the same partition key value are stored together, in sorted order by sort key value Source 10সোর্স 10.- The item without the sort key was refused with a
ValidationException. The message comes from DynamoDB local, and the tutorial did not compare it with the message of the web service. - After
delete-table,list-tablesshows no tables. The last line,0, shows that no container namedddb-practiceis left.
The run cannot show everything. DynamoDB local says that most reads appear to be strongly consistent Source 22সোর্স 22. So the run cannot show an eventually consistent read that returns old data. DynamoDB local ignores provisioned throughput settings Source 22সোর্স 22. So the run cannot show throttling. After the runs, the tutorial removed the image with docker rmi amazon/dynamodb-local:latest.
3. Model partition pruning for Athena. This step models one rule of the AWS page: if you query a partitioned table and specify the partition in the WHERE clause, Athena scans the data only from that partition Source 31সোর্স 31. The script is the tutorial's own. It writes three days of log lines into folders named in the Hive style, such as dt=2014-07-05, with 1,000, 2,000, and 3,000 lines. The lines have tab-separated fields, like the sample log data of the AWS tutorial Source 28সোর্স 28. Save it as partitions.py:
"""A model of one rule of the Athena page: with the partition in the WHERE clause, only that partition is read."""
from pathlib import Path
DAYS = ["2014-07-05", "2014-07-06", "2014-07-07"]
LINE = "{day}\t20:00:09\tDFW3\t4260\t10.0.0.15\tGET\teabcd12345678.cloudfront.net\t/test-image-{n}.jpeg\t200\t-\tMozilla/5.0\n"
root = Path("logs")
for i, day in enumerate(DAYS, start=1):
folder = root / f"dt={day}" # a Hive-style path: key=value
folder.mkdir(parents=True)
with open(folder / "part-0.tsv", "w", encoding="utf-8") as out:
for n in range(1000 * i): # 1000, 2000, and 3000 lines
out.write(LINE.format(day=day, n=n))
def run(label, folders):
rows = size = 0
for folder in folders:
for path in folder.glob("*.tsv"):
data = path.read_bytes()
size += len(data)
rows += data.count(b"\n")
print(f"{label:26} folders read: {len(folders)} rows: {rows:5} bytes read: {size}")
run("no filter on dt", sorted(root.glob("dt=*")))
run("WHERE dt = '2014-07-06'", [root / "dt=2014-07-06"])Run it:
python3 partitions.pyOutput of the tutorial's run:
no filter on dt folders read: 3 rows: 6000 bytes read: 674670
WHERE dt = '2014-07-06' folders read: 1 rows: 2000 bytes read: 224890The model does not read SQL. The two run calls pick the folders by hand, as the rule says that Athena does when the WHERE clause names the partition. With no filter, the model read 3 folders and 674670 bytes. With the filter on one day, it read 1 folder and 224890 bytes. The model does not measure what Athena reports as scanned data, and the tutorial did not measure that.
4. Model three rules of Step Functions. This script is the tutorial's own, and it is not the Step Functions service. It holds three rules of the AWS pages. StartAt and States are required Source 34সোর্স 34. The value of StartAt must exactly match the name of one of the state objects Source 34সোর্স 34. A Choice state goes to its Default if no rule is true, and the state machine throws an error if there is no Default Source 35সোর্স 35. The Hello World definition is the example of the state machine structure page Source 34সোর্স 34. The Choice state is the example of the TestState page, which sends the input {"number": 2} to the state Equals 2 Source 37সোর্স 37. Save it as asl_model.py:
"""A model of three rules of the Step Functions pages. It is not the Step Functions service."""
import json
HELLO = json.loads("""{
"Comment": "A Hello World example of the Amazon States Language using a Pass state",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Pass",
"Result": "Hello World!",
"End": true
}
}
}""")
CHOICE = json.loads('{"Type": "Choice", "Choices": [{"Variable": "$.number", "NumericEquals": 1, "Next": "Equals 1"}, '
'{"Variable": "$.number", "NumericEquals": 2, "Next": "Equals 2"}], "Default": "No Match"}')
def check(definition):
"""StartAt and States are required, and StartAt must exactly match the name of a state."""
problems = [f"{field} is required" for field in ("StartAt", "States") if field not in definition]
if not problems and definition["StartAt"] not in definition["States"]:
problems.append(f"StartAt {definition['StartAt']!r} does not exactly match the name of a state")
return problems or ["ok"]
def choose(state, data):
"""The next state of a Choice state. It handles only NumericEquals rules on a top-level name such as $.number."""
for rule in state["Choices"]:
name = rule["Variable"].removeprefix("$.")
if name in data and data[name] == rule["NumericEquals"]:
return rule["Next"]
if "Default" in state:
return state["Default"]
raise RuntimeError("no rule is true and there is no Default")
print("Hello World example:", check(HELLO))
print("StartAt in lower case:", check({**HELLO, "StartAt": "helloworld"}))
print("no States field:", check({"StartAt": "HelloWorld"}))
for number in (1, 2, 3):
print(f"Choice state, input number {number}:", choose(CHOICE, {"number": number}))
no_default = {key: value for key, value in CHOICE.items() if key != "Default"}
try:
choose(no_default, {"number": 3})
except RuntimeError as error:
print("Choice state without Default, input number 3:", error)Run it:
python3 asl_model.pyOutput of the tutorial's run:
Hello World example: ['ok']
StartAt in lower case: ["StartAt 'helloworld' does not exactly match the name of a state"]
no States field: ['States is required']
Choice state, input number 1: Equals 1
Choice state, input number 2: Equals 2
Choice state, input number 3: No Match
Choice state without Default, input number 3: no rule is true and there is no Default- The Hello World definition passes the check.
- A definition with a lower-case
StartAtis refused, because the value must match exactly. - A definition with no
Statesfield is refused, becauseStatesis required. - For the input 2, the Choice state goes to
Equals 2, as the page shows. The results for the inputs 1 and 3 are the tutorial's own reasoning from the rules. - Without a
Default, and with no true rule, the model raises an error. Step Functions throws an error in this case too, and the wording of the message is the tutorial's own.
The model reads only NumericEquals rules on a top-level name. It checks only three rules, so a definition that passes the model can still be refused by Step Functions.
5. Print the parameter templates of two commands. The command below first sets the same three environment variables as step 2. Choosing them is the tutorial's own choice. The --generate-cli-skeleton option generates and displays a parameter template that you can customize and use as input on a command Source 39সোর্স 39. The two commands are the tutorial's own choice, and so is the filter. The four spaces in it keep nested names out.
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
for command in "lambda update-function-configuration" "stepfunctions test-state"; do
echo "== aws $command"
aws $command --generate-cli-skeleton | grep -E '^ "'
doneOutput of the tutorial's run:
== aws lambda update-function-configuration
"FunctionName": "",
"Role": "",
"Handler": "",
"Description": "",
"Timeout": 0,
"MemorySize": 0,
"VpcConfig": {
"Environment": {
"Runtime": "nodejs",
"DeadLetterConfig": {
"KMSKeyArn": "",
"TracingConfig": {
"RevisionId": "",
"Layers": [
"FileSystemConfigs": [
"ImageConfig": {
"EphemeralStorage": {
"SnapStart": {
"LoggingConfig": {
"CapacityProviderConfig": {
"DurableConfig": {
"RuntimeConfig": {
"AcceleratorConfig": {
== aws stepfunctions test-state
"definition": "",
"roleArn": "",
"input": "",
"inspectionLevel": "INFO",
"revealSecrets": true,
"variables": "",
"stateName": "",
"mock": {
"context": "",
"stateConfiguration": {The tutorial did not check what the names in the templates mean against the API references. Some of them match an option or a name on the AWS pages, by name only. FunctionName and Timeout match --function-name and --timeout in the example of the timeout page Source 5সোর্স 5. definition, roleArn, input, and inspectionLevel match --definition, --role-arn, --input, and --inspection-level in the examples of the TestState page Source 37সোর্স 37. stateName matches the stateName parameter of the page Source 37সোর্স 37. revealSecrets matches the revealSecrets parameter Source 37সোর্স 37. mock matches the --mock option in the examples of the page Source 37সোর্স 37. context matches the context parameter of the page Source 37সোর্স 37. The template shows INFO for inspectionLevel, and INFO is also the level that Step Functions uses if you do not specify one Source 37সোর্স 37.
6. Read along: the console tutorials of AWS. These are AWS's own pages. The tutorial did not run them. The Lambda tutorial says that to get started with AWS, you need an AWS account Source 2সোর্স 2. The Athena tutorial says to sign up for an AWS account if you have not already done so Source 26সোর্স 26. Lambda has pay-per-use billing Source 1সোর্স 1, and AWS points to its pricing page for the prices Source 1সোর্স 1. The Athena tutorial uses live resources, so you are charged for the queries that you run Source 26সোর্স 26. You are not charged for the sample data that it uses, but if you upload your own data files to Amazon S3, charges do apply Source 26সোর্স 26. Standard workflows of Step Functions are priced by state transition Source 32সোর্স 32.
Lambda.
- Open the Event Functions page of the Lambda console, choose Create Event Function, and select Author from scratch Source 2সোর্স 2.
- For Runtime, choose either Node.js 24 or Python 3.14 Source 2সোর্স 2. Lambda also creates an execution role that grants basic permissions to write to CloudWatch Logs Source 2সোর্স 2.
- Paste the function of step 1 into the code editor, replacing the code that Lambda created, and choose Deploy Source 2সোর্স 2. Do not edit the name of the handler function. If you do, Lambda won't be able to run your code Source 2সোর্স 2.
- Create a test event named
myTestEventwith the JSON document that haslengthandwidth, and choose the run icon next to it Source 2সোর্স 2. - Clean up. Delete the function, then the log group that stores its logs, then the execution role Source 2সোর্স 2.
Athena.
- Create a bucket in Amazon S3, in the same Region, to hold your Athena query results. You configure this bucket as your query output location Source 26সোর্স 26.
- In the Athena console, enter the path to the bucket in the Location of query result box, with the prefix
s3://Source 27সোর্স 27. - Create a database named
mydatabasewith the CREATE DATABASE statement Source 27সোর্স 27. - Create the table from the sample CloudFront log data of AWS Source 28সোর্স 28. The page warns that its first CREATE TABLE statement has an important limitation, so read on before you run it Source 28সোর্স 28.
- Run a SQL query on the table and see the results in Athena Source 29সোর্স 29.
- The pages that the tutorial read have no clean-up step for Athena. The tutorial's own advice: delete the bucket for query results, the table, and the database when you are done.
Step Functions.
- Estimated duration is 20-30 minutes Source 38সোর্স 38. In the console, choose Run Hello World Source 38সোর্স 38.
- Choose the Code button to see the ASL code Source 38সোর্স 38.
- Name the state machine before you create it, because you cannot rename it afterwards Source 38সোর্স 38. Until then you have worked on a draft, and no resources have been created Source 38সোর্স 38.
- Create the state machine, with a new role for permissions Source 38সোর্স 38. Start an execution named
hello001with the input field empty Source 38সোর্স 38. - Clean up. Delete the IAM roles, and then delete the state machine with Actions and Delete Source 38সোর্স 38.
সহজ English
The tutorial ran steps 1 to 5 on 2026-11-19 at 13:04 (+06) on Linux 7.0.0-43-generic, with Python 3.14.4, aws-cli/2.41.0, Docker 29.10.0, and bash 5.3.9. Steps 1, 3, and 4 are Python only. Step 2 ran DynamoDB local from the Docker image amazon/dynamodb-local@sha256:6ada631ec7aa5fc83446855eb17233e3dad184fec47477e8140c6c569cfe0c86, which is DynamoDB local 3.3.2. The image takes about 780 MB on disk. The tutorial pulled it before the run, and it was not on the machine before. Steps 1 to 5 need no AWS account. In step 2, the tutorial passed --endpoint-url with every command, and it gave the AWS CLI made-up credentials. The tutorial did not watch the network. In the tutorial's run, no AWS_ variable was set before the steps. After the run, the AWS CLI had created the folder ~/.aws, which did not exist before, with one file in it, cli/cache/session.db. The tutorial removed both. No page that the tutorial read says why the file appears. A separate check ran on 2026-11-19 at 13:29 (+06), with the same AWS CLI and a new, empty HOME for each command: aws --version and the two --generate-cli-skeleton commands of step 5 created no file, and aws dynamodb list-tables --endpoint-url http://127.0.0.1:1, where nothing listens, created .aws/cli/cache/session.db. Step 5 reuses the AWS CLI that step 1 of AWS Compute and Storage installs. The output is from the tutorial's run. Step 6 is a read-along of AWS's own tutorials. The tutorial did not run it, because it needs an account and can cost money.
1. Test the example function of AWS Lambda. The function of this step is the Python function of the AWS tutorial "Create your first Lambda function" Source 2সোর্স 2. The tutorial copied it from the page, and only removed the spaces at the ends of lines. It takes a JSON object with two values, length and width, multiplies them, and returns the area as a JSON string Source 2সোর্স 2. Save it as lambda_function.py:
import json
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
# Get the length and width parameters from the event object. The
# runtime converts the event object to a Python dictionary
length = event['length']
width = event['width']
area = calculate_area(length, width)
print(f"The area is {area}")
logger.info(f"CloudWatch logs group: {context.log_group_name}")
# return the calculated area as a JSON string
data = {"area": area}
return json.dumps(data)
def calculate_area(length, width):
return length*widthThe test file is the tutorial's own. It uses unittest. A test case is the individual unit of testing, and it checks for a specific response to a particular set of inputs Source 41সোর্স 41. TestCase is the base class for new test cases Source 41সোর্স 41. assertEqual fails the test if the two values are not equal Source 41সোর্স 41. assertRaises passes the test if the exception is raised Source 41সোর্স 41. assertLogs tests that at least one message is logged Source 41সোর্স 41. subTest runs the enclosed code block as a subtest Source 41সোর্স 41. The class Context is a fake that stands in for the context object, and a fake is a mock that takes shortcuts to simplify or speed up testing Source 8সোর্স 8. Save the test file as test_handler.py:
import io
import json
import unittest
from contextlib import redirect_stdout
import lambda_function
class Context:
"""The tutorial's stand-in for the context object that Lambda passes in."""
log_group_name = "/aws/lambda/myLambdaFunction"
def call(event):
printed = io.StringIO()
with redirect_stdout(printed):
response = lambda_function.lambda_handler(event, Context())
return response, printed.getvalue()
class AreaHandler(unittest.TestCase):
def test_event_of_the_aws_tutorial(self):
response, printed = call({"length": 6, "width": 7})
self.assertEqual(response, '{"area": 42}')
self.assertEqual(printed, "The area is 42\n")
def test_log_line_names_the_log_group(self):
with self.assertLogs(level="INFO") as logs:
call({"length": 6, "width": 7})
self.assertEqual(logs.output, ["INFO:root:CloudWatch logs group: /aws/lambda/myLambdaFunction"])
def test_missing_width_raises_keyerror(self):
with self.assertRaises(KeyError):
call({"length": 6})
def test_what_the_code_does_with_odd_input(self):
# These cases record what the code does today. They are not a statement of what it should do.
cases = [
({"length": "ab", "width": 3}, '{"area": "ababab"}'),
({"length": -2, "width": 5}, '{"area": -10}'),
({"length": 2.5, "width": 4}, '{"area": 10.0}'),
({"length": True, "width": 7}, '{"area": 7}'),
]
for event, expected in cases:
with self.subTest(event=event):
response, _ = call(event)
self.assertEqual(response, expected)
if __name__ == "__main__":
unittest.main()Run it:
python3 -m unittest -v test_handlerOutput of the tutorial's run:
test_event_of_the_aws_tutorial (test_handler.AreaHandler.test_event_of_the_aws_tutorial) ... ok
test_log_line_names_the_log_group (test_handler.AreaHandler.test_log_line_names_the_log_group) ... ok
test_missing_width_raises_keyerror (test_handler.AreaHandler.test_missing_width_raises_keyerror) ... ok
test_what_the_code_does_with_odd_input (test_handler.AreaHandler.test_what_the_code_does_with_odd_input) ... ok
----------------------------------------------------------------------
Ran 4 tests in 0.009s
OK- The first test uses the event of the AWS tutorial, which has the keys
lengthandwidthSource 2সোর্স 2. The page shows the log lineThe area is 42for it Source 2সোর্স 2. The test checks the response string and the printed line. - The second test checks the log line. The function uses the
log_group_nameof the context to output the name of its CloudWatch log group Source 2সোর্স 2. The fake context holds the log group name that the page shows in its sample output Source 2সোর্স 2. The run shows only test results. The log line of the function is checked inside the test. - The third test shows that the function raises
KeyErrorwhen the event has nowidth. The function does not check the event. - The fourth test records what the code does today with input that nobody planned for. Text for the length gives the area
"ababab", a negative number gives a negative area, a decimal gives a decimal area, andTruegives the area 7. The tests pass because they assert today's behavior. They do not say that the behavior is right. AWS says that a handler should extract and validate data from the incoming event and context objects, and then pass the input to the methods that hold the business logic Source 8সোর্স 8. The example function of AWS does not validate, and the tutorial found this by running it.
This test ran the function as plain Python, outside Lambda. So it says nothing about the timeout, the memory setting, the execution role, or the permission for logs. AWS says that all Lambda function code has a dependency on timeout and memory settings, which could cause the function to fail if those settings are not set properly Source 8সোর্স 8.
2. Run the DynamoDB tutorial on DynamoDB local. DynamoDB local is available as a Docker image Source 21সোর্স 21, and the AWS page names the image amazon/dynamodb-local:latest Source 21সোর্স 21. This step needs Docker. The tutorial pulled the image with docker pull amazon/dynamodb-local:latest before the run, which is the tutorial's own way to get it.
The first block starts the container. The options --cap-drop ALL, --security-opt no-new-privileges, and --memory 1g are the tutorial's own choices, and so is the value of -p. The --publish or -p flag makes a port available outside the host Source 42সোর্স 42. The page of Docker shows the form -p 192.168.1.100:8080:80, which maps port 8080 on the Docker host IP 192.168.1.100 to TCP port 80 in the container Source 42সোর্স 42. The tutorial's value 127.0.0.1:18000:8000 follows that form, with the host IP 127.0.0.1, the host port 18000, and the container port 8000. If you include the localhost IP address (127.0.0.1, or ::1) with the publish flag, only the Docker host can access the published container port Source 42সোর্স 42. The option --rm automatically removes the container and its associated anonymous volumes when it exits Source 43সোর্স 43. With -inMemory, DynamoDB keeps no data after it stops Source 22সোর্স 22. With -disableTelemetry, DynamoDB local sends no telemetry Source 22সোর্স 22. The credentials are the made-up values that the AWS page shows Source 21সোর্স 21. AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE name the files for configuration profiles and access keys, and AWS_EC2_METADATA_DISABLED disables the use of the EC2 instance metadata service Source 40সোর্স 40. Setting them is the tutorial's own choice. The function ddb adds --endpoint-url to each command, because the AWS CLI needs it with each command Source 22সোর্স 22. The function j prints an answer on one line, which is the tutorial's own formatting.
# Start DynamoDB Local in a container, and publish its port 8000 as 127.0.0.1:18000 (the tutorial's own choice).
docker run -d --rm --name ddb-practice --cap-drop ALL --security-opt no-new-privileges --memory 1g \
-p 127.0.0.1:18000:8000 amazon/dynamodb-local:latest -jar DynamoDBLocal.jar -inMemory -disableTelemetry
# DynamoDB Local accepts any credentials. The first line holds the values that the AWS page shows.
export AWS_ACCESS_KEY_ID=fakeMyKeyId AWS_SECRET_ACCESS_KEY=fakeSecretAccessKey AWS_DEFAULT_REGION=fakeRegion
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
# The CLI cannot use DynamoDB Local as a default endpoint, so every command needs --endpoint-url. ddb adds it.
# j prints a JSON answer on one line.
ENDPOINT=http://127.0.0.1:18000
ddb() { aws dynamodb "$@" --endpoint-url "$ENDPOINT"; }
j() { python3 -c 'import json, sys; print(json.dumps(json.load(sys.stdin)))'; }
# Wait up to 30 seconds until DynamoDB Local answers, then list the tables.
for i in $(seq 30); do ddb list-tables > /dev/null 2>&1 && break; sleep 1; done
ddb list-tables | jThe second block holds the commands of the six steps of the AWS tutorial. The tutorial ran the Linux version of each command and put each on fewer lines. The AWS pages say: create-table creates the Music table Source 14সোর্স 14; put-item creates several new items Source 15সোর্স 15; get-item uses --consistent-read to demonstrate strongly consistent reads Source 16সোর্স 16; update-item updates an item Source 17সোর্স 17; query queries the table by the partition key Source 18সোর্স 18; and delete-table deletes the table Source 19সোর্স 19. The check of an item without the sort key is the tutorial's own. It follows from the rule that each item in the Music table must have both key attributes Source 10সোর্স 10.
echo "--- step 1: create the table"
ddb create-table \
--table-name Music \
--attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST \
--table-class STANDARD | grep TableStatus
echo "--- step 2: write data"
ddb put-item --table-name Music --item '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "1"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Howdy"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "2"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "PartiQL Rocks"}, "AlbumTitle": {"S": "Another Album Title"}, "Awards": {"N": "8"}}'
echo "--- step 3: read data"
ddb get-item --consistent-read --table-name Music --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' | j
echo "--- step 4: update data"
ddb update-item --table-name Music --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' --update-expression "SET AlbumTitle = :newval" --expression-attribute-values '{":newval":{"S":"Updated Album Title"}}' --return-values ALL_NEW | j
echo "--- step 5: query data"
ddb query --table-name Music --key-condition-expression "Artist = :name" --expression-attribute-values '{":name":{"S":"Acme Band"}}' | j
echo "--- the tutorial's own check: an item without the sort key"
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}}' 2>&1
echo "--- step 6: delete the table"
ddb delete-table --table-name Music | grep TableStatus
ddb list-tables | jThe third block stops the container with docker stop, which stops one or more running containers Source 44সোর্স 44, and then counts the containers that are named ddb-practice, in the tutorial's own way. The container was started with --rm, so the tutorial expected the count to be 0.
# Stop the container, which was started with --rm. The last line counts the containers named ddb-practice: 0 means that none is left.
docker stop ddb-practice
docker ps -a --filter name=ddb-practice --quiet | wc -lOutput of the tutorial's run:
41f0f5f30c18b931fe55cd4088cc03f6741de47fa0ab65a0bc57238b339ad765
{"TableNames": []}
--- step 1: create the table
"TableStatus": "ACTIVE",
--- step 2: write data
--- step 3: read data
{"Item": {"Artist": {"S": "Acme Band"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"}, "SongTitle": {"S": "Happy Day"}}}
--- step 4: update data
{"Attributes": {"Artist": {"S": "Acme Band"}, "Awards": {"N": "10"}, "AlbumTitle": {"S": "Updated Album Title"}, "SongTitle": {"S": "Happy Day"}}}
--- step 5: query data
{"Items": [{"Artist": {"S": "Acme Band"}, "Awards": {"N": "10"}, "AlbumTitle": {"S": "Updated Album Title"}, "SongTitle": {"S": "Happy Day"}}, {"Artist": {"S": "Acme Band"}, "AlbumTitle": {"S": "Another Album Title"}, "Awards": {"N": "8"}, "SongTitle": {"S": "PartiQL Rocks"}}], "Count": 2, "ScannedCount": 2, "ConsumedCapacity": null}
--- the tutorial's own check: an item without the sort key
aws: [ERROR]: An error occurred (ValidationException) when calling the PutItem operation: One of the required keys was not given a value
--- step 6: delete the table
"TableStatus": "ACTIVE",
{"TableNames": []}
ddb-practice
0- The table was
ACTIVEat once, and the answer ofdelete-tableshowsACTIVEtoo. The sample result ofcreate-tableon the AWS page showsCREATINGSource 14সোর্স 14, and the AWS page says that when DynamoDB finishes creating the table, the value of theTableStatusfield is set toACTIVESource 14সোর্স 14. The sample result ofdelete-tableon the AWS page showsDELETINGSource 19সোর্স 19. DynamoDB local says that table operations occur immediately, and the table state is always ACTIVE Source 22সোর্স 22. get-itemandqueryshowAwardswith the typeN, the type thatput-itemwrote. The sample result of step 3 on the AWS page showsAwardswith the typeSSource 16সোর্স 16, and the sample result of step 5 showsNSource 18সোর্স 18. The tutorial's run matches the sample of step 5 and differs from the sample of step 3. The comparison is the tutorial's own.querylistsHappy DaybeforePartiQL Rocks, the two items ofAcme Band. All items with the same partition key value are stored together, in sorted order by sort key value Source 10সোর্স 10.- The item without the sort key was refused with a
ValidationException. The message comes from DynamoDB local, and the tutorial did not compare it with the message of the web service. - After
delete-table,list-tablesshows no tables. The last line,0, shows that no container namedddb-practiceis left.
The run cannot show everything. DynamoDB local says that most reads appear to be strongly consistent Source 22সোর্স 22. So the run cannot show an eventually consistent read that returns old data. DynamoDB local ignores provisioned throughput settings Source 22সোর্স 22. So the run cannot show throttling. After the runs, the tutorial removed the image with docker rmi amazon/dynamodb-local:latest.
3. Model partition pruning for Athena. This step models one rule of the AWS page: if you query a partitioned table and specify the partition in the WHERE clause, Athena scans the data only from that partition Source 31সোর্স 31. The script is the tutorial's own. It writes three days of log lines into folders named in the Hive style, such as dt=2014-07-05, with 1,000, 2,000, and 3,000 lines. The lines have tab-separated fields, like the sample log data of the AWS tutorial Source 28সোর্স 28. Save it as partitions.py:
"""A model of one rule of the Athena page: with the partition in the WHERE clause, only that partition is read."""
from pathlib import Path
DAYS = ["2014-07-05", "2014-07-06", "2014-07-07"]
LINE = "{day}\t20:00:09\tDFW3\t4260\t10.0.0.15\tGET\teabcd12345678.cloudfront.net\t/test-image-{n}.jpeg\t200\t-\tMozilla/5.0\n"
root = Path("logs")
for i, day in enumerate(DAYS, start=1):
folder = root / f"dt={day}" # a Hive-style path: key=value
folder.mkdir(parents=True)
with open(folder / "part-0.tsv", "w", encoding="utf-8") as out:
for n in range(1000 * i): # 1000, 2000, and 3000 lines
out.write(LINE.format(day=day, n=n))
def run(label, folders):
rows = size = 0
for folder in folders:
for path in folder.glob("*.tsv"):
data = path.read_bytes()
size += len(data)
rows += data.count(b"\n")
print(f"{label:26} folders read: {len(folders)} rows: {rows:5} bytes read: {size}")
run("no filter on dt", sorted(root.glob("dt=*")))
run("WHERE dt = '2014-07-06'", [root / "dt=2014-07-06"])Run it:
python3 partitions.pyOutput of the tutorial's run:
no filter on dt folders read: 3 rows: 6000 bytes read: 674670
WHERE dt = '2014-07-06' folders read: 1 rows: 2000 bytes read: 224890The model does not read SQL. The two run calls pick the folders by hand, as the rule says that Athena does when the WHERE clause names the partition. With no filter, the model read 3 folders and 674670 bytes. With the filter on one day, it read 1 folder and 224890 bytes. The model does not measure what Athena reports as scanned data, and the tutorial did not measure that.
4. Model three rules of Step Functions. This script is the tutorial's own, and it is not the Step Functions service. It holds three rules of the AWS pages. StartAt and States are required Source 34সোর্স 34. The value of StartAt must exactly match the name of one of the state objects Source 34সোর্স 34. A Choice state goes to its Default if no rule is true, and the state machine throws an error if there is no Default Source 35সোর্স 35. The Hello World definition is the example of the state machine structure page Source 34সোর্স 34. The Choice state is the example of the TestState page, which sends the input {"number": 2} to the state Equals 2 Source 37সোর্স 37. Save it as asl_model.py:
"""A model of three rules of the Step Functions pages. It is not the Step Functions service."""
import json
HELLO = json.loads("""{
"Comment": "A Hello World example of the Amazon States Language using a Pass state",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Pass",
"Result": "Hello World!",
"End": true
}
}
}""")
CHOICE = json.loads('{"Type": "Choice", "Choices": [{"Variable": "$.number", "NumericEquals": 1, "Next": "Equals 1"}, '
'{"Variable": "$.number", "NumericEquals": 2, "Next": "Equals 2"}], "Default": "No Match"}')
def check(definition):
"""StartAt and States are required, and StartAt must exactly match the name of a state."""
problems = [f"{field} is required" for field in ("StartAt", "States") if field not in definition]
if not problems and definition["StartAt"] not in definition["States"]:
problems.append(f"StartAt {definition['StartAt']!r} does not exactly match the name of a state")
return problems or ["ok"]
def choose(state, data):
"""The next state of a Choice state. It handles only NumericEquals rules on a top-level name such as $.number."""
for rule in state["Choices"]:
name = rule["Variable"].removeprefix("$.")
if name in data and data[name] == rule["NumericEquals"]:
return rule["Next"]
if "Default" in state:
return state["Default"]
raise RuntimeError("no rule is true and there is no Default")
print("Hello World example:", check(HELLO))
print("StartAt in lower case:", check({**HELLO, "StartAt": "helloworld"}))
print("no States field:", check({"StartAt": "HelloWorld"}))
for number in (1, 2, 3):
print(f"Choice state, input number {number}:", choose(CHOICE, {"number": number}))
no_default = {key: value for key, value in CHOICE.items() if key != "Default"}
try:
choose(no_default, {"number": 3})
except RuntimeError as error:
print("Choice state without Default, input number 3:", error)Run it:
python3 asl_model.pyOutput of the tutorial's run:
Hello World example: ['ok']
StartAt in lower case: ["StartAt 'helloworld' does not exactly match the name of a state"]
no States field: ['States is required']
Choice state, input number 1: Equals 1
Choice state, input number 2: Equals 2
Choice state, input number 3: No Match
Choice state without Default, input number 3: no rule is true and there is no Default- The Hello World definition passes the check.
- A definition with a lower-case
StartAtis refused, because the value must match exactly. - A definition with no
Statesfield is refused, becauseStatesis required. - For the input 2, the Choice state goes to
Equals 2, as the page shows. The results for the inputs 1 and 3 are the tutorial's own reasoning from the rules. - Without a
Default, and with no true rule, the model raises an error. Step Functions throws an error in this case too, and the wording of the message is the tutorial's own.
The model reads only NumericEquals rules on a top-level name. It checks only three rules, so a definition that passes the model can still be refused by Step Functions.
5. Print the parameter templates of two commands. The command below first sets the same three environment variables as step 2. Choosing them is the tutorial's own choice. The --generate-cli-skeleton option generates and displays a parameter template that you can customize and use as input on a command Source 39সোর্স 39. The two commands are the tutorial's own choice, and so is the filter. The four spaces in it keep nested names out.
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
for command in "lambda update-function-configuration" "stepfunctions test-state"; do
echo "== aws $command"
aws $command --generate-cli-skeleton | grep -E '^ "'
doneOutput of the tutorial's run:
== aws lambda update-function-configuration
"FunctionName": "",
"Role": "",
"Handler": "",
"Description": "",
"Timeout": 0,
"MemorySize": 0,
"VpcConfig": {
"Environment": {
"Runtime": "nodejs",
"DeadLetterConfig": {
"KMSKeyArn": "",
"TracingConfig": {
"RevisionId": "",
"Layers": [
"FileSystemConfigs": [
"ImageConfig": {
"EphemeralStorage": {
"SnapStart": {
"LoggingConfig": {
"CapacityProviderConfig": {
"DurableConfig": {
"RuntimeConfig": {
"AcceleratorConfig": {
== aws stepfunctions test-state
"definition": "",
"roleArn": "",
"input": "",
"inspectionLevel": "INFO",
"revealSecrets": true,
"variables": "",
"stateName": "",
"mock": {
"context": "",
"stateConfiguration": {The tutorial did not check what the names in the templates mean against the API references. Some of them match an option or a name on the AWS pages, by name only. FunctionName and Timeout match --function-name and --timeout in the example of the timeout page Source 5সোর্স 5. definition, roleArn, input, and inspectionLevel match --definition, --role-arn, --input, and --inspection-level in the examples of the TestState page Source 37সোর্স 37. stateName matches the stateName parameter of the page Source 37সোর্স 37. revealSecrets matches the revealSecrets parameter Source 37সোর্স 37. mock matches the --mock option in the examples of the page Source 37সোর্স 37. context matches the context parameter of the page Source 37সোর্স 37. The template shows INFO for inspectionLevel, and INFO is also the level that Step Functions uses if you do not specify one Source 37সোর্স 37.
6. Read along: the console tutorials of AWS. These are AWS's own pages. The tutorial did not run them. The Lambda tutorial says that to get started with AWS, you need an AWS account Source 2সোর্স 2. The Athena tutorial says to sign up for an AWS account if you have not already done so Source 26সোর্স 26. Lambda has pay-per-use billing Source 1সোর্স 1, and AWS points to its pricing page for the prices Source 1সোর্স 1. The Athena tutorial uses live resources, so you are charged for the queries that you run Source 26সোর্স 26. You are not charged for the sample data that it uses, but if you upload your own data files to Amazon S3, charges do apply Source 26সোর্স 26. Standard workflows of Step Functions are priced by state transition Source 32সোর্স 32.
Lambda.
- Open the Event Functions page of the Lambda console, choose Create Event Function, and select Author from scratch Source 2সোর্স 2.
- For Runtime, choose either Node.js 24 or Python 3.14 Source 2সোর্স 2. Lambda also creates an execution role that grants basic permissions to write to CloudWatch Logs Source 2সোর্স 2.
- Paste the function of step 1 into the code editor, replacing the code that Lambda created, and choose Deploy Source 2সোর্স 2. Do not edit the name of the handler function. If you do, Lambda won't be able to run your code Source 2সোর্স 2.
- Create a test event named
myTestEventwith the JSON document that haslengthandwidth, and choose the run icon next to it Source 2সোর্স 2. - Clean up. Delete the function, then the log group that stores its logs, then the execution role Source 2সোর্স 2.
Athena.
- Create a bucket in Amazon S3, in the same Region, to hold your Athena query results. You configure this bucket as your query output location Source 26সোর্স 26.
- In the Athena console, enter the path to the bucket in the Location of query result box, with the prefix
s3://Source 27সোর্স 27. - Create a database named
mydatabasewith the CREATE DATABASE statement Source 27সোর্স 27. - Create the table from the sample CloudFront log data of AWS Source 28সোর্স 28. The page warns that its first CREATE TABLE statement has an important limitation, so read on before you run it Source 28সোর্স 28.
- Run a SQL query on the table and see the results in Athena Source 29সোর্স 29.
- The pages that the tutorial read have no clean-up step for Athena. The tutorial's own advice: delete the bucket for query results, the table, and the database when you are done.
Step Functions.
- Estimated duration is 20-30 minutes Source 38সোর্স 38. In the console, choose Run Hello World Source 38সোর্স 38.
- Choose the Code button to see the ASL code Source 38সোর্স 38.
- Name the state machine before you create it, because you cannot rename it afterwards Source 38সোর্স 38. Until then you have worked on a draft, and no resources have been created Source 38সোর্স 38.
- Create the state machine, with a new role for permissions Source 38সোর্স 38. Start an execution named
hello001with the input field empty Source 38সোর্স 38. - Clean up. Delete the IAM roles, and then delete the state machine with Actions and Delete Source 38সোর্স 38.
বাংলা ব্যাখ্যা
টিউটোরিয়াল ১ থেকে ৫ নম্বর ধাপ চালিয়েছে 2026-11-19 তারিখে 13:04-এ (+06), Linux 7.0.0-43-generic-এ, Python 3.14.4, aws-cli/2.41.0, Docker 29.10.0 আর bash 5.3.9 দিয়ে। ১, ৩ আর ৪ নম্বর ধাপ শুধু Python। ২ নম্বর ধাপে DynamoDB local চলেছে Docker image amazon/dynamodb-local@sha256:6ada631ec7aa5fc83446855eb17233e3dad184fec47477e8140c6c569cfe0c86 থেকে, যা DynamoDB local 3.3.2। image-টা disk-এ প্রায় ৭৮০ MB নেয়। টিউটোরিয়াল সেটা run-এর আগে pull করেছে, আর আগে সেটা মেশিনে ছিল না। ১ থেকে ৫ নম্বর ধাপে কোনো AWS account লাগে না। ২ নম্বর ধাপে টিউটোরিয়াল প্রতিটা command-এ --endpoint-url দিয়েছে, আর AWS CLI-কে বানানো credential দিয়েছে। টিউটোরিয়াল network নজর করেনি। টিউটোরিয়ালের run-এ ধাপগুলোর আগে কোনো AWS_ variable সেট ছিল না। run-এর পর দেখা গেছে, AWS CLI ~/.aws folder বানিয়েছে, যা আগে ছিল না, আর তাতে ছিল একটা file, cli/cache/session.db। টিউটোরিয়াল দুটোই সরিয়ে দিয়েছে। টিউটোরিয়ালে যে page-গুলো পড়া হয়েছে, তার কোনোটাই বলে না file-টা কেন দেখা দেয়। 2026-11-19 তারিখে 13:29-এ (+06) একটা আলাদা পরীক্ষা চলেছে, একই AWS CLI দিয়ে, প্রতিটা command-এর জন্য একটা নতুন, খালি HOME দিয়ে: aws --version আর ৫ নম্বর ধাপের দুটো --generate-cli-skeleton command কোনো file বানায়নি, আর aws dynamodb list-tables --endpoint-url http://127.0.0.1:1, যেখানে কিছুই শোনে না, .aws/cli/cache/session.db বানিয়েছে। ৫ নম্বর ধাপ সেই AWS CLI আবার ব্যবহার করে, যা AWS Compute and Storage-এর ১ নম্বর ধাপে install হয়। output টিউটোরিয়ালের run থেকে নেওয়া। ৬ নম্বর ধাপ AWS-এর নিজের tutorial পাশাপাশি পড়ে যাওয়া। টিউটোরিয়াল সেটা চালায়নি, কারণ তার জন্য account লাগে আর খরচ হতে পারে।
১. AWS Lambda-র উদাহরণ function test করুন। এই ধাপের function হলো AWS-এর tutorial "Create your first Lambda function"-এর Python function Source 2সোর্স 2। টিউটোরিয়াল সেটা page থেকে কপি করেছে, শুধু লাইনের শেষের space সরিয়েছে। এটা length আর width নামে দুটো মান সহ একটা JSON object নেয়, দুটো গুণ করে, আর area-টা JSON string হিসেবে ফেরত দেয় Source 2সোর্স 2। এটা lambda_function.py নামে save করুন:
import json
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
# Get the length and width parameters from the event object. The
# runtime converts the event object to a Python dictionary
length = event['length']
width = event['width']
area = calculate_area(length, width)
print(f"The area is {area}")
logger.info(f"CloudWatch logs group: {context.log_group_name}")
# return the calculated area as a JSON string
data = {"area": area}
return json.dumps(data)
def calculate_area(length, width):
return length*widthtest file টিউটোরিয়ালের নিজের। এটা unittest ব্যবহার করে। একটা test case হলো test-এর একটা এককে, আর সেটা নির্দিষ্ট কিছু input-এর জন্য একটা নির্দিষ্ট response যাচাই করে Source 41সোর্স 41। TestCase হলো নতুন test case বানানোর base class Source 41সোর্স 41। দুটো মান সমান না হলে assertEqual test ব্যর্থ করে Source 41সোর্স 41। exception ছোড়া হলে assertRaises test পাস করায় Source 41সোর্স 41। assertLogs যাচাই করে অন্তত একটা message log হয়েছে Source 41সোর্স 41। subTest ভেতরের code block-কে একটা subtest হিসেবে চালায় Source 41সোর্স 41। Context class হলো context object-এর জায়গায় বসানো একটা fake, আর fake হলো এমন একটা mock, যা test সহজ বা দ্রুত করতে শর্টকাট নেয় Source 8সোর্স 8। test file-টা test_handler.py নামে save করুন:
import io
import json
import unittest
from contextlib import redirect_stdout
import lambda_function
class Context:
"""The tutorial's stand-in for the context object that Lambda passes in."""
log_group_name = "/aws/lambda/myLambdaFunction"
def call(event):
printed = io.StringIO()
with redirect_stdout(printed):
response = lambda_function.lambda_handler(event, Context())
return response, printed.getvalue()
class AreaHandler(unittest.TestCase):
def test_event_of_the_aws_tutorial(self):
response, printed = call({"length": 6, "width": 7})
self.assertEqual(response, '{"area": 42}')
self.assertEqual(printed, "The area is 42\n")
def test_log_line_names_the_log_group(self):
with self.assertLogs(level="INFO") as logs:
call({"length": 6, "width": 7})
self.assertEqual(logs.output, ["INFO:root:CloudWatch logs group: /aws/lambda/myLambdaFunction"])
def test_missing_width_raises_keyerror(self):
with self.assertRaises(KeyError):
call({"length": 6})
def test_what_the_code_does_with_odd_input(self):
# These cases record what the code does today. They are not a statement of what it should do.
cases = [
({"length": "ab", "width": 3}, '{"area": "ababab"}'),
({"length": -2, "width": 5}, '{"area": -10}'),
({"length": 2.5, "width": 4}, '{"area": 10.0}'),
({"length": True, "width": 7}, '{"area": 7}'),
]
for event, expected in cases:
with self.subTest(event=event):
response, _ = call(event)
self.assertEqual(response, expected)
if __name__ == "__main__":
unittest.main()চালান:
python3 -m unittest -v test_handlerটিউটোরিয়ালের run-এর output:
test_event_of_the_aws_tutorial (test_handler.AreaHandler.test_event_of_the_aws_tutorial) ... ok
test_log_line_names_the_log_group (test_handler.AreaHandler.test_log_line_names_the_log_group) ... ok
test_missing_width_raises_keyerror (test_handler.AreaHandler.test_missing_width_raises_keyerror) ... ok
test_what_the_code_does_with_odd_input (test_handler.AreaHandler.test_what_the_code_does_with_odd_input) ... ok
----------------------------------------------------------------------
Ran 4 tests in 0.009s
OK- প্রথম test AWS-এর tutorial-এর event ব্যবহার করে, যাতে
lengthআরwidthkey আছে Source 2সোর্স 2। page তার জন্যThe area is 42log লাইনটা দেখায় Source 2সোর্স 2। test response string আর ছাপা লাইন যাচাই করে। - দ্বিতীয় test log লাইন যাচাই করে। function context-এর
log_group_nameদিয়ে তার CloudWatch log group-এর নাম output করে Source 2সোর্স 2। fake context-এ আছে সেই log group-এর নাম, যা page তার নমুনা output-এ দেখায় Source 2সোর্স 2। run শুধু test-এর ফল দেখায়। function-এর log লাইন test-এর ভেতরেই যাচাই হয়। - তৃতীয় test দেখায়, event-এ
widthনা থাকলে functionKeyErrorছোড়ে। function event যাচাই করে না। - চতুর্থ test দেখায়, যে input কেউ ভাবেনি তাতে code আজ কী করে। length-এর জায়গায় text দিলে area হয়
"ababab", negative সংখ্যা দিলে area negative হয়, দশমিক সংখ্যা দিলে area দশমিক হয়, আরTrueদিলে area হয় ৭। test পাস করে কারণ সেগুলো আজকের আচরণই assert করে। সেগুলো বলে না যে আচরণটা সঠিক। AWS বলে, একটা handler-এর উচিত আসা event আর context object থেকে data বের করে যাচাই করা, আর তারপর business logic রাখা method-গুলোতে input পাঠানো Source 8সোর্স 8। AWS-এর উদাহরণ function যাচাই করে না, আর টিউটোরিয়াল এটা চালিয়ে দেখে জেনেছে।
এই test function-টাকে Lambda-র বাইরে সাধারণ Python হিসেবে চালিয়েছে। তাই timeout, memory setting, execution role বা log-এর permission নিয়ে এটা কিছু বলে না। AWS বলে, সব Lambda function code timeout আর memory setting-এর ওপর নির্ভর করে, আর সেই setting ঠিকমতো না দিলে function ব্যর্থ হতে পারে Source 8সোর্স 8।
২. DynamoDB local-এ DynamoDB-র tutorial চালান। DynamoDB local Docker image হিসেবে পাওয়া যায় Source 21সোর্স 21, আর AWS-এর page image-টার নাম দেয় amazon/dynamodb-local:latest Source 21সোর্স 21। এই ধাপে Docker লাগে। টিউটোরিয়াল run-এর আগে docker pull amazon/dynamodb-local:latest দিয়ে image pull করেছে, যা image পাওয়ার টিউটোরিয়ালের নিজের উপায়।
প্রথম block container চালু করে। --cap-drop ALL, --security-opt no-new-privileges আর --memory 1g option টিউটোরিয়ালের নিজের পছন্দ, -p-এর মানও তাই। --publish বা -p flag একটা port-কে host-এর বাইরে পাওয়া যাওয়ার মতো করে দেয় Source 42সোর্স 42। Docker-এর page -p 192.168.1.100:8080:80 রূপটা দেখায়, যা Docker host IP 192.168.1.100-এর ৮০৮০ নম্বর port-কে container-এর TCP ৮০ নম্বর port-এর সঙ্গে জুড়ে দেয় Source 42সোর্স 42। টিউটোরিয়ালের মান 127.0.0.1:18000:8000 সেই রূপ মেনে চলে: host IP 127.0.0.1, host port ১৮০০০, আর container port ৮০০০। publish flag-এর সঙ্গে localhost IP address (127.0.0.1, বা ::1) দিলে শুধু Docker host publish করা container port-এ ঢুকতে পারে Source 42সোর্স 42। --rm option container বন্ধ হয়ে যাওয়ার (exit) সময় container আর তার সঙ্গে জড়িত anonymous volume আপনা থেকে মুছে দেয় Source 43সোর্স 43। -inMemory দিলে DynamoDB বন্ধ হওয়ার পর কোনো data রাখে না Source 22সোর্স 22। -disableTelemetry দিলে DynamoDB local কোনো telemetry পাঠায় না Source 22সোর্স 22। credential হলো AWS-এর page-এ দেখানো বানানো মান Source 21সোর্স 21। AWS_CONFIG_FILE আর AWS_SHARED_CREDENTIALS_FILE configuration profile আর access key রাখার file-এর নাম দেয়, আর AWS_EC2_METADATA_DISABLED EC2 instance metadata service-এর ব্যবহার বন্ধ করে Source 40সোর্স 40। এগুলো সেট করা টিউটোরিয়ালের নিজের পছন্দ। ddb function প্রতিটা command-এ --endpoint-url যোগ করে, কারণ AWS CLI-র প্রতিটা command-এ সেটা লাগে Source 22সোর্স 22। j function একটা উত্তর এক লাইনে ছাপে, যা টিউটোরিয়ালের নিজের formatting।
# Start DynamoDB Local in a container, and publish its port 8000 as 127.0.0.1:18000 (the tutorial's own choice).
docker run -d --rm --name ddb-practice --cap-drop ALL --security-opt no-new-privileges --memory 1g \
-p 127.0.0.1:18000:8000 amazon/dynamodb-local:latest -jar DynamoDBLocal.jar -inMemory -disableTelemetry
# DynamoDB Local accepts any credentials. The first line holds the values that the AWS page shows.
export AWS_ACCESS_KEY_ID=fakeMyKeyId AWS_SECRET_ACCESS_KEY=fakeSecretAccessKey AWS_DEFAULT_REGION=fakeRegion
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
# The CLI cannot use DynamoDB Local as a default endpoint, so every command needs --endpoint-url. ddb adds it.
# j prints a JSON answer on one line.
ENDPOINT=http://127.0.0.1:18000
ddb() { aws dynamodb "$@" --endpoint-url "$ENDPOINT"; }
j() { python3 -c 'import json, sys; print(json.dumps(json.load(sys.stdin)))'; }
# Wait up to 30 seconds until DynamoDB Local answers, then list the tables.
for i in $(seq 30); do ddb list-tables > /dev/null 2>&1 && break; sleep 1; done
ddb list-tables | jদ্বিতীয় block-এ আছে AWS-এর tutorial-এর ছয় ধাপের command। টিউটোরিয়াল প্রতিটা command-এর Linux version চালিয়েছে আর কম লাইনে রেখেছে। AWS-এর page-গুলো বলে: create-table Music table বানায় Source 14সোর্স 14; put-item কয়েকটা নতুন item বানায় Source 15সোর্স 15; get-item strongly consistent read দেখাতে --consistent-read ব্যবহার করে Source 16সোর্স 16; update-item একটা item হালনাগাদ করে Source 17সোর্স 17; query partition key দিয়ে table query করে Source 18সোর্স 18; আর delete-table table মুছে ফেলে Source 19সোর্স 19। sort key ছাড়া একটা item-এর যাচাই টিউটোরিয়ালের নিজের। এটা এই নিয়ম থেকে আসে যে Music table-এর প্রতিটা item-এ দুটো key attribute-ই থাকতে হয় Source 10সোর্স 10।
echo "--- step 1: create the table"
ddb create-table \
--table-name Music \
--attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST \
--table-class STANDARD | grep TableStatus
echo "--- step 2: write data"
ddb put-item --table-name Music --item '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "1"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Howdy"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "2"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"}}'
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}, "SongTitle": {"S": "PartiQL Rocks"}, "AlbumTitle": {"S": "Another Album Title"}, "Awards": {"N": "8"}}'
echo "--- step 3: read data"
ddb get-item --consistent-read --table-name Music --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' | j
echo "--- step 4: update data"
ddb update-item --table-name Music --key '{ "Artist": {"S": "Acme Band"}, "SongTitle": {"S": "Happy Day"}}' --update-expression "SET AlbumTitle = :newval" --expression-attribute-values '{":newval":{"S":"Updated Album Title"}}' --return-values ALL_NEW | j
echo "--- step 5: query data"
ddb query --table-name Music --key-condition-expression "Artist = :name" --expression-attribute-values '{":name":{"S":"Acme Band"}}' | j
echo "--- the tutorial's own check: an item without the sort key"
ddb put-item --table-name Music --item '{"Artist": {"S": "Acme Band"}}' 2>&1
echo "--- step 6: delete the table"
ddb delete-table --table-name Music | grep TableStatus
ddb list-tables | jতৃতীয় block docker stop দিয়ে container বন্ধ করে, যা এক বা একাধিক চলমান container বন্ধ করে Source 44সোর্স 44, তারপর টিউটোরিয়ালের নিজের উপায়ে ddb-practice নামের container গুনে দেখায়। container-টা --rm দিয়ে চালু হয়েছিল, তাই টিউটোরিয়াল আশা করেছিল গোনা সংখ্যা হবে ০।
# Stop the container, which was started with --rm. The last line counts the containers named ddb-practice: 0 means that none is left.
docker stop ddb-practice
docker ps -a --filter name=ddb-practice --quiet | wc -lটিউটোরিয়ালের run-এর output:
41f0f5f30c18b931fe55cd4088cc03f6741de47fa0ab65a0bc57238b339ad765
{"TableNames": []}
--- step 1: create the table
"TableStatus": "ACTIVE",
--- step 2: write data
--- step 3: read data
{"Item": {"Artist": {"S": "Acme Band"}, "AlbumTitle": {"S": "Songs About Life"}, "Awards": {"N": "10"}, "SongTitle": {"S": "Happy Day"}}}
--- step 4: update data
{"Attributes": {"Artist": {"S": "Acme Band"}, "Awards": {"N": "10"}, "AlbumTitle": {"S": "Updated Album Title"}, "SongTitle": {"S": "Happy Day"}}}
--- step 5: query data
{"Items": [{"Artist": {"S": "Acme Band"}, "Awards": {"N": "10"}, "AlbumTitle": {"S": "Updated Album Title"}, "SongTitle": {"S": "Happy Day"}}, {"Artist": {"S": "Acme Band"}, "AlbumTitle": {"S": "Another Album Title"}, "Awards": {"N": "8"}, "SongTitle": {"S": "PartiQL Rocks"}}], "Count": 2, "ScannedCount": 2, "ConsumedCapacity": null}
--- the tutorial's own check: an item without the sort key
aws: [ERROR]: An error occurred (ValidationException) when calling the PutItem operation: One of the required keys was not given a value
--- step 6: delete the table
"TableStatus": "ACTIVE",
{"TableNames": []}
ddb-practice
0- table সঙ্গে সঙ্গে
ACTIVEছিল, আরdelete-table-এর উত্তরেওACTIVEদেখা গেছে। AWS-এর page-এcreate-table-এর নমুনা ফলCREATINGদেখায় Source 14সোর্স 14, আর AWS-এর page বলে, DynamoDB table তৈরি শেষ করলেTableStatusfield-এর মানACTIVEকরা হয় Source 14সোর্স 14।delete-table-এর নমুনা ফল AWS-এর page-এDELETINGদেখায় Source 19সোর্স 19। DynamoDB local বলে, table-এর operation সঙ্গে সঙ্গে ঘটে, আর table state সবসময় ACTIVE Source 22সোর্স 22। get-itemআরqueryAwards-কেNtype-এ দেখায়, যে typeput-itemলিখেছিল। AWS-এর page-এর ৩ নম্বর ধাপের নমুনা ফলAwards-কেStype-এ দেখায় Source 16সোর্স 16, আর ৫ নম্বর ধাপের নমুনাNদেখায় Source 18সোর্স 18। টিউটোরিয়ালের run ৫ নম্বর ধাপের নমুনার সঙ্গে মেলে, আর ৩ নম্বর ধাপের নমুনা থেকে আলাদা। তুলনাটা টিউটোরিয়ালের নিজের।queryAcme Band-এর দুটো item-এর মধ্যেHappy Day-কেPartiQL Rocks-এর আগে দেখায়। একই partition key-র মান আছে এমন সব item একসঙ্গে রাখা হয়, sort key-র মান অনুযায়ী সাজানো অবস্থায় Source 10সোর্স 10।- sort key ছাড়া item-টা
ValidationExceptionদিয়ে প্রত্যাখ্যাত হয়েছে। message এসেছে DynamoDB local থেকে, আর টিউটোরিয়াল সেটা web service-এর message-এর সঙ্গে মেলায়নি। delete-table-এর পরlist-tablesকোনো table দেখায় না। শেষ লাইন0দেখায়,ddb-practiceনামের কোনো container বাকি নেই।
run সবকিছু দেখাতে পারে না। DynamoDB local বলে, বেশির ভাগ read strongly consistent মনে হয় Source 22সোর্স 22। তাই run এমন eventually consistent read দেখাতে পারে না, যা পুরোনো data ফেরত দেয়। DynamoDB local provisioned throughput setting উপেক্ষা করে Source 22সোর্স 22। তাই run throttling দেখাতে পারে না। run-এর পর টিউটোরিয়াল docker rmi amazon/dynamodb-local:latest দিয়ে image সরিয়ে দিয়েছে।
৩. Athena-র জন্য partition pruning-এর model বানান। এই ধাপ AWS-এর page-এর একটা নিয়মের model বানায়: আপনি একটা partitioned table query করে WHERE clause-এ partition উল্লেখ করলে Athena শুধু সেই partition থেকে data scan করে Source 31সোর্স 31। script টিউটোরিয়ালের নিজের। এটা তিন দিনের log লাইন লেখে Hive style-এ নাম দেওয়া folder-এ, যেমন dt=2014-07-05, ১,০০০, ২,০০০ আর ৩,০০০ লাইন সহ। লাইনগুলোতে tab দিয়ে আলাদা করা field আছে, AWS-এর tutorial-এর নমুনা log data-র মতো Source 28সোর্স 28। এটা partitions.py নামে save করুন:
"""A model of one rule of the Athena page: with the partition in the WHERE clause, only that partition is read."""
from pathlib import Path
DAYS = ["2014-07-05", "2014-07-06", "2014-07-07"]
LINE = "{day}\t20:00:09\tDFW3\t4260\t10.0.0.15\tGET\teabcd12345678.cloudfront.net\t/test-image-{n}.jpeg\t200\t-\tMozilla/5.0\n"
root = Path("logs")
for i, day in enumerate(DAYS, start=1):
folder = root / f"dt={day}" # a Hive-style path: key=value
folder.mkdir(parents=True)
with open(folder / "part-0.tsv", "w", encoding="utf-8") as out:
for n in range(1000 * i): # 1000, 2000, and 3000 lines
out.write(LINE.format(day=day, n=n))
def run(label, folders):
rows = size = 0
for folder in folders:
for path in folder.glob("*.tsv"):
data = path.read_bytes()
size += len(data)
rows += data.count(b"\n")
print(f"{label:26} folders read: {len(folders)} rows: {rows:5} bytes read: {size}")
run("no filter on dt", sorted(root.glob("dt=*")))
run("WHERE dt = '2014-07-06'", [root / "dt=2014-07-06"])চালান:
python3 partitions.pyটিউটোরিয়ালের run-এর output:
no filter on dt folders read: 3 rows: 6000 bytes read: 674670
WHERE dt = '2014-07-06' folders read: 1 rows: 2000 bytes read: 224890model SQL পড়ে না। দুটো run call হাতে folder বেছে নেয়, যেমন নিয়ম বলে WHERE clause partition-এর নাম দিলে Athena করে। কোনো filter ছাড়া model 3টা folder আর 674670 byte পড়েছে। একটা দিনের filter দিয়ে সে 1টা folder আর 224890 byte পড়েছে। Athena scan করা data হিসেবে যা জানায়, model তা মাপে না, আর টিউটোরিয়ালও তা মাপেনি।
৪. Step Functions-এর তিনটা নিয়মের model বানান। এই script টিউটোরিয়ালের নিজের, আর এটা Step Functions service নয়। এতে AWS-এর page-এর তিনটা নিয়ম আছে। StartAt আর States আবশ্যক Source 34সোর্স 34। StartAt-এর মান state object-গুলোর একটার নামের সঙ্গে হুবহু মিলতে হয় Source 34সোর্স 34। কোনো rule true না হলে একটা Choice state তার Default-এ যায়, আর Default না থাকলে state machine একটা error ছোড়ে Source 35সোর্স 35। Hello World definition হলো state machine structure page-এর উদাহরণ Source 34সোর্স 34। Choice state হলো TestState page-এর উদাহরণ, যা {"number": 2} input-কে Equals 2 state-এ পাঠায় Source 37সোর্স 37। এটা asl_model.py নামে save করুন:
"""A model of three rules of the Step Functions pages. It is not the Step Functions service."""
import json
HELLO = json.loads("""{
"Comment": "A Hello World example of the Amazon States Language using a Pass state",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Pass",
"Result": "Hello World!",
"End": true
}
}
}""")
CHOICE = json.loads('{"Type": "Choice", "Choices": [{"Variable": "$.number", "NumericEquals": 1, "Next": "Equals 1"}, '
'{"Variable": "$.number", "NumericEquals": 2, "Next": "Equals 2"}], "Default": "No Match"}')
def check(definition):
"""StartAt and States are required, and StartAt must exactly match the name of a state."""
problems = [f"{field} is required" for field in ("StartAt", "States") if field not in definition]
if not problems and definition["StartAt"] not in definition["States"]:
problems.append(f"StartAt {definition['StartAt']!r} does not exactly match the name of a state")
return problems or ["ok"]
def choose(state, data):
"""The next state of a Choice state. It handles only NumericEquals rules on a top-level name such as $.number."""
for rule in state["Choices"]:
name = rule["Variable"].removeprefix("$.")
if name in data and data[name] == rule["NumericEquals"]:
return rule["Next"]
if "Default" in state:
return state["Default"]
raise RuntimeError("no rule is true and there is no Default")
print("Hello World example:", check(HELLO))
print("StartAt in lower case:", check({**HELLO, "StartAt": "helloworld"}))
print("no States field:", check({"StartAt": "HelloWorld"}))
for number in (1, 2, 3):
print(f"Choice state, input number {number}:", choose(CHOICE, {"number": number}))
no_default = {key: value for key, value in CHOICE.items() if key != "Default"}
try:
choose(no_default, {"number": 3})
except RuntimeError as error:
print("Choice state without Default, input number 3:", error)চালান:
python3 asl_model.pyটিউটোরিয়ালের run-এর output:
Hello World example: ['ok']
StartAt in lower case: ["StartAt 'helloworld' does not exactly match the name of a state"]
no States field: ['States is required']
Choice state, input number 1: Equals 1
Choice state, input number 2: Equals 2
Choice state, input number 3: No Match
Choice state without Default, input number 3: no rule is true and there is no Default- Hello World definition check পাস করে।
- ছোট হাতের
StartAtসহ একটা definition প্রত্যাখ্যাত হয়, কারণ মান হুবহু মিলতে হয়। Statesfield ছাড়া একটা definition প্রত্যাখ্যাত হয়, কারণStatesআবশ্যক।- ২ input-এর জন্য Choice state
Equals 2-এ যায়, যেমন page দেখায়। ১ আর ৩ input-এর ফল নিয়মগুলো থেকে টিউটোরিয়ালের নিজের যুক্তি। Defaultছাড়া আর কোনো rule true না হলে model একটা error ছোড়ে। Step Functions-ও এই ক্ষেত্রে error ছোড়ে, আর message-এর শব্দ টিউটোরিয়ালের নিজের।
model শুধু একটা top-level নামের ওপর NumericEquals rule পড়ে। এটা মাত্র তিনটা নিয়ম যাচাই করে, তাই model-এ পাস করা একটা definition-ও Step Functions প্রত্যাখ্যান করতে পারে।
৫. দুটো command-এর parameter template ছাপুন। নিচের command প্রথমে ২ নম্বর ধাপের মতোই তিনটা environment variable সেট করে। এগুলো বেছে নেওয়া টিউটোরিয়ালের নিজের পছন্দ। --generate-cli-skeleton option একটা parameter template তৈরি করে দেখায়, যা আপনি নিজের মতো করে বদলে একটা command-এর input হিসেবে ব্যবহার করতে পারেন Source 39সোর্স 39। দুটো command টিউটোরিয়ালের নিজের পছন্দ, ছাঁকনিও তাই। এতে থাকা চারটা space ভেতরের (nested) নাম বাদ রাখে।
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true
for command in "lambda update-function-configuration" "stepfunctions test-state"; do
echo "== aws $command"
aws $command --generate-cli-skeleton | grep -E '^ "'
doneটিউটোরিয়ালের run-এর output:
== aws lambda update-function-configuration
"FunctionName": "",
"Role": "",
"Handler": "",
"Description": "",
"Timeout": 0,
"MemorySize": 0,
"VpcConfig": {
"Environment": {
"Runtime": "nodejs",
"DeadLetterConfig": {
"KMSKeyArn": "",
"TracingConfig": {
"RevisionId": "",
"Layers": [
"FileSystemConfigs": [
"ImageConfig": {
"EphemeralStorage": {
"SnapStart": {
"LoggingConfig": {
"CapacityProviderConfig": {
"DurableConfig": {
"RuntimeConfig": {
"AcceleratorConfig": {
== aws stepfunctions test-state
"definition": "",
"roleArn": "",
"input": "",
"inspectionLevel": "INFO",
"revealSecrets": true,
"variables": "",
"stateName": "",
"mock": {
"context": "",
"stateConfiguration": {টিউটোরিয়াল template-এর নামগুলোর মানে API reference-এর সঙ্গে যাচাই করেনি। এর কয়েকটা AWS-এর page-এর একটা option বা নামের সঙ্গে মেলে, শুধু নামের মিল দেখে। FunctionName আর Timeout মেলে timeout page-এর উদাহরণের --function-name আর --timeout-এর সঙ্গে Source 5সোর্স 5। definition, roleArn, input আর inspectionLevel মেলে TestState page-এর উদাহরণের --definition, --role-arn, --input আর --inspection-level-এর সঙ্গে Source 37সোর্স 37। stateName মেলে page-এর stateName parameter-এর সঙ্গে Source 37সোর্স 37। revealSecrets মেলে revealSecrets parameter-এর সঙ্গে Source 37সোর্স 37। mock মেলে page-এর উদাহরণের --mock option-এর সঙ্গে Source 37সোর্স 37। context মেলে page-এর context parameter-এর সঙ্গে Source 37সোর্স 37। template inspectionLevel-এর জন্য INFO দেখায়, আর আপনি কোনো level না দিলে Step Functions-ও INFO ব্যবহার করে Source 37সোর্স 37।
৬. পাশাপাশি পড়ুন: AWS-এর console tutorial। এগুলো AWS-এর নিজের page। টিউটোরিয়াল এগুলো চালায়নি। Lambda-র tutorial বলে, AWS শুরু করতে একটা AWS account লাগে Source 2সোর্স 2। Athena-র tutorial বলে, আগে না করে থাকলে একটা AWS account-এর জন্য sign up করতে Source 26সোর্স 26। Lambda-র billing হলো ব্যবহার অনুযায়ী Source 1সোর্স 1, আর দামের জন্য AWS তার pricing page-এর দিকে নির্দেশ করে Source 1সোর্স 1। Athena-র tutorial live resource ব্যবহার করে, তাই আপনি যে query চালান তার জন্য খরচ হয় Source 26সোর্স 26। এর ব্যবহার করা নমুনা data-র জন্য খরচ হয় না, কিন্তু আপনি নিজের data file Amazon S3-এ upload করলে খরচ হয় Source 26সোর্স 26। Step Functions-এর Standard workflow-এর দাম ঠিক হয় state transition ধরে Source 32সোর্স 32।
Lambda।
- Lambda console-এর Event Functions page খুলুন, Create Event Function বেছে নিন, আর Author from scratch নির্বাচন করুন Source 2সোর্স 2।
- Runtime-এর জন্য Node.js 24 বা Python 3.14 বেছে নিন Source 2সোর্স 2। Lambda একটা execution role-ও বানায়, যা CloudWatch Logs-এ লেখার মৌলিক permission দেয় Source 2সোর্স 2।
- ১ নম্বর ধাপের function code editor-এ paste করুন, Lambda যে code বানিয়েছিল তার জায়গায়, আর Deploy বেছে নিন Source 2সোর্স 2। handler function-এর নাম বদলাবেন না। বদলালে Lambda আপনার code চালাতে পারবে না Source 2সোর্স 2।
lengthআরwidthসহ JSON document দিয়েmyTestEventনামে একটা test event বানান, আর তার পাশের run icon বেছে নিন Source 2সোর্স 2।- পরিষ্কার করুন। function মুছুন, তারপর তার log রাখা log group, তারপর execution role Source 2সোর্স 2।
Athena।
- একই Region-এ Amazon S3-এ একটা bucket বানান, যেখানে আপনার Athena query-র ফল থাকবে। আপনি এই bucket-টাকে আপনার query output location হিসেবে configure করেন Source 26সোর্স 26।
- Athena console-এ Location of query result box-এ bucket-এর path দিন,
s3://prefix সহ Source 27সোর্স 27। - CREATE DATABASE statement দিয়ে
mydatabaseনামে একটা database বানান Source 27সোর্স 27। - AWS-এর নমুনা CloudFront log data থেকে table বানান Source 28সোর্স 28। page সতর্ক করে, তার প্রথম CREATE TABLE statement-এ একটা গুরুত্বপূর্ণ সীমাবদ্ধতা আছে, তাই চালানোর আগে পড়ে নিন Source 28সোর্স 28।
- table-টায় একটা SQL query চালান আর Athena-য় ফল দেখুন Source 29সোর্স 29।
- টিউটোরিয়াল যে page পড়েছে সেগুলোতে Athena-র জন্য পরিষ্কারের কোনো ধাপ নেই। টিউটোরিয়ালের নিজের পরামর্শ: কাজ শেষে query-র ফলের bucket, table আর database মুছে ফেলুন।
Step Functions।
- আনুমানিক সময় ২০-৩০ মিনিট Source 38সোর্স 38। console-এ Run Hello World বেছে নিন Source 38সোর্স 38।
- ASL code দেখতে Code button বেছে নিন Source 38সোর্স 38।
- state machine বানানোর আগে তার নাম দিন, কারণ পরে নাম বদলানো যায় না Source 38সোর্স 38। তখন পর্যন্ত আপনি একটা খসড়ায় কাজ করেছেন, আর কোনো resource বানানো হয়নি Source 38সোর্স 38।
- permission-এর জন্য একটা নতুন role দিয়ে state machine বানান Source 38সোর্স 38। input field খালি রেখে
hello001নামে একটা execution চালু করুন Source 38সোর্স 38। - পরিষ্কার করুন। IAM role মুছুন, তারপর Actions আর Delete দিয়ে state machine মুছুন Source 38সোর্স 38।
How a tester uses it
- Test the function as code, and then in the cloud. For serverless testing, you still write unit, integration and end-to-end tests Source 8সোর্স 8. Cloud-based tests provide the most accurate measure of quality of both your functions and serverless applications Source 8সোর্স 8. You cannot fully replicate a cloud environment locally Source 8সোর্স 8.
- Keep the handler thin. The handler should be a slim adapter that takes in event data and passes only the details that matter to your business logic Source 8সোর্স 8. It should extract and validate data from the incoming event and context objects Source 8সোর্স 8.
- Know what mocks and emulators miss. Tests that rely on emulators might pass locally, but fail in the cloud due to production security policies, inter-service configurations, or exceeding Lambda quotas Source 8সোর্স 8. Mock frameworks are limited in testing or detecting IAM policy or quota limitations Source 8সোর্স 8. Even a function that calls no other service depends on its timeout and memory settings Source 8সোর্স 8. The permission for logs cannot be accurately mocked or emulated Source 8সোর্স 8.
- Give cloud tests their own resources. Automated test processes should create uniquely named resources for each stack Source 8সোর্স 8. Load testing is an activity that you should isolate from your production stack Source 8সোর্স 8. Environments should have alerts and controls to avoid unnecessary spending Source 8সোর্স 8.
- Test timeouts with realistic data. If the timeout value is close to the average duration of a function, there is a higher risk that the function times out unexpectedly Source 5সোর্স 5. Tests often use small samples, but you should use datasets at the upper bounds of what is reasonably expected Source 5সোর্স 5.
- Test both invocation types. A synchronous invocation returns the error message in the response, and an asynchronous invocation is retried by Lambda automatically Source 3সোর্স 3.
- Do not lean on a reused environment. You should not assume that the execution environment will persist indefinitely Source 6সোর্স 6. The
/tmpdirectory keeps its content while the environment is frozen Source 6সোর্স 6. So a test can pass on a reused environment because of state that an earlier invocation left behind. - Expect cold starts and throttling. Cold starts are typically more common in development and test functions than in production workloads Source 6সোর্স 6. A function that runs out of available concurrency experiences throttling Source 7সোর্স 7.
- Read after a write on purpose. Eventually consistent is the default read model, and a read might not reflect a recently completed write Source 11সোর্স 11. Set ConsistentRead to true to get the most up-to-date data Source 11সোর্স 11. Reads from a global secondary index are always eventually consistent Source 11সোর্স 11. DynamoDB local says that most reads appear to be strongly consistent Source 22সোর্স 22. It also ignores provisioned throughput settings Source 22সোর্স 22. A local run therefore cannot show stale reads or throttling.
- Do not wait for TTL in a test. The system might delete expired items at any time, typically within a few days after their expiration Source 13সোর্স 13. Check that the TTL attribute is a Number in Unix epoch time at the seconds granularity Source 13সোর্স 13. Use filter expressions to remove expired items from Scan and Query results Source 13সোর্স 13.
- Test the key rules. Each item in the Music table must have both key attributes Source 10সোর্স 10. Each primary key attribute must be a scalar of the type string, number, or binary Source 10সোর্স 10. In the tutorial's run, the item without the sort key was refused.
- Compare a sample with a real run. In the tutorial's run, the sample result of step 3 of the DynamoDB tutorial showed a type that the real output did not show (see step 2 of Try it).
- Check the partition filter and the registration in Athena. If the WHERE clause names the partition, Athena scans the data only from that partition Source 31সোর্স 31. The MSCK REPAIR TABLE command works only with Hive-style partitions Source 31সোর্স 31. If the S3 path is in camel case, it does not add the partitions to the AWS Glue Data Catalog Source 31সোর্স 31. Before querying data, a table must be registered in Athena Source 30সোর্স 30.
- Unit-test states with the TestState API. The API enables you to write unit tests for your state machines Source 37সোর্স 37. You can assert which Catch or Retry applies Source 37সোর্স 37. You can assert the input after the InputPath filter, in
afterInputPathSource 37সোর্স 37. Mocking is necessary to test Map, Parallel, Activity,.sync, andwaitForTaskTokenpatterns Source 37সোর্স 37. The console TestState feature does not yet support some of the enhancements Source 37সোর্স 37. - Test an input that no Choice rule matches. If no Choices evaluate to true and no Default is provided, the state machine throws an error Source 35সোর্স 35.
- Make Express steps safe to repeat. One or more steps in an Express workflow can potentially run more than once, while each step executes at least once Source 32সোর্স 32. So check that a repeated step does no harm.
সহজ English
- Test the function as code, and then in the cloud. For serverless testing, you still write unit, integration and end-to-end tests Source 8সোর্স 8. Cloud-based tests provide the most accurate measure of quality of both your functions and serverless applications Source 8সোর্স 8. You cannot fully replicate a cloud environment locally Source 8সোর্স 8.
- Keep the handler thin. The handler should be a slim adapter that takes in event data and passes only the details that matter to your business logic Source 8সোর্স 8. It should extract and validate data from the incoming event and context objects Source 8সোর্স 8.
- Know what mocks and emulators miss. Tests that rely on emulators might pass locally, but fail in the cloud due to production security policies, inter-service configurations, or exceeding Lambda quotas Source 8সোর্স 8. Mock frameworks are limited in testing or detecting IAM policy or quota limitations Source 8সোর্স 8. Even a function that calls no other service depends on its timeout and memory settings Source 8সোর্স 8. The permission for logs cannot be accurately mocked or emulated Source 8সোর্স 8.
- Give cloud tests their own resources. Automated test processes should create uniquely named resources for each stack Source 8সোর্স 8. Load testing is an activity that you should isolate from your production stack Source 8সোর্স 8. Environments should have alerts and controls to avoid unnecessary spending Source 8সোর্স 8.
- Test timeouts with realistic data. If the timeout value is close to the average duration of a function, there is a higher risk that the function times out unexpectedly Source 5সোর্স 5. Tests often use small samples, but you should use datasets at the upper bounds of what is reasonably expected Source 5সোর্স 5.
- Test both invocation types. A synchronous invocation returns the error message in the response, and an asynchronous invocation is retried by Lambda automatically Source 3সোর্স 3.
- Do not lean on a reused environment. You should not assume that the execution environment will persist indefinitely Source 6সোর্স 6. The
/tmpdirectory keeps its content while the environment is frozen Source 6সোর্স 6. So a test can pass on a reused environment because of state that an earlier invocation left behind. - Expect cold starts and throttling. Cold starts are typically more common in development and test functions than in production workloads Source 6সোর্স 6. A function that runs out of available concurrency experiences throttling Source 7সোর্স 7.
- Read after a write on purpose. Eventually consistent is the default read model, and a read might not reflect a recently completed write Source 11সোর্স 11. Set ConsistentRead to true to get the most up-to-date data Source 11সোর্স 11. Reads from a global secondary index are always eventually consistent Source 11সোর্স 11. DynamoDB local says that most reads appear to be strongly consistent Source 22সোর্স 22. It also ignores provisioned throughput settings Source 22সোর্স 22. A local run therefore cannot show stale reads or throttling.
- Do not wait for TTL in a test. The system might delete expired items at any time, typically within a few days after their expiration Source 13সোর্স 13. Check that the TTL attribute is a Number in Unix epoch time at the seconds granularity Source 13সোর্স 13. Use filter expressions to remove expired items from Scan and Query results Source 13সোর্স 13.
- Test the key rules. Each item in the Music table must have both key attributes Source 10সোর্স 10. Each primary key attribute must be a scalar of the type string, number, or binary Source 10সোর্স 10. In the tutorial's run, the item without the sort key was refused.
- Compare a sample with a real run. In the tutorial's run, the sample result of step 3 of the DynamoDB tutorial showed a type that the real output did not show (see step 2 of Try it).
- Check the partition filter and the registration in Athena. If the WHERE clause names the partition, Athena scans the data only from that partition Source 31সোর্স 31. The MSCK REPAIR TABLE command works only with Hive-style partitions Source 31সোর্স 31. If the S3 path is in camel case, it does not add the partitions to the AWS Glue Data Catalog Source 31সোর্স 31. Before querying data, a table must be registered in Athena Source 30সোর্স 30.
- Unit-test states with the TestState API. The API enables you to write unit tests for your state machines Source 37সোর্স 37. You can assert which Catch or Retry applies Source 37সোর্স 37. You can assert the input after the InputPath filter, in
afterInputPathSource 37সোর্স 37. Mocking is necessary to test Map, Parallel, Activity,.sync, andwaitForTaskTokenpatterns Source 37সোর্স 37. The console TestState feature does not yet support some of the enhancements Source 37সোর্স 37. - Test an input that no Choice rule matches. If no Choices evaluate to true and no Default is provided, the state machine throws an error Source 35সোর্স 35.
- Make Express steps safe to repeat. One or more steps in an Express workflow can potentially run more than once, while each step executes at least once Source 32সোর্স 32. So check that a repeated step does no harm.
বাংলা ব্যাখ্যা
- function-টা আগে code হিসেবে test করুন, তারপর cloud-এ। serverless test-এর জন্যও আপনি unit, integration আর end-to-end test লেখেন Source 8সোর্স 8। cloud-ভিত্তিক test আপনার function আর serverless application দুটোর মানের সবচেয়ে নির্ভুল পরিমাপ দেয় Source 8সোর্স 8। আপনি একটা cloud environment স্থানীয়ভাবে পুরোপুরি নকল করতে পারেন না Source 8সোর্স 8।
- handler পাতলা রাখুন। handler হওয়া উচিত একটা সরু adapter, যা event data নেয় আর শুধু যা business logic-এর জন্য জরুরি তা পাঠায় Source 8সোর্স 8। এটার উচিত আসা event আর context object থেকে data বের করে যাচাই করা Source 8সোর্স 8।
- mock আর emulator কী ধরতে পারে না, তা জানুন। emulator-নির্ভর test স্থানীয়ভাবে পাস করতে পারে, কিন্তু production security policy, service-এর মধ্যকার configuration বা Lambda quota ছাড়িয়ে যাওয়ার কারণে cloud-এ ব্যর্থ হতে পারে Source 8সোর্স 8। mock framework IAM policy বা quota-র সীমা test করা বা ধরার ক্ষেত্রে সীমিত Source 8সোর্স 8। অন্য কোনো service call না করা function-ও তার timeout আর memory setting-এর ওপর নির্ভর করে Source 8সোর্স 8। log-এর permission সঠিকভাবে mock বা emulate করা যায় না Source 8সোর্স 8।
- cloud test-কে নিজস্ব resource দিন। স্বয়ংক্রিয় test process-এর উচিত প্রতিটা stack-এর জন্য অনন্য নামের resource বানানো Source 8সোর্স 8। load test এমন একটা কাজ, যা আপনার production stack থেকে আলাদা রাখা উচিত Source 8সোর্স 8। অপ্রয়োজনীয় খরচ এড়াতে environment-এ alert আর নিয়ন্ত্রণ থাকা উচিত Source 8সোর্স 8।
- বাস্তবসম্মত data দিয়ে timeout test করুন। timeout-এর মান একটা function-এর গড় সময়ের কাছাকাছি হলে function অপ্রত্যাশিতভাবে time out করার ঝুঁকি বেশি Source 5সোর্স 5। test প্রায়ই ছোট নমুনা ব্যবহার করে, কিন্তু যুক্তিসঙ্গতভাবে প্রত্যাশিত সীমার উপরের প্রান্তের dataset ব্যবহার করা উচিত Source 5সোর্স 5।
- দুই ধরনের invocation-ই test করুন। synchronous invocation response-এ error message ফেরত দেয়, আর asynchronous invocation Lambda নিজে থেকেই retry করে Source 3সোর্স 3।
- আবার ব্যবহার করা environment-এর ওপর ভরসা করবেন না। execution environment যে অনির্দিষ্টকাল টিকে থাকবে তা ধরে নেওয়া উচিত নয় Source 6সোর্স 6। environment frozen থাকার সময়
/tmpdirectory-র content থেকে যায় Source 6সোর্স 6। তাই আগের কোনো invocation-এর রেখে যাওয়া অবস্থার কারণে একটা test আবার ব্যবহার করা environment-এ পাস করতে পারে। - cold start আর throttling আশা করুন। production workload-এর চেয়ে development আর test function-এ cold start সাধারণত বেশি ঘটে Source 6সোর্স 6। available concurrency ফুরিয়ে গেলে একটা function throttling-এর মুখে পড়ে Source 7সোর্স 7।
- ইচ্ছে করে লেখার পর পড়ুন। eventually consistent হলো default read model, আর একটা read সদ্য শেষ হওয়া লেখা না-ও দেখাতে পারে Source 11সোর্স 11। সবচেয়ে হালনাগাদ data পেতে ConsistentRead true করুন Source 11সোর্স 11। global secondary index থেকে সব read সবসময় eventually consistent Source 11সোর্স 11। DynamoDB local বলে, বেশির ভাগ read strongly consistent মনে হয় Source 22সোর্স 22। এটা provisioned throughput setting-ও উপেক্ষা করে Source 22সোর্স 22। তাই স্থানীয় run পুরোনো read বা throttling দেখাতে পারে না।
- test-এ TTL-এর জন্য অপেক্ষা করবেন না। system মেয়াদোত্তীর্ণ item যেকোনো সময় মুছতে পারে, সাধারণত মেয়াদ শেষের কয়েক দিনের মধ্যে Source 13সোর্স 13। যাচাই করুন TTL attribute সেকেন্ড granularity-তে Unix epoch time-এর একটা Number Source 13সোর্স 13। মেয়াদোত্তীর্ণ item Scan আর Query-র ফল থেকে বাদ দিতে filter expression ব্যবহার করুন Source 13সোর্স 13।
- key-এর নিয়ম test করুন। Music table-এর প্রতিটা item-এ দুটো key attribute-ই থাকতে হয় Source 10সোর্স 10। প্রতিটা primary key attribute string, number বা binary type-এর একটা scalar হতে হয় Source 10সোর্স 10। টিউটোরিয়ালের run-এ sort key ছাড়া item-টা প্রত্যাখ্যাত হয়েছে।
- নমুনার সঙ্গে আসল run মিলিয়ে দেখুন। টিউটোরিয়ালের run-এ DynamoDB tutorial-এর ৩ নম্বর ধাপের নমুনা ফল এমন একটা type দেখিয়েছে, যা আসল output দেখায়নি (Try it-এর ২ নম্বর ধাপ দেখুন)।
- Athena-য় partition filter আর registration যাচাই করুন। WHERE clause partition-এর নাম দিলে Athena শুধু সেই partition থেকে data scan করে Source 31সোর্স 31। MSCK REPAIR TABLE command শুধু Hive-style partition-এর সঙ্গে কাজ করে Source 31সোর্স 31। S3 path camel case-এ থাকলে সেটা AWS Glue Data Catalog-এ partition যোগ করে না Source 31সোর্স 31। data query করার আগে একটা table Athena-য় register করা থাকতে হয় Source 30সোর্স 30।
- TestState API দিয়ে state-এর unit test করুন। API আপনাকে আপনার state machine-এর জন্য unit test লিখতে সক্ষম করে Source 37সোর্স 37। আপনি assert করতে পারেন কোন Catch বা Retry প্রযোজ্য Source 37সোর্স 37। আপনি InputPath filter-এর পরের input assert করতে পারেন,
afterInputPath-এ Source 37সোর্স 37। Map, Parallel, Activity,.syncআরwaitForTaskTokenpattern test করতে mocking লাগে Source 37সোর্স 37। console-এর TestState সুবিধা এখনো কিছু উন্নতি সমর্থন করে না Source 37সোর্স 37। - এমন input test করুন, যাতে কোনো Choice rule মেলে না। কোনো Choice true না হলে আর Default না থাকলে state machine একটা error ছোড়ে Source 35সোর্স 35।
- Express-এর ধাপ আবার চললেও নিরাপদ রাখুন। একটা Express workflow-র এক বা একাধিক ধাপ সম্ভবত একাধিকবার চলতে পারে, আর প্রতিটা ধাপ অন্তত একবার চলে Source 32সোর্স 32। তাই যাচাই করুন আবার চলা একটা ধাপ কোনো ক্ষতি করে না।
Common mistakes
- Renaming the handler function. Be sure not to edit the name of the handler function, because Lambda won't be able to run your code if you do Source 2সোর্স 2.
- Calling
sts:AssumeRolein function code. Lambda automatically assumes your execution role Source 4সোর্স 4. You should avoid manually callingsts:AssumeRoleto assume the execution role in your function code Source 4সোর্স 4. - Forgetting the trust policy of the role. For Lambda to properly assume the execution role, the trust policy must specify the Lambda service principal as a trusted service Source 4সোর্স 4.
- Testing only on your own machine. You cannot fully replicate a cloud environment locally Source 8সোর্স 8. Tests that rely on emulators might provide successful results locally, but fail in the cloud Source 8সোর্স 8.
- Putting the logic in the handler. The handler should be a slim adapter that passes only the details that matter to your business logic Source 8সোর্স 8.
- Setting a timeout close to the usual duration. If the timeout value is close to the average duration of a function, there is a higher risk that the function times out unexpectedly Source 5সোর্স 5.
- Trusting a reused execution environment. You should not assume that the execution environment will persist indefinitely Source 6সোর্স 6. Background processes that did not complete when the function ended resume if Lambda reuses the execution environment Source 6সোর্স 6.
- Forgetting
--endpoint-url. By default, the AWS SDKs and tools use endpoints for the DynamoDB web service Source 22সোর্স 22. To use them with DynamoDB local, you must specify the local endpoint Source 22সোর্স 22. - Treating DynamoDB local as the real service. The downloadable version is intended for development and testing purposes only Source 22সোর্স 22. With
-inMemory, none of the data is saved when you stop DynamoDB Source 22সোর্স 22. If telemetry remains on, DynamoDB local sends telemetry data in the background Source 23সোর্স 23. - Expecting a JOIN in DynamoDB. DynamoDB doesn't support a JOIN operator Source 9সোর্স 9.
- Expecting a strongly consistent read by default. Eventually consistent is the default read consistent model Source 11সোর্স 11. Strongly consistent reads from a global secondary index or a stream are not supported Source 11সোর্স 11.
- Expecting TTL to delete items on time. The system might delete expired items at any time, typically within a few days after their expiration Source 13সোর্স 13. Items with a TTL attribute that is not a Number are ignored by the TTL process Source 13সোর্স 13.
- Pointing an Athena table at a file. The LOCATION clause specifies an Amazon S3 folder, not a specific file, because Athena expects to scan all of the files in a folder Source 28সোর্স 28.
- Using a camel case path with
MSCK REPAIR TABLE. If the S3 path is in camel case, MSCK REPAIR TABLE doesn't add the partitions to the AWS Glue Data Catalog Source 31সোর্স 31. The command works only with Hive-style partitions Source 31সোর্স 31. - Leaving a big S3 bucket unpartitioned. If you issue queries against Amazon S3 buckets with a large number of objects and the data is not partitioned, such queries may affect the GET request rate limits in Amazon S3 and lead to Amazon S3 exceptions Source 31সোর্স 31.
- Getting the name in
StartAtwrong. The value must exactly match, and is case sensitive, the name of one of the state objects Source 34সোর্স 34. - Leaving out
Defaultin a Choice state. If no Choices evaluate to true and no Default is provided, the state machine throws an error Source 35সোর্স 35. Choice states do not support the End field Source 35সোর্স 35. - Expecting a catcher to save a failed execution. Catchers are not available for top-level state machine execution failures Source 36সোর্স 36. By default, Step Functions fails the entire state machine execution Source 36সোর্স 36.
- Assuming an Express step runs once. One or more steps in an Express workflow can potentially run more than once Source 32সোর্স 32.
- Choosing the console to test Map or Parallel states. The console TestState feature does not yet support mocking service integrations or testing Map and Parallel states Source 37সোর্স 37.
- Naming a state machine in a hurry. You cannot rename a state machine after you create it Source 38সোর্স 38.
- Forgetting what costs money. Using provisioned concurrency incurs additional charges to your account Source 7সোর্স 7. In provisioned mode, you are charged for the capacity that you provisioned, not for the capacity that you consumed Source 12সোর্স 12. In the Athena tutorial, you are charged for the queries that you run, and if you upload your own data files to Amazon S3, charges do apply Source 26সোর্স 26.
সহজ English
- Renaming the handler function. Be sure not to edit the name of the handler function, because Lambda won't be able to run your code if you do Source 2সোর্স 2.
- Calling
sts:AssumeRolein function code. Lambda automatically assumes your execution role Source 4সোর্স 4. You should avoid manually callingsts:AssumeRoleto assume the execution role in your function code Source 4সোর্স 4. - Forgetting the trust policy of the role. For Lambda to properly assume the execution role, the trust policy must specify the Lambda service principal as a trusted service Source 4সোর্স 4.
- Testing only on your own machine. You cannot fully replicate a cloud environment locally Source 8সোর্স 8. Tests that rely on emulators might provide successful results locally, but fail in the cloud Source 8সোর্স 8.
- Putting the logic in the handler. The handler should be a slim adapter that passes only the details that matter to your business logic Source 8সোর্স 8.
- Setting a timeout close to the usual duration. If the timeout value is close to the average duration of a function, there is a higher risk that the function times out unexpectedly Source 5সোর্স 5.
- Trusting a reused execution environment. You should not assume that the execution environment will persist indefinitely Source 6সোর্স 6. Background processes that did not complete when the function ended resume if Lambda reuses the execution environment Source 6সোর্স 6.
- Forgetting
--endpoint-url. By default, the AWS SDKs and tools use endpoints for the DynamoDB web service Source 22সোর্স 22. To use them with DynamoDB local, you must specify the local endpoint Source 22সোর্স 22. - Treating DynamoDB local as the real service. The downloadable version is intended for development and testing purposes only Source 22সোর্স 22. With
-inMemory, none of the data is saved when you stop DynamoDB Source 22সোর্স 22. If telemetry remains on, DynamoDB local sends telemetry data in the background Source 23সোর্স 23. - Expecting a JOIN in DynamoDB. DynamoDB doesn't support a JOIN operator Source 9সোর্স 9.
- Expecting a strongly consistent read by default. Eventually consistent is the default read consistent model Source 11সোর্স 11. Strongly consistent reads from a global secondary index or a stream are not supported Source 11সোর্স 11.
- Expecting TTL to delete items on time. The system might delete expired items at any time, typically within a few days after their expiration Source 13সোর্স 13. Items with a TTL attribute that is not a Number are ignored by the TTL process Source 13সোর্স 13.
- Pointing an Athena table at a file. The LOCATION clause specifies an Amazon S3 folder, not a specific file, because Athena expects to scan all of the files in a folder Source 28সোর্স 28.
- Using a camel case path with
MSCK REPAIR TABLE. If the S3 path is in camel case, MSCK REPAIR TABLE doesn't add the partitions to the AWS Glue Data Catalog Source 31সোর্স 31. The command works only with Hive-style partitions Source 31সোর্স 31. - Leaving a big S3 bucket unpartitioned. If you issue queries against Amazon S3 buckets with a large number of objects and the data is not partitioned, such queries may affect the GET request rate limits in Amazon S3 and lead to Amazon S3 exceptions Source 31সোর্স 31.
- Getting the name in
StartAtwrong. The value must exactly match, and is case sensitive, the name of one of the state objects Source 34সোর্স 34. - Leaving out
Defaultin a Choice state. If no Choices evaluate to true and no Default is provided, the state machine throws an error Source 35সোর্স 35. Choice states do not support the End field Source 35সোর্স 35. - Expecting a catcher to save a failed execution. Catchers are not available for top-level state machine execution failures Source 36সোর্স 36. By default, Step Functions fails the entire state machine execution Source 36সোর্স 36.
- Assuming an Express step runs once. One or more steps in an Express workflow can potentially run more than once Source 32সোর্স 32.
- Choosing the console to test Map or Parallel states. The console TestState feature does not yet support mocking service integrations or testing Map and Parallel states Source 37সোর্স 37.
- Naming a state machine in a hurry. You cannot rename a state machine after you create it Source 38সোর্স 38.
- Forgetting what costs money. Using provisioned concurrency incurs additional charges to your account Source 7সোর্স 7. In provisioned mode, you are charged for the capacity that you provisioned, not for the capacity that you consumed Source 12সোর্স 12. In the Athena tutorial, you are charged for the queries that you run, and if you upload your own data files to Amazon S3, charges do apply Source 26সোর্স 26.
বাংলা ব্যাখ্যা
- handler function-এর নাম বদলানো। handler function-এর নাম বদলাবেন না, কারণ বদলালে Lambda আপনার code চালাতে পারবে না Source 2সোর্স 2।
- function code-এ
sts:AssumeRolecall করা। Lambda নিজে থেকেই আপনার execution role assume করে Source 4সোর্স 4। আপনার function code-এ execution role assume করতে নিজে হাতেsts:AssumeRolecall করা এড়ানো উচিত Source 4সোর্স 4। - role-এর trust policy ভুলে যাওয়া। Lambda যাতে execution role ঠিকভাবে assume করতে পারে, তার জন্য trust policy-তে Lambda service principal-কে একটা বিশ্বস্ত service হিসেবে উল্লেখ করতে হয় Source 4সোর্স 4।
- শুধু নিজের মেশিনে test করা। আপনি একটা cloud environment স্থানীয়ভাবে পুরোপুরি নকল করতে পারেন না Source 8সোর্স 8। emulator-নির্ভর test স্থানীয়ভাবে সফল ফল দিতে পারে, কিন্তু cloud-এ ব্যর্থ হতে পারে Source 8সোর্স 8।
- handler-এ logic ঢোকানো। handler হওয়া উচিত একটা সরু adapter, যা শুধু business logic-এর জন্য জরুরি খুঁটিনাটি পাঠায় Source 8সোর্স 8।
- সাধারণ সময়ের কাছাকাছি timeout ঠিক করা। timeout-এর মান একটা function-এর গড় সময়ের কাছাকাছি হলে function অপ্রত্যাশিতভাবে time out করার ঝুঁকি বেশি Source 5সোর্স 5।
- আবার ব্যবহার করা execution environment-এ ভরসা করা। execution environment যে অনির্দিষ্টকাল টিকে থাকবে তা ধরে নেওয়া উচিত নয় Source 6সোর্স 6। function শেষ হওয়ার সময় যে background process শেষ হয়নি, Lambda environment আবার ব্যবহার করলে সেগুলো আবার চলতে শুরু করে Source 6সোর্স 6।
--endpoint-urlভুলে যাওয়া। by default AWS SDK আর tool DynamoDB web service-এর endpoint ব্যবহার করে Source 22সোর্স 22। DynamoDB local-এর সঙ্গে ব্যবহার করতে আপনাকে local endpoint উল্লেখ করতেই হয় Source 22সোর্স 22।- DynamoDB local-কে আসল service ভাবা। downloadable version শুধু development আর testing-এর উদ্দেশ্যে Source 22সোর্স 22।
-inMemoryদিলে DynamoDB বন্ধ করার সময় কোনো data সংরক্ষিত থাকে না Source 22সোর্স 22। telemetry চালু থাকলে DynamoDB local background-এ telemetry data পাঠায় Source 23সোর্স 23। - DynamoDB-তে JOIN আশা করা। DynamoDB JOIN operator সমর্থন করে না Source 9সোর্স 9।
- by default strongly consistent read আশা করা। eventually consistent হলো default read consistent model Source 11সোর্স 11। global secondary index বা stream থেকে strongly consistent read সমর্থিত নয় Source 11সোর্স 11।
- TTL ঠিক সময়ে item মুছবে আশা করা। system মেয়াদোত্তীর্ণ item যেকোনো সময় মুছতে পারে, সাধারণত মেয়াদ শেষের কয়েক দিনের মধ্যে Source 13সোর্স 13। TTL attribute Number নয় এমন item-কে TTL process উপেক্ষা করে Source 13সোর্স 13।
- Athena table-কে একটা file-এর দিকে নির্দেশ করা। LOCATION clause Amazon S3-এর একটা folder-কে নির্দেশ করে, নির্দিষ্ট একটা file-কে নয়, কারণ Athena একটা folder-এর সব file scan করতে চায় Source 28সোর্স 28।
MSCK REPAIR TABLE-এ camel case path ব্যবহার করা। S3 path camel case-এ থাকলে MSCK REPAIR TABLE AWS Glue Data Catalog-এ partition যোগ করে না Source 31সোর্স 31। command-টা শুধু Hive-style partition-এর সঙ্গে কাজ করে Source 31সোর্স 31।- বড় S3 bucket partition না করে রাখা। আপনি অনেক object-সহ Amazon S3 bucket-এ এমন query চালালে, যার data partition করা নেই, সেই query Amazon S3-এর GET request rate limit-এ প্রভাব ফেলতে পারে আর Amazon S3 exception ঘটাতে পারে Source 31সোর্স 31।
StartAt-এ নাম ভুল দেওয়া। মান state object-গুলোর একটার নামের সঙ্গে হুবহু মিলতে হয়, আর এটা case sensitive Source 34সোর্স 34।- Choice state-এ
Defaultবাদ দেওয়া। কোনো Choice true না হলে আর Default না থাকলে state machine একটা error ছোড়ে Source 35সোর্স 35। Choice state End field সমর্থন করে না Source 35সোর্স 35। - catcher ব্যর্থ execution বাঁচাবে আশা করা। top-level state machine execution-এর ব্যর্থতার জন্য catcher পাওয়া যায় না Source 36সোর্স 36। by default Step Functions পুরো state machine execution ব্যর্থ করে দেয় Source 36সোর্স 36।
- Express-এর একটা ধাপ একবারই চলবে ধরে নেওয়া। একটা Express workflow-র এক বা একাধিক ধাপ সম্ভবত একাধিকবার চলতে পারে Source 32সোর্স 32।
- Map বা Parallel state test করতে console বেছে নেওয়া। console-এর TestState সুবিধা এখনো service integration mock করা বা Map ও Parallel state test করা সমর্থন করে না Source 37সোর্স 37।
- তাড়াহুড়ো করে state machine-এর নাম দেওয়া। state machine বানানোর পর তার নাম বদলানো যায় না Source 38সোর্স 38।
- কিসে খরচ হয় ভুলে যাওয়া। provisioned concurrency ব্যবহারে আপনার account-এ বাড়তি খরচ হয় Source 7সোর্স 7। provisioned mode-এ আপনি যে capacity provision করেছেন তার জন্য খরচ হয়, যে capacity ব্যবহার করেছেন তার জন্য নয় Source 12সোর্স 12। Athena-র tutorial-এ আপনি যে query চালান তার জন্য খরচ হয়, আর আপনি নিজের data file Amazon S3-এ upload করলে খরচ হয় Source 26সোর্স 26।
What a tester can check
Tutorial advice
This list is the tutorial's own advice for a tester who works with Lambda, DynamoDB, Athena, and Step Functions.
- Write the expected result of an event or a request before you run it, and keep it with the test.
- Keep the handler thin, and put the logic in plain functions that a test can call.
- Test with the largest realistic input, not only with a small sample.
- Use made-up data for every practice table, secret, and bucket, and start each name with a prefix that says it is a test.
- Put the clean-up in the same script that creates the resources.
- When a sample on a docs page and a real run disagree, write down both, and tell the owner of the page.
- For DynamoDB, read right after a write twice: once with ConsistentRead and once without.
- For Athena, check what a query reads, not only what it returns.
- For Step Functions, keep one test for every branch of a Choice state, and one test for an input that matches no branch.
- Run the local tools with made-up credentials and an explicit endpoint, and check the endpoint before you run a command.
- Keep the date, the tool versions, and the exact commands with every test result.
- Use the models of this page to learn the rules, not as a test oracle for a real account.
সহজ English
Tutorial advice
This list is the tutorial's own advice for a tester who works with Lambda, DynamoDB, Athena, and Step Functions.
- Write the expected result of an event or a request before you run it, and keep it with the test.
- Keep the handler thin, and put the logic in plain functions that a test can call.
- Test with the largest realistic input, not only with a small sample.
- Use made-up data for every practice table, secret, and bucket, and start each name with a prefix that says it is a test.
- Put the clean-up in the same script that creates the resources.
- When a sample on a docs page and a real run disagree, write down both, and tell the owner of the page.
- For DynamoDB, read right after a write twice: once with ConsistentRead and once without.
- For Athena, check what a query reads, not only what it returns.
- For Step Functions, keep one test for every branch of a Choice state, and one test for an input that matches no branch.
- Run the local tools with made-up credentials and an explicit endpoint, and check the endpoint before you run a command.
- Keep the date, the tool versions, and the exact commands with every test result.
- Use the models of this page to learn the rules, not as a test oracle for a real account.
বাংলা ব্যাখ্যা
Tutorial advice
এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, এমন একজন tester-এর জন্য যিনি Lambda, DynamoDB, Athena আর Step Functions নিয়ে কাজ করেন।
- একটা event বা request চালানোর আগে তার প্রত্যাশিত ফল লিখে রাখুন, আর সেটা test-এর সঙ্গে রাখুন।
- handler পাতলা রাখুন, আর logic রাখুন সাধারণ function-এ, যা একটা test call করতে পারে।
- শুধু ছোট নমুনা দিয়ে নয়, বাস্তবসম্মত সবচেয়ে বড় input দিয়ে test করুন।
- অনুশীলনের প্রতিটা table, secret আর bucket-এর জন্য বানানো data ব্যবহার করুন, আর প্রতিটা নাম শুরু করুন এমন একটা prefix দিয়ে, যা বলে এটা test।
- পরিষ্কারের কাজ রাখুন সেই একই script-এ, যা resource বানায়।
- একটা docs page-এর নমুনা আর আসল run মিলে না গেলে দুটোই লিখে রাখুন, আর page-এর মালিককে জানান।
- DynamoDB-র জন্য একটা লেখার ঠিক পরে দুবার পড়ুন: একবার ConsistentRead দিয়ে আর একবার ছাড়া।
- Athena-র জন্য একটা query কী ফেরত দেয় শুধু তা নয়, সে কী পড়ে তা যাচাই করুন।
- Step Functions-এর জন্য একটা Choice state-এর প্রতিটা branch-এর জন্য একটা করে test রাখুন, আর এমন একটা input-এর জন্য একটা test, যা কোনো branch-এর সঙ্গে মেলে না।
- স্থানীয় tool চালান বানানো credential আর স্পষ্ট endpoint দিয়ে, আর command চালানোর আগে endpoint যাচাই করুন।
- প্রতিটা test-এর ফলের সঙ্গে তারিখ, tool-এর version আর হুবহু command রাখুন।
- এই page-এর model-গুলো নিয়ম শেখার জন্য ব্যবহার করুন, একটা আসল account-এর test oracle হিসেবে নয়।
Key words
| Term | Meaning |
|---|---|
| Serverless | Lambda is a serverless compute service; you can run code without provisioning or managing servers |
| Event | A JSON formatted document that contains data for your function to process |
| Handler | The handler function is always the entry point to your code; when your function is invoked, Lambda runs this method |
| Context object | It contains information about the function invocation and execution environment |
| Trigger | Some services can invoke a function with each new event, and this is called a trigger |
| Event source mapping | What it is called when, for stream and queue-based services, Lambda invokes the function with batches of records |
| Synchronous invocation | You wait for the function to process the event and return a response |
| Asynchronous invocation | Lambda queues the event for processing and returns a response immediately |
| Execution role | An IAM role that grants the function permission to access AWS services and resources |
| Timeout | The maximum amount of time in seconds that a Lambda function can run; the default is 3 seconds, and you can adjust it up to a maximum value of 1,800 seconds |
| Execution environment | It provides a secure and isolated runtime environment; Lambda invokes your function in it |
| Cold start | What it is known as when Lambda has to initialize a new environment to carry out an invocation |
| Concurrency | The number of in-flight requests that a function is handling at the same time |
| Reserved concurrency | It reserves a portion of the concurrency of your account for a function; there is no charge for configuring it |
| Provisioned concurrency | It pre-initializes environment instances, which reduces cold start latencies; using it incurs additional charges |
| Throttling | What a function experiences if it runs out of available concurrency; it starts to drop requests |
| Table, item, attribute | A table is a collection of items, and each item is a collection of attributes |
| Primary key | It uniquely identifies each item in the table, so that no two items can have the same key |
| Partition key | DynamoDB uses its value as input to an internal hash function; the output determines the partition in which the item is stored |
| Sort key | All items with the same partition key value are stored together, in sorted order by sort key value |
| Global secondary index | An index with a partition key and sort key that can be different from those of the table |
| Local secondary index | An index that has the same partition key as the table, but a different sort key |
| Eventually consistent read | The default read model; a read might not reflect the results of a recently completed write |
| Strongly consistent read | If you set ConsistentRead to true, DynamoDB returns the most up-to-date data; it is not supported on a global secondary index or a stream |
| On-demand mode | The default and recommended throughput option for most workloads; it has pay-per-request pricing |
| Provisioned mode | You must specify the number of reads and writes per second that you require, and you are charged for the capacity that you provisioned |
| Time To Live (TTL) | A method for deleting items that are no longer relevant; the system might delete expired items at any time, typically within a few days after their expiration |
| DynamoDB local | The downloadable version of DynamoDB; it is intended for development and testing purposes only |
| Athena table | Its metadata tells Athena where the data is located in Amazon S3 and specifies the structure of the data; before querying data, a table must be registered in Athena |
| Partition (Athena) | If the WHERE clause names the partition, Athena scans the data only from that partition |
| Hive style partition | A partition whose data paths contain key value pairs connected by equal signs |
| MSCK REPAIR TABLE | The command that loads new Hive partitions; it works only with Hive-style partitions |
| State machine | A collection of states; the Amazon States Language, a JSON-based, structured language, defines it |
| State | Each step in a workflow is called a state |
| Execution | Instances of running workflows performing tasks are called executions |
| Standard workflow | Exactly-once workflow execution; it can run for up to one year |
| Express workflow | At-least-once workflow execution; it can run for up to five minutes, and one or more steps can potentially run more than once |
| Choice state | It adds conditional logic to a state machine; Default is the name of the state to transition to if no Choice Rule evaluates to true |
| TestState API | It accepts the definition of a state and executes it; it allows you to test a state without creating a state machine |
| Mock | It lets you test state logic without calling the actual service |
| Fake | A mock that takes shortcuts to simplify or speed up testing |
| Test case (unittest) | The individual unit of testing; it checks for a specific response to a particular set of inputs |