AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-07-01 · Documentation low

File: code-library/latest/ug/glue_example_glue_CreateCrawler_section.md

Summary

Added Swift SDK implementation for creating AWS Glue crawlers with error handling and documentation

Security assessment

New code example demonstrates standard API usage without addressing security vulnerabilities. While IAM roles and S3 paths are mentioned, there's no specific security guidance added. The changes represent routine feature documentation expansion rather than security-focused content

Diff

diff --git a/code-library/latest/ug/glue_example_glue_CreateCrawler_section.md b/code-library/latest/ug/glue_example_glue_CreateCrawler_section.md
index 198e81962..d057e60f9 100644
--- a//code-library/latest/ug/glue_example_glue_CreateCrawler_section.md
+++ b//code-library/latest/ug/glue_example_glue_CreateCrawler_section.md
@@ -487,0 +488,63 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
+Swift
+    
+
+**SDK for Swift**
+    
+
+###### Note
+
+There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/glue#code-examples). 
+    
+    
+    import AWSClientRuntime
+    import AWSGlue
+    
+        /// Create a new AWS Glue crawler.
+        /// 
+        /// - Parameters:
+        ///   - glueClient: An AWS Glue client to use for the crawler.
+        ///   - crawlerName: A name for the new crawler.
+        ///   - iamRole: The name of an Amazon IAM role for the crawler to use.
+        ///   - s3Path: The path of an Amazon S3 folder to use as a target location.
+        ///   - cronSchedule: A `cron` schedule indicating when to run the crawler.
+        ///   - databaseName: The name of an AWS Glue database to operate on.
+        ///
+        /// - Returns: `true` if the crawler is created successfully, otherwise `false`.
+        func createCrawler(glueClient: GlueClient, crawlerName: String, iamRole: String,
+                           s3Path: String, cronSchedule: String, databaseName: String) async -> Bool {
+            let s3Target = GlueClientTypes.S3Target(path: s3url)
+            let targetList = GlueClientTypes.CrawlerTargets(s3Targets: [s3Target])
+    
+            do {
+                _ = try await glueClient.createCrawler(
+                    input: CreateCrawlerInput(
+                        databaseName: databaseName,
+                        description: "Created by the AWS SDK for Swift Scenario Example for AWS Glue.",
+                        name: crawlerName,
+                        role: iamRole,
+                        schedule: cronSchedule,
+                        tablePrefix: tablePrefix,
+                        targets: targetList
+                    )
+                )
+            } catch _ as AlreadyExistsException {
+                print("*** A crawler named \"\(crawlerName)\" already exists.")
+                return false
+            } catch _ as OperationTimeoutException {
+                print("*** The attempt to create the AWS Glue crawler timed out.")
+                return false
+            } catch {
+                print("*** An unexpected error occurred creating the AWS Glue crawler: \(error.localizedDescription)")
+                return false
+            }
+    
+            return true
+        }
+    
+    
+
+  * For API details, see [CreateCrawler](https://sdk.amazonaws.com/swift/api/awsglue/latest/documentation/awsglue/glueclient/createcrawler\(input:\)) in _AWS SDK for Swift API reference_. 
+
+
+
+