AWS Security ChangesHomeSearch

AWS documentdb documentation change

Service: documentdb · 2026-03-31 · Documentation low

File: documentdb/latest/developerguide/month.md

Summary

Added new documentation page for the $month operator in Amazon DocumentDB, including usage examples, parameters, and code samples in MongoDB Shell, Node.js, and Python

Security assessment

This change adds standard documentation for a date aggregation operator ($month) with example usage. The code examples include TLS connection parameters (tls=true, tlsCAFile=global-bundle.pem) which are standard security practices for DocumentDB connections, but this is not new security documentation - it's just showing standard secure connection patterns that are already documented elsewhere. There is no evidence this addresses a specific security vulnerability or incident.

Diff

diff --git a/documentdb/latest/developerguide/month.md b/documentdb/latest/developerguide/month.md
index 8b1378917..8fb97f9eb 100644
--- a//documentdb/latest/developerguide/month.md
+++ b//documentdb/latest/developerguide/month.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#month "Open PDF")
@@ -1,0 +3,154 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $month
+
+The `$month` operator in Amazon DocumentDB returns the month of a date as a number between 1 and 12. This operator is useful for extracting the month component from a date field and performing date-based aggregations and analyses.
+
+**Parameters**
+
+  * `date_expression`: This is the expression or field that contains the date or timestamp from which you want to extract the month.
+
+
+
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$month` operator to extract the month from a date field and group the data by month.
+
+**Create sample documents**
+    
+    
+    db.sales.insert([
+      { product: "abc123", price: 10.99, date: new Date("2022-01-15") },
+      { product: "def456", price: 15.50, date: new Date("2022-02-28") },
+      { product: "ghi789", price: 8.25, date: new Date("2022-03-10") },
+      { product: "jkl012", price: 12.75, date: new Date("2022-04-05") },
+      { product: "mno345", price: 18.99, date: new Date("2022-05-20") }
+    ]);
+
+**Query example**
+    
+    
+    db.sales.aggregate([
+      { $group: { 
+          _id: { month: { $month: "$date" } },
+          totalSales: { $sum: "$price" }
+        }},
+      { $sort: { "_id.month": 1 } }
+    ]);
+
+**Output**
+    
+    
+    [
+      { _id: { month: 1 }, totalSales: 10.99 },
+      { _id: { month: 2 }, totalSales: 15.5 },
+      { _id: { month: 3 }, totalSales: 8.25 },
+      { _id: { month: 4 }, totalSales: 12.75 },
+      { _id: { month: 5 }, totalSales: 18.99 }
+    ]
+
+## Code examples
+
+To view a code example for using the `$month` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function groupSalesByMonth() {
+      const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false');
+    
+      try {
+        await client.connect();
+        const db = client.db('test');
+        const collection = db.collection('sales');
+    
+        const pipeline = [
+          {
+            $group: {
+              _id: { month: { $month: "$date" } },
+              totalSales: { $sum: "$price" }
+            }
+          },
+          {
+            $sort: { "_id.month": 1 }
+          }
+        ];
+    
+        const results = await collection.aggregate(pipeline).toArray();
+    
+        console.dir(results, { depth: null });
+    
+      } finally {
+        await client.close();
+      }
+    }
+    
+    groupSalesByMonth().catch(console.error);
+    
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def group_sales_by_month():
+      
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+    
+        try:
+            db = client.test
+            collection = db.sales
+    
+            pipeline = [
+                {
+                    "$group": {
+                        "_id": { "$month": "$date" }, 
+                        "totalSales": { "$sum": "$price" }  
+                    }
+                },
+                {
+                    "$sort": { "_id": 1 } 
+                }
+            ]
+    
+            results = collection.aggregate(pipeline)
+    
+            for doc in results:
+                print(doc)
+    
+        except Exception as e:
+            print(f"An error occurred: {e}")
+    
+        finally:
+            client.close()
+    
+    group_sales_by_month()
+
+![Warning](https://d1ge0kk1l5kms0.cloudfront.net/images/G/01/webservices/console/warning.png) **Javascript is disabled or is unavailable in your browser.**
+
+To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.
+
+[Document Conventions](/general/latest/gr/docconventions.html)
+
+$mod
+
+$multiply
+
+Did this page help you? - Yes
+
+Thanks for letting us know we're doing a good job!
+
+If you've got a moment, please tell us what we did right so we can do more of it.
+
+Did this page help you? - No
+
+Thanks for letting us know this page needs work. We're sorry we let you down.
+
+If you've got a moment, please tell us how we can make the documentation better.