Skip to content
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
51 changes: 30 additions & 21 deletions .doc_gen/metadata/iam_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ iam_CreateAccessKey:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.createaccesskey
- iam.swift.basics.iam.CreateAccessKey
Bash:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -690,7 +690,7 @@ iam_DeleteAccessKey:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.deleteaccesskey
- iam.swift.basics.iam.DeleteAccessKey
Bash:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -1026,7 +1026,7 @@ iam_CreatePolicy:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.createpolicy
- iam.swift.basics.iam.CreatePolicy
Bash:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -1118,7 +1118,7 @@ iam_DeletePolicy:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.deletepolicy
- iam.swift.basics.iam.DeletePolicy
Bash:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -1216,7 +1216,7 @@ iam_ListPolicies:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.listpolicies.handler.listpolicies
- iam.swift.listpolicies.handler.ListPolicies
C++:
versions:
- sdk_version: 1
Expand Down Expand Up @@ -1304,7 +1304,7 @@ iam_GetPolicy:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.getpolicy.handler.getpolicy
- iam.swift.getpolicy.handler.GetPolicy
C++:
versions:
- sdk_version: 1
Expand Down Expand Up @@ -1426,7 +1426,7 @@ iam_AttachRolePolicy:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.attachrolepolicy.handler.attachrolepolicy
- iam.swift.attachrolepolicy.handler.AttachRolePolicy
JavaScript:
versions:
- sdk_version: 3
Expand Down Expand Up @@ -1543,7 +1543,7 @@ iam_ListAttachedRolePolicies:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.listattachedrolepolicies.handler.listattachedrolepolicies
- iam.swift.listattachedrolepolicies.handler.ListAttachedRolePolicies
services:
iam: {ListAttachedRolePolicies}
iam_DetachRolePolicy:
Expand Down Expand Up @@ -1645,7 +1645,7 @@ iam_DetachRolePolicy:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.detachrolepolicy
- iam.swift.basics.iam.DetachRolePolicy
Bash:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -1752,7 +1752,7 @@ iam_CreateRole:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.createrole.handler.createrole
- iam.swift.createrole.handler.CreateRole
JavaScript:
versions:
- sdk_version: 3
Expand Down Expand Up @@ -1860,7 +1860,7 @@ iam_ListRoles:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.listroles.handler.listroles
- iam.swift.listroles.handler.ListRoles
services:
iam: {ListRoles}
iam_GetRole:
Expand Down Expand Up @@ -1934,7 +1934,7 @@ iam_GetRole:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.getrole.handler.getrole
- iam.swift.getrole.handler.GetRole
services:
iam: {GetRole}
iam_DeleteRole:
Expand Down Expand Up @@ -1999,7 +1999,7 @@ iam_DeleteRole:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.deleterole
- iam.swift.basics.iam.DeleteRole
Bash:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -2114,7 +2114,7 @@ iam_ListRolePolicies:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.listrolepolicies.handler.listrolepolicies
- iam.swift.listrolepolicies.handler.ListRolePolicies
services:
iam: {ListRolePolicies}
iam_Scenario_RoleManagement:
Expand Down Expand Up @@ -2216,7 +2216,7 @@ iam_CreateUser:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.createuser.handler.createuser
- iam.swift.createuser.handler.CreateUser
Go:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -2360,7 +2360,7 @@ iam_DeleteUser:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.deleteuser
- iam.swift.basics.iam.DeleteUser
Bash:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -2411,6 +2411,15 @@ iam_GetUser:
snippet_tags:
- aws-cli.bash-linux.iam.errecho
- aws-cli.bash-linux.iam.GetUser
Swift:
versions:
- sdk_version: 1
github: swift/example_code/iam
excerpts:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.GetUser
services:
iam: {GetUser}
iam_ListUsers:
Expand Down Expand Up @@ -2484,7 +2493,7 @@ iam_ListUsers:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.listusers.handler.listusers
- iam.swift.listusers.handler.ListUsers
Go:
versions:
- sdk_version: 2
Expand Down Expand Up @@ -2693,7 +2702,7 @@ iam_PutUserPolicy:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.putuserpolicy
- iam.swift.basics.iam.PutUserPolicy
services:
iam: {PutUserPolicy}
iam_ListUserPolicies:
Expand Down Expand Up @@ -2753,7 +2762,7 @@ iam_DeleteUserPolicy:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.basics.iam.deleteuserpolicy
- iam.swift.basics.iam.DeleteUserPolicy
services:
iam: {DeleteUserPolicy}
iam_Scenario_UserPolicies:
Expand Down Expand Up @@ -3115,7 +3124,7 @@ iam_ListGroups:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.listgroups.handler.listgroups
- iam.swift.listgroups.handler.ListGroups
services:
iam: {ListGroups}
iam_CreateSAMLProvider:
Expand Down Expand Up @@ -3202,7 +3211,7 @@ iam_CreateServiceLinkedRole:
- description:
snippet_tags:
- iam.swift.import
- iam.swift.createservicelinkedrole.handler.createservicelinkedrole
- iam.swift.createservicelinkedrole.handler.CreateServiceLinkedRole
services:
iam: {CreateServiceLinkedRole}
iam_DeleteServiceLinkedRole:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ struct ExampleCommand: ParsableCommand {
/// example.
// snippet-start:[iam.swift.attachrolepolicy.command.runasync]
func runAsync() async throws {
let serviceHandler = await ServiceHandler()

do {
let serviceHandler = try await ServiceHandler()

_ = try await serviceHandler.attachRolePolicy(role: rolename, policyArn: policyArn)
} catch {
print("ERROR: runAsync:", dump(error))
throw error
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public class ServiceHandler {
/// - Returns: A new ``ServiceHandler`` object, ready to be called to
/// execute AWS operations.
// snippet-start:[iam.swift.attachrolepolicy.handler.init]
public init() async {
public init() async throws {
do {
client = try IAMClient(region: "us-east-1")
client = try await IAMClient()
} catch {
print("ERROR: ", dump(error, name: "Initializing Amazon IAM client"))
exit(1)
throw error
}
}
// snippet-end:[iam.swift.attachrolepolicy.handler.init]
Expand All @@ -47,7 +47,7 @@ public class ServiceHandler {
/// - role: The name of the role to attach the policy to.
/// - policyArn: The ARN of the policy to attach.
///
// snippet-start:[iam.swift.attachrolepolicy.handler.attachrolepolicy]
// snippet-start:[iam.swift.attachrolepolicy.handler.AttachRolePolicy]
public func attachRolePolicy(role: String, policyArn: String) async throws {
let input = AttachRolePolicyInput(
policyArn: policyArn,
Expand All @@ -56,9 +56,10 @@ public class ServiceHandler {
do {
_ = try await client.attachRolePolicy(input: input)
} catch {
print("ERROR: Attaching a role policy:", dump(error))
throw error
}
}
// snippet-end:[iam.swift.attachrolepolicy.handler.attachrolepolicy]
// snippet-end:[iam.swift.attachrolepolicy.handler.AttachRolePolicy]
}
// snippet-end:[iam.swift.attachrolepolicy.handler]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class AttachRolePolicyTests: XCTestCase {
super.setUp()

Task() {
AttachRolePolicyTests.serviceHandler = await ServiceHandler()
AttachRolePolicyTests.serviceHandler = try await ServiceHandler()
tdSem.signal()
}
tdSem.wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ struct ExampleCommand: ParsableCommand {
/// example.
// snippet-start:[iam.swift.createrole.command.runasync]
func runAsync() async throws {
let serviceHandler = await ServiceHandler()

do {
let serviceHandler = try await ServiceHandler()

// Get information about the user running this example. This user
// will be granted the new role.
let user = try await serviceHandler.getUser(name: nil)
Expand Down Expand Up @@ -63,6 +63,7 @@ struct ExampleCommand: ParsableCommand {
let roleID = try await serviceHandler.createRole(name: rolename, policyDocument: policyDocument)
print("Created new role \(rolename) with ID \(roleID)")
} catch {
print("ERROR: CreateRole runAsync:", dump(error))
throw error
}
}
Expand All @@ -88,4 +89,4 @@ struct Main {
}
}
// snippet-end:[iam.swift.createrole.main]
// snippet-end:[iam.swift.createrole.example]
// snippet-end:[iam.swift.createrole.example]
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ public class ServiceHandler {
public let client: IAMClient

/// Initialize and return a new ``ServiceHandler`` object, which is used
/// to drive the AWS calls used for the example.
/// to drive the AWS calls used for the example.
///
/// - Returns: A new ``ServiceHandler`` object, ready to be called to
/// execute AWS operations.
// snippet-start:[iam.swift.createrole.handler.init]
public init() async {
public init() async throws {
do {
client = try IAMClient(region: "us-east-1")
client = try await IAMClient()
} catch {
print("ERROR: ", dump(error, name: "Initializing Amazon IAM client"))
exit(1)
throw error
}
}
// snippet-end:[iam.swift.createrole.handler.init]
Expand All @@ -47,7 +47,7 @@ public class ServiceHandler {
/// - Parameter name: The name of the new IAM role.
///
/// - Returns: The ID of the newly created role.
// snippet-start:[iam.swift.createrole.handler.createrole]
// snippet-start:[iam.swift.createrole.handler.CreateRole]
public func createRole(name: String, policyDocument: String) async throws -> String {
let input = CreateRoleInput(
assumeRolePolicyDocument: policyDocument,
Expand All @@ -63,10 +63,11 @@ public class ServiceHandler {
}
return id
} catch {
print("ERROR: createRole:", dump(error))
throw error
}
}
// snippet-end:[iam.swift.createrole.handler.createrole]
// snippet-end:[iam.swift.createrole.handler.CreateRole]

/// Get information about the specified user
///
Expand All @@ -86,9 +87,10 @@ public class ServiceHandler {
}
return user
} catch {
print("ERROR: getUser:", dump(error))
throw error
}
}
// snippet-end:[iam.swift.createrole.handler.getuser]
}
// snippet-end:[iam.swift.createrole.handler]
// snippet-end:[iam.swift.createrole.handler]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class CreateRoleTests: XCTestCase {
super.setUp()

Task() {
CreateRoleTests.serviceHandler = await ServiceHandler()
CreateRoleTests.serviceHandler = try await ServiceHandler()
tdSem.signal()
}
tdSem.wait()
Expand Down
Loading
Loading