Skip to content
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

Bind ECS Environment Creds Provider #286

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,34 @@ extension CredentialsProvider.Source {
///
/// If both relative uri and absolute uri are set, relative uri has higher priority.
/// Token is used in auth header but only for absolute uri.
/// While above information is used in request only, endpoint info is needed when creating ecs provider to initiate the connection
/// manager, more specifically, host and http scheme (tls or not) from endpoint are needed.
///
/// - Parameters:
/// - bootstrap: Connection bootstrap to use for any network connections made while sourcing credentials
/// - tlsContext: Client TLS context to use when querying STS web identity provider.
/// If set, port 443 is used. If NULL, port 80 is used.
/// - shutdownCallback: (Optional) shutdown callback
/// - Returns: `CredentialsProvider`
/// - Throws: CommonRuntimeError.crtError
public static func `ecsEnvironment`(bootstrap: ClientBootstrap,
tlsContext: TLSContext,
shutdownCallback: ShutdownCallback? = nil) -> Self {
Self {
let shutdownCallbackCore = ShutdownCallbackCore(shutdownCallback)
var ecsOptions = aws_credentials_provider_ecs_environment_options()
ecsOptions.tls_ctx = tlsContext.rawValue
ecsOptions.bootstrap = bootstrap.rawValue
ecsOptions.shutdown_options = shutdownCallbackCore.getRetainedCredentialProviderShutdownOptions()

guard let provider: UnsafeMutablePointer<aws_credentials_provider> =
aws_credentials_provider_new_ecs_from_environment(allocator.rawValue, &ecsOptions) else {
shutdownCallbackCore.release()
throw CommonRunTimeError.crtError(CRTError.makeFromLastError())
}
return provider
}
}

/// Credential Provider that sources credentials from ECS container metadata
/// - Parameters:
/// - bootstrap: Connection bootstrap to use for any network connections made while sourcing credentials
/// - tlsContext: (Optional) Client TLS context to use when querying STS web identity provider.
Expand Down
Loading