AWSCore.jl Documentation
Amazon Web Services Core Functions and Types.
https://github.com/JuliaCloud/AWSCore.jl
AWSCore Configuration
AWSCore.AWSConfig
— Type.Most AWSCore
functions take a AWSConfig
dictionary as the first argument. This dictionary holds AWSCredentials
and AWS region configuration.
aws = AWSConfig(:creds => AWSCredentials(), :region => "us-east-1")`
AWSCore.aws_config
— Function.The aws_config
function provides a simple way to creates an AWSConfig
configuration dictionary.
>aws = aws_config()
>aws = aws_config(creds = my_credentials)
>aws = aws_config(region = "ap-southeast-2")
By default, the aws_config
attempts to load AWS credentials from:
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
environemnt variables,
A ~/.aws/credentials
file can be created using the AWS CLI command aws configrue
. Or it can be created manually:
[default]
aws_access_key_id = AKIAXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
If your ~/.aws/credentials
file contains multiple profiles you can select a profile by setting the AWS_PROFILE
environment variable.
aws_config
understands the following AWS CLI environment variables: AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, AWS_SESSION_TOKEN
, AWS_DEFAULT_REGION
, AWS_PROFILE
and AWS_CONFIG_FILE
.
An configuration dictionary can also be created directly from a key pair as follows. However, putting access credentials in source code is discouraged.
aws = aws_config(creds = AWSCredentials("AKIAXXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))
AWSCore.default_aws_config
— Function.default_aws_config
returns a global shared AWSConfig
object obtained by calling aws_config
with no optional arguments.
AWSCore.aws_user_arn
— Function.aws_user_arn(::AWSConfig)
Unique Amazon Resource Name for configrued user.
e.g. "arn:aws:iam::account-ID-without-hyphens:user/Bob"
AWSCore.aws_account_number
— Function.aws_account_number(::AWSConfig)
12-digit AWS Account Number.
AWSCore Internals
AWS Security Credentials
AWSCore.AWSCredentials
— Type.When 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.
The AWSCredentials()
constructor tries to load local Credentials from environment variables, ~/.aws/credentials
or EC2 instance credentials.
AWSCore.env_instance_credentials
— Function.Load Credentials from environment variables AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
etc. (e.g. in Lambda sandbox).
AWSCore.dot_aws_credentials
— Function.Load Credentials from AWS CLI ~/.aws/credentials file.
AWSCore.ec2_instance_credentials
— Function.Load Instance Profile Credentials for EC2 virtual machine.
Endpoints and Resource Names
AWSCore.aws_endpoint
— Function.aws_endpoint(service, [region, [hostname_prefix]])
Generate service endpoint URL for service
and region
.
AWSCore.aws_endpoint("sqs", "eu-west-1")
"http://sqs.eu-west-1.amazonaws.com"
AWSCore.arn
— Function.arn([::AWSConfig], service, resource, [region, [account]])
Generate an Amazon Resource Name for service
and resource
.
AWSCore.arn("sqs", "au-test-queue", "ap-southeast-2", "1234")
"arn:aws:sqs:ap-southeast-2:1234:au-test-queue"
AWSCore.arn(default_aws_config(), "sns", "au-test-topic")
"arn:aws:sns:ap-southeast-2:551613799374:au-test-topic"
AWSCore.arn_region
— Function.arn_region(arn)
Extract region name from arn
.
API Requests
AWSRequest
do_request
dump_aws_request
post_request
post_request(aws_config(), "sdb", "2009-04-15", Dict("Action" => "ListDomains"))
Execution Environemnt
AWSCore.localhost_is_lambda
— Function.Is Julia running in an AWS Lambda sandbox?
AWSCore.localhost_is_ec2
— Function.Is Julia running on an EC2 virtual machine?
AWSCore.ec2_metadata
— Function.ec2_metadata(key)
Fetch EC2 meta-data for key
.
Utility Functions
AWSCore.mime_multipart
— Function.mime_multipart([header,] parts)
Encode parts
as a MIME Multipart message.
parts
is a Vector of (filename, content_type, content)
Tuples.
println(AWSCore.mime_multipart([
("foo.txt", "text/plain", "foo"),
("bar.txt", "text/plain", "bar")
]))
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=PRZLn8Nm1I82df0Dtj4ZvJi="
--=PRZLn8Nm1I82df0Dtj4ZvJi=
Content-Type: text/plain;
name=foo.txt
Content-Disposition: attachment;
filename=foo.txt
Content-Transfer-Encoding: binary
foo
--=PRZLn8Nm1I82df0Dtj4ZvJi=
Content-Type: text/plain;
name=bar.txt
Content-Disposition: attachment;
filename=bar.txt
Content-Transfer-Encoding: binary
bar
--=PRZLn8Nm1I82df0Dtj4ZvJi=--