AWS Security ChangesHomeSearch

AWS code-library documentation change

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

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

Summary

Added Swift SDK example for CreateSecurityGroup API

Security assessment

Routine documentation update showing security group creation without demonstrating specific security configurations or vulnerabilities. Security groups are security features but no specific issue is addressed.

Diff

diff --git a/code-library/latest/ug/ec2_example_ec2_CreateSecurityGroup_section.md b/code-library/latest/ug/ec2_example_ec2_CreateSecurityGroup_section.md
index d515737eb..aa822bf89 100644
--- a//code-library/latest/ug/ec2_example_ec2_CreateSecurityGroup_section.md
+++ b//code-library/latest/ug/ec2_example_ec2_CreateSecurityGroup_section.md
@@ -985,0 +986,43 @@ 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/ec2#code-examples). 
+    
+    
+    import AWSEC2
+    
+        /// Create a new security group.
+        /// 
+        /// - Parameters:
+        ///   - groupName: The name of the group to create.
+        ///   - groupDescription: A description of the new security group.
+        ///
+        /// - Returns: The ID string of the new security group.
+        func createSecurityGroup(name groupName: String, description groupDescription: String) async -> String? {
+            do {
+                let output = try await ec2Client.createSecurityGroup(
+                    input: CreateSecurityGroupInput(
+                        description: groupDescription,
+                        groupName: groupName
+                    )
+                )
+    
+                return output.groupId
+            } catch {
+                print("*** Error creating the security group: \(error.localizedDescription)")
+                return nil
+            }
+        }
+    
+    
+
+  * For API details, see [CreateSecurityGroup](https://sdk.amazonaws.com/swift/api/awsec2/latest/documentation/awsec2/ec2client/createsecuritygroup\(input:\)) in _AWS SDK for Swift API reference_. 
+
+
+
+