AWS
Index
AWS.IMDSAWS.DEFAULT_BACKENDAWS.AWSCredentialsAWS.AWSCredentialsAWS.AbstractBackendAWS.DownloadsBackendAWS.FeatureSetAWS.HTTPBackendAWS.JSONServiceAWS.QueryServiceAWS.RestJSONServiceAWS.RestXMLServiceAWS.assume_roleAWS.assume_roleAWS.aws_account_numberAWS.aws_get_profile_settingsAWS.aws_get_regionAWS.aws_user_arnAWS.check_credentialsAWS.credentials_from_webtokenAWS.dot_aws_configAWS.dot_aws_credentialsAWS.ec2_instance_credentialsAWS.ecs_instance_credentialsAWS.env_var_credentialsAWS.external_process_credentialsAWS.global_aws_configAWS.global_aws_configAWS.localhost_is_ec2AWS.set_user_agentAWS.sso_credentialsAWS.@service
Documentation
AWS.@service — Macro@service service_id feature=val...
@service service_id as module_name feature=val...Include the high-level service wrapper for service_id in a module. The module name will match the service_id or can be specified using the as syntax.
An optional list of features can be specified for this service include. See FeatureSet for a list of available features.
The module name cannot match the binding name used for the low-level API. The low-level API binding name is equivalent to the lowercase service_id where spaces are replace with underscores (e.g. the service ID Secrets_Manager can be used but secrets_manager cannot).
Extended Help
Arguments
service_id::Symbol: The high-level API wrappers service ID to include in the current module. Note the service ID is case insensitive.module_name::Symbol: The name of the module containing the high-level API wrappers. Useful to avoiding name conflicts. Defaults to usingservice_id.features=val...: A list of features to enable/disable for this high-level API include. SeeFeatureSetfor a list of available features.
Returns
Module: The module containging the high-level service API wrapper functions.
Examples
julia> using AWS: @service
julia> @service STS
STS
julia> STS.get_caller_identity()
OrderedCollections.LittleDict{Union{String, Symbol}, Any, Vector{Union{String, Symbol}}, Vector{Any}} with 2 entries:
"GetCallerIdentityResult" => LittleDict{Union{String, Symbol}, Any, Vector{Un…
"ResponseMetadata" => LittleDict{Union{String, Symbol}, Any, Vector{Un…Specify the module name and use a feature:
julia> @service STS as SecurityTokenService use_response_type = true
SecurityTokenService
julia> SecurityTokenService.get_caller_identity()
AWS.Response: application/xml interpreted as:
OrderedCollections.LittleDict{Union{String, Symbol}, Any, Vector{Union{String, Symbol}}, Vector{Any}} with 2 entries:
"GetCallerIdentityResult" => LittleDict{Union{String, Symbol}, Any, Vector{Un…
"ResponseMetadata" => LittleDict{Union{String, Symbol}, Any, Vector{Un…Service IDs are case insensitive:
julia> @service Secrets_Manager
Secrets_Manager
julia> @service SECRETS_MANAGER
SECRETS_MANAGER
julia> @service sECRETS_MANAGER
sECRETS_MANAGERUsing an all lowercase service ID does not work as it conflicts with the low-level API binding name:
julia> @service sts
WARNING: import of AWSServices.sts into sts conflicts with an existing identifier; ignored.
sts
julia> sts.get_caller_identity()
ERROR: MethodError: objects of type Module are not callable
[...]AWS.AWSCredentials — TypeAWSCredentialsWhen you interact with AWS, you specify your AWS Security Credentials to verify who you are and whether you have permission to access the resources that you are requesting. AWS uses the security credentials to authenticate and authorize your requests. The fields access_key_id and secret_key hold the access keys used to authenticate API requests (see Creating, Modifying, and Viewing Access Keys). Temporary Security Credentials require the extra session token field. The user_arn and account_number fields are used to cache the result of the aws_user_arn and aws_account_number functions.
AWS.jl searches for credentials in multiple locations and stops once any credentials are found. The credential preference order mostly mirrors the AWS CLI and is as follows:
- Credentials or a profile passed directly to the
AWSCredentials - Environment variables
- Web Identity
- AWS Single Sign-On (SSO) provided via the AWS configuration file
- AWS credentials file (e.g. "~/.aws/credentials")
- External process set via
credential_processin the AWS configuration file - AWS configuration file set via
aws_access_key_idin the AWS configuration file - Amazon ECS container credentials
- Amazon EC2 instance metadata
Once the credentials are found, the method by which they were accessed is stored in the renew field and the DateTime at which they will expire is stored in the expiry field. This allows the credentials to be refreshed as needed using check_credentials. If renew is set to nothing, no attempt will be made to refresh the credentials. Any renewal function is expected to return nothing on failure or a populated AWSCredentials object on success. The renew field of the returned AWSCredentials will be discarded and does not need to be set.
To specify the profile to use from ~/.aws/credentials, do, for example, AWSCredentials(profile="profile-name").
AWS.AWSCredentials — MethodAWSCredentials(; profile=nothing) -> Union{AWSCredentials, Nothing}Create an AWSCredentials object, given a provided profile (if not provided "default" will be used).
Checks credential locations in the order: 1. Environment Variables 2. ~/.aws/credentials 3. ~/.aws/config 4. EC2 or ECS metadata
Keywords
profile::AbstractString: Specific profile used to search for AWSCredentials
Throws
error("Can't find AWS Credentials"): AWSCredentials could not be found
AWS.JSONService — Type(service::JSONService)(
operation::String, args::AbstractDict{String, <:Any}=Dict{String, Any}();
aws_config::AbstractAWSConfig=aws_config
)Perform a JSON request to AWS.
Arguments
operation::String: Name of the operation to performargs::AbstractDict{String, <:Any}: Additional arguments to be included in the request
Keywords
aws_config::AbstractAWSConfig: AWSConfig containing credentials and other information for fulfilling the request, default value is the global configurationfeature_set::FeatureSet: Specifies opt-in functionality for this specific API call.
Returns
TupleorDict: Ifreturn_headersis passed in throughargsa Tuple containing the headers and response will be returned, otherwise just aDict
AWS.QueryService — Type(service::QueryService)(
operation::String, args::AbstractDict{String, <:Any}=Dict{String, Any}();
aws_config::AbstractAWSConfig=aws_config
)Perform a Query request to AWS.
Arguments
operation::String:args::AbstractDict{String, <:Any}: Additional arguments to be included in the request
Keywords
aws_config::AbstractAWSConfig: AWSConfig containing credentials and other information for fulfilling the request, default value is the global configurationfeature_set::FeatureSet: Specifies opt-in functionality for this specific API call.
Returns
TupleorDict: Ifreturn_headersis passed in throughargsa Tuple containing the headers and response will be returned, otherwise just aDict
AWS.RestJSONService — Type(service::RestJSONService)(
request_method::String, request_uri::String, args::AbstractDict{String, <:Any}=Dict{String, String}();
aws_config::AbstractAWSConfig=aws_config
)Perform a RestJSON request to AWS.
Arguments
request_method::String: RESTful request type, e.g.:GET,HEAD,PUT, etc.request_uri::String: AWS URI for the endpointargs::AbstractDict{String, <:Any}: Additional arguments to be included in the request
Keywords
aws_config::AbstractAWSConfig: AWSConfig containing credentials and other information for fulfilling the request, default value is the global configurationfeature_set::FeatureSet: Specifies opt-in functionality for this specific API call.
Returns
TupleorDict: Ifreturn_headersis passed in throughargsa Tuple containing the headers and response will be returned, otherwise just aDict
AWS.RestXMLService — Type(service::RestXMLService)(
request_method::String, request_uri::String, args::AbstractDict{String, <:Any}=Dict{String, String}();
aws_config::AbstractAWSConfig=aws_config
)Perform a RestXML request to AWS.
Arguments
request_method::String: RESTful request type, e.g.:GET,HEAD,PUT, etc.request_uri::String: AWS URI for the endpointargs::AbstractDict{String, <:Any}: Additional arguments to be included in the request
Keywords
aws_config::AbstractAWSConfig: AWSConfig containing credentials and other information for fulfilling the request, default value is the global configurationfeature_set::FeatureSet: Specifies opt-in functionality for this specific API call.
Returns
TupleorDict: Ifreturn_headersis passed in throughargsa Tuple containing the headers and response will be returned, otherwise just aDict
AWS.assume_role — Methodassume_role(principal::AbstractAWSConfig, role; kwargs...) -> AbstractAWSConfigAssumes the IAM role via temporary credentials via the principal entity. The principal entity must be included in the trust policy of the role.
Role chaining must be manually specified by multiple assume_role calls (e.g. "role-a" has permissions to assume "role-b": assume_role(assume_role(AWSConfig(), "role-a"), "role-b")).
Arguments
principal::AbstractAWSConfig: The AWS configuration and credentials of the principal entity (user or role) performing thests:AssumeRoleaction.role::AbstractString: The AWS IAM role to assume. Either a full role ARN or just the role name. If only the role name is specified the role will be assumed to reside in the same account used in theprincipalargument.
Keywords
duration::Integer(optional): Role session duration in seconds.mfa_serial::AbstractString(optional): The identification number of the MFA device that is associated with the user making theAssumeRoleAPI call. Either a serial number for a hardware device ("GAHT12345678") or an ARN for a virtual device ("arn:aws:iam::123456789012:mfa/user"). When specified a MFA token must be provided viatokenor an interactive prompt.token::AbstractString(optional): The value provided by the MFA device. Only can be specified whenmfa_serialis set.session_name::AbstractString(optional): The unique role session name associated with this API request.
AWS.assume_role — Methodassume_role(role; kwargs...) -> FunctionCreate a function that assumes the IAM role via a deferred principal entity, i.e. a function equivalent to principal -> assume_role(principal, role; kwargs...). Useful for role chaining.
Examples
Assume "role-a" which in turn assumes "role-b":
AWSConfig() |> assume_role("role-a") |> assume_role("role-b")AWS.aws_account_number — Methodaws_account_number(aws::AWSConfig) -> StringRetrieve the AWS account number from the AWSConfig, if not present query STS to update the AWS account number.
Arguments
aws::AWSConfig: AWSConfig used to retrieve the AWS account number
AWS.aws_get_profile_settings — Methodaws_get_profile_settings(profile::AbstractString, ini::Inifile) -> DictReturn a Dict containing all of the settings for the specified profile.
Arguments
profile::AbstractString: Profile to retrieve settings fromini::Inifile: Configuration file read the settings from
AWS.aws_get_region — Methodaws_get_region(; profile=nothing, config=nothing, default="us-east-1")Determine the current AWS region that should be used for AWS requests. The order of precedence mirrors what is used by the AWS CLI:
- Environment variable:
AWS_REGION. - Environment variable:
AWS_DEFAULT_REGION - AWS configuration file:
regionas specified by theprofilein the configuration file, typically "~/.aws/config". - Instance metadata service on an Amazon EC2 instance that has an IAM role configured.
- Default region: use the specified
default, typically "us-east-1".
Keywords
profile: Name of the AWS configuration profile, if any. Defaults tonothingwhich falls back to usingAWS._aws_get_profile()config: AWS configuration loaded as anInifileor a path to a configuration file. Defaults tonothingwhich falls back to usingdot_aws_config_file()default: The region to return if no high-precedence was found. Can be useful to set this tonothingif you want to know that no current AWS region was defined.
AWS.aws_user_arn — Methodaws_user_arn(aws::AWSConfig) -> StringRetrieve the User ARN from the AWSConfig, if not present query STS to update the user_arn.
Arguments
aws::AWSConfig: AWSConfig used to retrieve the user arn
AWS.check_credentials — Methodcheck_credentials(
aws_creds::AWSCredentials, force_refresh::Bool=false
) -> AWSCredentialsChecks current AWSCredentials, refreshing them if they are soon to expire. If force_refresh is true the credentials will be renewed immediately
Arguments
aws_creds::AWSCredentials: AWSCredentials to be checked / refreshed
Keywords
force_refresh::Bool=false:trueto refresh the credentials
Throws
error("Can't find AWS credentials!"): If no credentials can be found
AWS.credentials_from_webtoken — Methodcredentials_from_webtoken()Assume role via web identity. https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html#cli-configure-role-oidc
AWS.dot_aws_config — Functiondot_aws_config(profile=nothing) -> Union{AWSCredentials, Nothing}Retrieve AWSCredentials from the AWS CLI configuration file. The configuration file defaults to "~/.aws/config" but can be specified using the env variable AWS_CONFIG_FILE. When no credentials are found for the given profile then the associated source_profile will be used to recursively look up credentials of source profiles. If still no credentials can be found then nothing will be returned.
Arguments
profile: Specific profile used to get AWSCredentials, default isnothing
AWS.dot_aws_credentials — Functiondot_aws_credentials(profile=nothing) -> Union{AWSCredentials, Nothing}Retrieve AWSCredentials from the AWS CLI credentials file. The credential file defaults to "~/.aws/credentials" but can be specified using the env variable AWS_SHARED_CREDENTIALS_FILE.
Arguments
profile: Specific profile used to get AWSCredentials, default isnothing
AWS.ec2_instance_credentials — Methodec2_instance_credentials(profile::AbstractString) -> AWSCredentialsParse the EC2 metadata to retrieve AWSCredentials.
AWS.ecs_instance_credentials — Methodecs_instance_credentials() -> Union{AWSCredentials, Nothing}Retrieve credentials from the ECS credential endpoint. If the ECS credential endpoint is unavailable then nothing will be returned.
More information can be found at:
- https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html
- https://docs.aws.amazon.com/sdkref/latest/guide/feature-container-credentials.html
Returns
AWSCredentials: AWSCredentials fromECScredentials URI,nothingif the Env Var is not set (not running on an ECS container instance)
Throws
StatusError: If the response status is >= 300ParsingError: Invalid HTTP request target
AWS.env_var_credentials — Functionenv_var_credentials(explicit_profile::Bool=false) -> Union{AWSCredentials, Nothing}Use AWS environmental variables (e.g. AWSACCESSKEYID, AWSSECRETACCESSKEY, etc.) to create AWSCredentials.
AWS.external_process_credentials — Methodexternal_process_credentials(cmd::Base.AbstractCmd) -> AWSCredentialsSources AWS credentials from an external process as defined in the AWS CLI config file. See https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html for details.
AWS.global_aws_config — Methodglobal_aws_config(config::AbstractAWSConfig)Set the global AWSConfig.
Arguments
config::AWSConfig: The AWSConfig to set in the global state
Returns
AWSConfig: Global AWSConfig
AWS.global_aws_config — Methodglobal_aws_config()Retrieve the global AWS configuration. If one is not set, create one with default configuration options.
Keywords
kwargs...: AWSConfig kwargs to be passed along if the global configuration is not already set
Returns
AWSConfig: The global AWS configuration
AWS.localhost_is_ec2 — Methodlocalhost_is_ec2() -> BoolDetermine if the machine executing this code is running on an EC2 instance.
AWS.set_user_agent — Methodset_user_agent(new_user_agent::String)Set the global user agent when making HTTP requests.
Arguments
new_user_agent::String: User agent to set when making HTTP requests
Return
String: The global user agent
AWS.sso_credentials — Functionsso_credentials(profile=nothing) -> Union{AWSCredentials, Nothing}Retrieve credentials via AWS single sign-on (SSO) settings defined in the profile within the AWS configuration file. If no SSO settings are found for the profile nothing is returned.
Arguments
profile: Specific profile used to getAWSCredentials, default isnothing
AWS.FeatureSet — TypeFeatureSetAllows end users to opt-in to new breaking behaviors prior before a major/breaking package release. Each field of this struct contains a default which specifies uses the original non-breaking behavior.
Features
use_response_type::Bool=false: When enabled, service calls will return anAWS.Responsewhich provides streaming/raw/parsed access to the response. When disabled, the service call response typically be parsed but will vary depending on the following parameters: "returnheaders", "returnstream", "returnraw", "responsedict_type".