Skip to content

Add Glue scenario example for Swift #7487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .doc_gen/metadata/glue_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ glue_GetCrawler:
- description:
snippet_tags:
- rust.glue.get_crawler
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.GetCrawler
services:
glue: {GetCrawler}
glue_CreateCrawler:
Expand Down Expand Up @@ -241,6 +250,15 @@ glue_CreateCrawler:
- description:
snippet_tags:
- rust.glue.create_crawler
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.CreateCrawler
services:
glue: {CreateCrawler}
glue_StartCrawler:
Expand Down Expand Up @@ -329,6 +347,15 @@ glue_StartCrawler:
- description:
snippet_tags:
- rust.glue.start_crawler
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.StartCrawler
services:
glue: {StartCrawler}
glue_GetDatabase:
Expand Down Expand Up @@ -416,6 +443,15 @@ glue_GetDatabase:
- description:
snippet_tags:
- rust.glue.get_database
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.GetDatabase
services:
glue: {GetDatabase}
glue_GetTables:
Expand Down Expand Up @@ -494,6 +530,15 @@ glue_GetTables:
- description:
snippet_tags:
- rust.glue.get_tables
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.GetTables
services:
glue: {GetTables}
glue_CreateJob:
Expand Down Expand Up @@ -573,6 +618,15 @@ glue_CreateJob:
- description:
snippet_tags:
- rust.glue.create_job
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.CreateJob
services:
glue: {CreateJob}
glue_StartJobRun:
Expand Down Expand Up @@ -653,6 +707,15 @@ glue_StartJobRun:
- description:
snippet_tags:
- rust.glue.start_job_run
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.StartJobRun
services:
glue: {StartJobRun}
glue_ListJobs:
Expand Down Expand Up @@ -720,6 +783,15 @@ glue_ListJobs:
- description:
snippet_tags:
- rust.glue.list_jobs
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.ListJobs
services:
glue: {ListJobs}
glue_GetJobRuns:
Expand Down Expand Up @@ -859,6 +931,15 @@ glue_GetJobRun:
- description:
snippet_tags:
- rust.glue.get_job_run
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.GetJobRun
services:
glue: {GetJobRun}
glue_DeleteJob:
Expand Down Expand Up @@ -936,6 +1017,15 @@ glue_DeleteJob:
- description:
snippet_tags:
- rust.glue.delete_job
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.DeleteJob
services:
glue: {DeleteJob}
glue_DeleteTable:
Expand Down Expand Up @@ -1070,6 +1160,15 @@ glue_DeleteDatabase:
- description:
snippet_tags:
- rust.glue.delete_database
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.DeleteDatabase
services:
glue: {DeleteDatabase}
glue_DeleteCrawler:
Expand Down Expand Up @@ -1147,6 +1246,15 @@ glue_DeleteCrawler:
- description:
snippet_tags:
- rust.glue.delete_crawler
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description:
snippet_tags:
- swift.glue.import
- swift.glue.DeleteCrawler
services:
glue: {DeleteCrawler}
glue_GetDatabases:
Expand Down Expand Up @@ -1333,6 +1441,17 @@ glue_Scenario_GetStartedCrawlersJobs:
- rust.glue.delete_table
- rust.glue.delete_database
- rust.glue.delete_crawler
Swift:
versions:
- sdk_version: 1
github: swift/example_code/glue
excerpts:
- description: The <code>Package.swift</code> file.
snippet_tags:
- swift.glue.scenario.package
- description: The Swift code file, <code>entry.swift</code>.
snippet_tags:
- swift.glue.scenario
services:
glue: {GetCrawler, CreateCrawler, StartCrawler, GetDatabase, GetDatabases, GetTables, CreateJob, StartJobRun, ListJobs,
GetJob, GetJobRuns, GetJobRun, DeleteJob, DeleteTable, DeleteDatabase, DeleteCrawler}
123 changes: 123 additions & 0 deletions swift/example_code/glue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# AWS Glue code examples for the SDK for Swift

## Overview

Shows how to use the AWS SDK for Swift to work with AWS Glue.

<!--custom.overview.start-->
<!--custom.overview.end-->

_AWS Glue is a scalable, serverless data integration service that makes it easy to discover, prepare, and combine data for analytics, machine learning, and application development._

## ⚠ Important

* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
* Running the tests might result in charges to your AWS account.
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).

<!--custom.important.start-->
<!--custom.important.end-->

## Code examples

### Prerequisites

For prerequisites, see the [README](../../README.md#Prerequisites) in the `swift` folder.


<!--custom.prerequisites.start-->
<!--custom.prerequisites.end-->

### Basics

Code examples that show you how to perform the essential operations within a service.

- [Learn the basics](scenario/Package.swift)


### Single actions

Code excerpts that show you how to call individual service functions.

- [CreateCrawler](scenario/Sources/entry.swift#L134)
- [CreateJob](scenario/Sources/entry.swift#L275)
- [DeleteCrawler](scenario/Sources/entry.swift#L178)
- [DeleteDatabase](scenario/Sources/entry.swift#L463)
- [DeleteJob](scenario/Sources/entry.swift#L349)
- [GetCrawler](scenario/Sources/entry.swift#L220)
- [GetDatabase](scenario/Sources/entry.swift#L399)
- [GetJobRun](scenario/Sources/entry.swift#L557)
- [GetTables](scenario/Sources/entry.swift#L422)
- [ListJobs](scenario/Sources/entry.swift#L312)
- [StartCrawler](scenario/Sources/entry.swift#L198)
- [StartJobRun](scenario/Sources/entry.swift#L518)


<!--custom.examples.start-->
<!--custom.examples.end-->

## Run the examples

### Instructions

To build any of these examples from a terminal window, navigate into its
directory, then use the following command:

```
$ swift build
```

To build one of these examples in Xcode, navigate to the example's directory
(such as the `ListUsers` directory, to build that example). Then type `xed.`
to open the example directory in Xcode. You can then use standard Xcode build
and run commands.

<!--custom.instructions.start-->
<!--custom.instructions.end-->


#### Learn the basics

This example shows you how to do the following:

- Create a crawler that crawls a public Amazon S3 bucket and generates a database of CSV-formatted metadata.
- List information about databases and tables in your AWS Glue Data Catalog.
- Create a job to extract CSV data from the S3 bucket, transform the data, and load JSON-formatted output into another S3 bucket.
- List information about job runs, view transformed data, and clean up resources.

<!--custom.basic_prereqs.glue_Scenario_GetStartedCrawlersJobs.start-->
<!--custom.basic_prereqs.glue_Scenario_GetStartedCrawlersJobs.end-->


<!--custom.basics.glue_Scenario_GetStartedCrawlersJobs.start-->
<!--custom.basics.glue_Scenario_GetStartedCrawlersJobs.end-->


### Tests

⚠ Running tests might result in charges to your AWS account.


To find instructions for running these tests, see the [README](../../README.md#Tests)
in the `swift` folder.



<!--custom.tests.start-->
<!--custom.tests.end-->

## Additional resources

- [AWS Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/what-is-glue.html)
- [AWS Glue API Reference](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api.html)
- [SDK for Swift AWS Glue reference](https://sdk.amazonaws.com/swift/api/awsglue/latest/documentation/awsglue)

<!--custom.resources.start-->
<!--custom.resources.end-->

---

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
48 changes: 48 additions & 0 deletions swift/example_code/glue/scenario/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// swift-tools-version: 5.9
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// (swift-tools-version has two lines here because it needs to be the first
// line in the file, but it should also appear in the snippet below)
//
// snippet-start:[swift.glue.scenario.package]
// swift-tools-version: 5.9
//
// The swift-tools-version declares the minimum version of Swift required to
// build this package.

import PackageDescription

let package = Package(
name: "glue-scenario",
// Let Xcode know the minimum Apple platforms supported.
platforms: [
.macOS(.v13),
.iOS(.v15)
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(
url: "https://github.com/awslabs/aws-sdk-swift",
from: "1.0.0"),
.package(
url: "https://github.com/apple/swift-argument-parser.git",
branch: "main"
)
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products
// from dependencies.
.executableTarget(
name: "glue-scenario",
dependencies: [
.product(name: "AWSGlue", package: "aws-sdk-swift"),
.product(name: "AWSS3", package: "aws-sdk-swift"),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
path: "Sources")

]
)
// snippet-end:[swift.glue.scenario.package]
Loading
Loading