AWS Security ChangesHomeSearch

AWS quick medium security documentation change

Service: quick · 2026-03-22 · Security-related medium

File: quick/latest/userguide/actions-code.md

Summary

Expanded documentation for code actions with detailed sections on types, usage guidelines, security restrictions, approved libraries, and example use cases

Security assessment

Added explicit security documentation about restricted Python environment (RestrictedPython), approved library whitelist, and prohibited imports. This demonstrates hardening against code injection/unsafe operations by limiting execution capabilities.

Diff

diff --git a/quick/latest/userguide/actions-code.md b/quick/latest/userguide/actions-code.md
index 6f10092a5..9fb259975 100644
--- a//quick/latest/userguide/actions-code.md
+++ b//quick/latest/userguide/actions-code.md
@@ -4,0 +5,2 @@
+Single Line ExpressionsCustom Code Block
+
@@ -7 +9,270 @@
-  * **Single-line expression** \- Runs a one-line Python expression. Used to perform simple operations that require no output such as adding items to a list (list.append) or updating dictionary values (dictionary.update).
+Code actions in Quick Automate let you implement custom logic using Python code blocks, going beyond what standard automation actions support. They are well-suited for complex data transformations and calculations, and run within a restricted Python environment to maintain security.
+
+**Two Types of Code Actions:**
+
+  * **Single Line Expressions:** Quick, one-line operations that modify variables without returning values
+
+  * **Custom Code Blocks:** Multi-line Python functions for complex logic with parameters and return values
+
+
+
+
+**When to use code actions:**
+
+Use code blocks when you need to:
+
+  * Perform complex data transformations not available in standard actions
+
+  * Implement custom business logic or calculations
+
+  * Process or manipulate data structures (lists, dictionaries, JSON)
+
+  * Work with dates, times, and time zones in custom ways
+
+  * Parse or format strings with complex patterns
+
+  * Optimize automation performance by consolidating multiple actions into one code block
+
+
+
+
+**When not to use code actions:**
+
+Avoid code blocks when:
+
+  * A standard automation action already exists for your use case
+
+  * The operation is simple enough for built-in actions
+
+  * You need to interact with external APIs (use REST API integration instead)
+
+  * You need to access file systems or databases (use appropriate integrations)
+
+
+
+
+**How to Access code actions:**
+
+Code blocks are available through multiple interfaces:
+
+  * **Actions Panel (Recommended):**
+
+    * Open your automation in the automation builder
+
+    * Click on the Actions Panel on the right side
+
+    * Locate "Custom Code Block" under the Code Actions section
+
+    * Drag and drop the code block into your automation workflow
+
+  * **Build with Assistant:**
+
+    * Available during plan generation when the assistant determines custom code is needed
+
+    * The assistant automatically suggests code blocks for complex operations
+
+    * You can request code blocks by describing your custom logic needs
+
+
+
+
+**Actions available:**
+
+## Single Line Expressions
+
+Single Line Expressions execute one-line Python statements that perform operations without returning a value. They are ideal for quick modifications to existing variables like appending to lists, updating dictionaries, or performing simple calculations that modify state.
+
+**Properties:**
+
+  * Expression (required): The Python expression to execute (e.g., "my_list.append('new item')")
+
+
+
+
+**Examples:**
+
+  * **Appending to list**
+    
+        my_list.append("1")
+    my_list.append(new_item)
+
+  * **Removing List Items**
+    
+        task_list.remove(completed_task)
+
+
+
+
+## Custom Code Block
+
+Custom Code Blocks are multi-line Python functions that execute complex logic, accept parameters, and return values. They are the fallback option when standard automation actions and Single Line Expressions are not sufficient for your needs.
+
+**Properties:**
+
+  * **Function Title (required)** : Name identifier for the code block (e.g., "Calculate_Total")
+
+  * **Function (required):** Python code block that contains your custom logic.
+
+    * Step 1: Define Parameters
+
+      * Click the "Edit" button to open the code editor
+
+      * In the Parameter panel, click "Add" to create new parameters
+
+      * Enter parameter names that match your automation variables
+
+      * Parameters are available as function arguments
+
+    * Step 2: Write Your Python Code
+
+  * **Return Value (optional):** Variable name to store the function's output
+
+    * Follow the required code block structure (see below)
+
+    * Implement your custom logic within the function
+
+    * Use only approved libraries and built-in functions
+
+    * Include a return statement if you need to output data
+
+
+
+
+**Code Block Structure**
+
+All code blocks must follow this specific format:
+    
+    
+    @code_block()
+    def your_function_name(parameter1, parameter2, parameter3):
+    -------------------------------------------------------------------------------------
+        """
+        Optional: Add a docstring describing what your function does
+        """
+        # Your custom logic here
+        result = parameter1 + parameter2 + parameter3
+    
+        return result
+
+**Built-in Python Functions and Imports**
+
+All standard Python built-in functions are available without imports (len, str, int, etc.)
+
+**Approved Standard Libraries (Security Restricted)**
+
+Code blocks can ONLY import these standard libraries:
+
+  * `base64` \- Base64 encoding/decoding
+
+  * `datetime` \- Date and time operations
+
+  * `json` \- JSON parsing and generation
+
+  * `math` \- Mathematical functions
+
+  * `re` \- Regular expressions
+
+  * `zoneinfo` \- Time zone handling
+
+
+
+
+###### Note
+
+  * Cannot import standard libraries other than the ones listed above.
+
+  * Cannot install or import third-party libraries. `pip install` is not supported in code blocks.
+
+
+
+
+**Limitations**
+
+  * Restricted Python environment with limited library access. The execution environment is based on RestrictedPython, a subset of Python 3.10.
+
+  * Code blocks cannot invoke other code blocks or actions
+
+
+
+
+**Best Practices**
+