AWSTools
AWSTools provides several helper methods for working with AWSSDK.jl from julia.
Installation
julia> Pkg.add("AWSTools.jl")
You will also need to have the proper IAM permissions for the actions you wish to perform. Currently the permissions AWSTools requires (if run in it's entirety) are:
- cloudformation:DescribeStacks
- ecr:GetAuthorizationToken
- s3:GetObject
- s3:ListBucket
- s3:PutObject
- s3:DeleteObject
Basic Usage
This example uses the Docker module directly and the ECR module indirectly. See the API for other uses of AWSTools.
julia> using AWSTools
julia> using AWSTools.Docker
julia> Docker.login()
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
true
API
AWSTools.assume_role
— Function.assume_role(role_arn, [role_session_name]) -> AWSConfig
Generate a new AWSConfig
by assuming a new role. In order to use the assumed role you need to use this config in the various AWS calls you perform.
Arguments
role_arn::AbstractString
: The ARN of the role to assume.role_session_name::AbstractString
: An optional string which is the unique identifier for the session name.
Keywords
config::AWSConfig
: The AWS configuration to use when assuming the role.
CloudFormation
raw_stack_description(stack_name::AbstractString) -> String
Returns the description for the specified stack. Can optionally pass in the aws config
as a keyword argument.
AWSTools.CloudFormation.stack_output
— Method.stack_output(stack_name::AbstractString) -> OrderedDict
The stack's OutputKey and OutputValue values as a dictionary. Can pass in the aws config
as a keyword argument.
Docker
AWSTools.Docker.login
— Method.login(registry_id::Union{AbstractString, Integer}="")
Gets the AWS ECR authorization token and runs the corresponding docker login command. Takes an optional AWS config
keyword argument or uses the default.
AWSTools.Docker.pull
— Method.pull(image::AbstractString, tags::AbstractVector{<:AbstractString}=String[])
Pulls a docker image and tags it if tags
is specified.
AWSTools.Docker.push
— Method.push(image::AbstractString)
Pushes a docker image.
AWSTools.Docker.build
— Method.build(dir::AbstractString, tag::AbstractString="")
Builds the docker image.
ECR
AWSTools.ECR.get_login
— Function.get_login(registry_ids::Union{AbstractString, Integer}="") -> Cmd
Gets the AWS ECR authorization token and returns the corresponding docker login command. The AWS config
keyword parameter is optional (will use the default if it's not passed in).
EC2
AWSTools.EC2.instance_metadata
— Method.instance_metadata(path) -> Union{String,Nothing}
Retrieve AWS EC2 instance metadata as a string from the provided path
. If no instance metadata is available (typically due to not running within an EC2 instance) then nothing
will be returned. See the AWS documentation for details on what metadata is available.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
AWSTools.EC2.instance_availability_zone
— Method.instance_availability_zone() -> Union{String,Nothing}
Get the availability zone of the host if running inside of an EC2 instance. If not running within an EC2 instance nothing
is returned.
AWSTools.EC2.instance_region
— Method.instance_availability_zone() -> Union{String,Nothing}
Get the region of the host if executed inside of an EC2 instance. If not running within an EC2 instance nothing
is returned.