Skip to content

Commit

Permalink
Merge #27
Browse files Browse the repository at this point in the history
27: AWSCore.jl -> AWS.jl r=mattBrzezinski a=mattBrzezinski



Co-authored-by: Matt Brzezinski <matt.brzezinski@invenia.ca>
Co-authored-by: mattBrzezinski <matt.brzezinski@invenia.ca>
Co-authored-by: morris25 <sam.morrison@invenia.ca>
Co-authored-by: Sam Morrison <sam.morrison@invenia.ca>
  • Loading branch information
3 people authored Sep 16, 2021
2 parents 59377a3 + a6ed481 commit 8130a01
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 601 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
version: '1.6'
- run: |
julia --project=docs -e '
using Pkg
Expand Down
10 changes: 4 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name = "AWSTools"
uuid = "83bcdc74-1232-581c-948a-f29122bf8259"
authors = ["Invenia Technical Computing"]
version = "1.10.1"
version = "2.0.0"

[deps]
AWSCore = "4f1ea46c-232b-54a6-9b17-cc2d0f3e6598"
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
AWSS3 = "1c724243-ef5b-51ab-93f4-b0a88ac62a95"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
Expand All @@ -19,10 +18,9 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
XMLDict = "228000da-037f-5747-90a9-8195ccbf91a5"

[compat]
AWSCore = "0.5, 0.6"
AWSS3 = "0.6, 0.8"
AWS = "1"
AWSS3 = "0.8"
EzXML = "0.7.3, 0.8, 0.9, 1"
FilePathsBase = "0.9"
HTTP = "0.8.4, 0.9"
MbedTLS = "0.6, 0.7, 1"
Memento = "0.12.1, 0.13, 1"
Expand Down
59 changes: 21 additions & 38 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
# This file is machine-generated - editing it directly is not advised

[[AWS]]
deps = ["Base64", "Compat", "Dates", "GitHub", "HTTP", "IniFile", "JSON", "MbedTLS", "Mocking", "OrderedCollections", "Retry", "Sockets", "URIs", "UUIDs", "XMLDict"]
git-tree-sha1 = "8285d067fc0e11b145c83993f891f94a529269b3"
deps = ["Base64", "Compat", "Dates", "Downloads", "GitHub", "HTTP", "IniFile", "JSON", "MbedTLS", "Mocking", "OrderedCollections", "Retry", "Sockets", "URIs", "UUIDs", "XMLDict"]
git-tree-sha1 = "5a202ba4941a6bdbe901df5e6e591cd4dedb348f"
uuid = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
version = "1.51.0"

[[AWSCore]]
deps = ["Base64", "Dates", "HTTP", "IniFile", "JSON", "LazyJSON", "MbedTLS", "Mocking", "OrderedCollections", "Retry", "Sockets", "SymDict", "UUIDs", "XMLDict"]
git-tree-sha1 = "1d3c3af424f774d1b5f040f2f62ce51f2f790b70"
uuid = "4f1ea46c-232b-54a6-9b17-cc2d0f3e6598"
version = "0.6.17"
version = "1.60.3"

[[AWSS3]]
deps = ["AWS", "Base64", "Dates", "EzXML", "FilePathsBase", "HTTP", "MbedTLS", "OrderedCollections", "Retry", "SymDict", "UUIDs", "XMLDict"]
git-tree-sha1 = "a64107e7d883f8eadd162354d754864c41629678"
deps = ["AWS", "Base64", "Dates", "EzXML", "FilePathsBase", "HTTP", "MbedTLS", "OrderedCollections", "Retry", "SymDict", "URIs", "UUIDs", "XMLDict"]
git-tree-sha1 = "09d99ce2fba4de795a357535462519a569801c40"
uuid = "1c724243-ef5b-51ab-93f4-b0a88ac62a95"
version = "0.8.6"
version = "0.8.9"

[[AWSTools]]
deps = ["AWSCore", "AWSS3", "Base64", "Dates", "EzXML", "FilePathsBase", "HTTP", "MbedTLS", "Memento", "Mocking", "OrderedCollections", "Random", "XMLDict"]
git-tree-sha1 = "b8a981dac009e3deefe27d53778d24988668c08b"
deps = ["AWS", "AWSS3", "Base64", "Dates", "EzXML", "HTTP", "MbedTLS", "Memento", "Mocking", "OrderedCollections", "Random", "XMLDict"]
path = ".."
uuid = "83bcdc74-1232-581c-948a-f29122bf8259"
version = "1.10.0"
version = "2.0.0"

[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand All @@ -35,9 +29,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "dc7dedc2c2aa9faf59a55c622760a25cbefbe941"
git-tree-sha1 = "4866e381721b30fac8dda4c8cb1d9db45c8d2994"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.31.0"
version = "3.37.0"

[[Dates]]
deps = ["Printf"]
Expand Down Expand Up @@ -90,15 +84,15 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[GitHub]]
deps = ["Base64", "Dates", "HTTP", "JSON", "MbedTLS", "Sockets", "SodiumSeal"]
git-tree-sha1 = "9e62f3eae4a2514d1de65cc2ac9d1669032a4595"
git-tree-sha1 = "c8594dff1ed76e232d8063b2a2555335900af6f3"
uuid = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26"
version = "5.6.0"
version = "5.7.0"

[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "c6a1fff2fd4b1da29d3dccaffb1e1001244d844e"
git-tree-sha1 = "60ed5f1643927479f845b0135bb369b031b541fa"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.12"
version = "0.9.14"

[[IniFile]]
deps = ["Test"]
Expand Down Expand Up @@ -131,12 +125,6 @@ version = "0.20.1"
deps = ["Artifacts", "Pkg"]
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"

[[LazyJSON]]
deps = ["JSON", "OrderedCollections", "PropertyDicts"]
git-tree-sha1 = "ce08411caa70e0c9e780f142f59debd89a971738"
uuid = "fc18253b-5e1b-504c-a4a2-9ece4944c004"
version = "0.2.2"

[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
Expand Down Expand Up @@ -194,9 +182,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[Mocking]]
deps = ["ExprTools"]
git-tree-sha1 = "916b850daad0d46b8c71f65f719c49957e9513ed"
git-tree-sha1 = "748f6e1e4de814b101911e64cc12d83a6af66782"
uuid = "78c3b35d-d492-501b-9361-3d52fe80e533"
version = "0.7.1"
version = "0.7.2"

[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
Expand All @@ -223,11 +211,6 @@ version = "1.2.2"
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[PropertyDicts]]
git-tree-sha1 = "429d887daee312e73842cabe6b122e310b72e25d"
uuid = "f8a19df8-e894-5f55-a973-672c1158cbca"
version = "0.1.0"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand All @@ -237,9 +220,9 @@ deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[RecipesBase]]
git-tree-sha1 = "b3fb709f3c97bfc6e948be68beeecb55a0b340ae"
git-tree-sha1 = "44a75aa7a527910ee3d1751d1f0e4148698add9e"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.1.1"
version = "1.1.2"

[[Retry]]
git-tree-sha1 = "41ac127cd281bb33e42aba46a9d3b25cd35fc6d5"
Expand Down Expand Up @@ -299,9 +282,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TimeZones]]
deps = ["Dates", "Future", "LazyArtifacts", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"]
git-tree-sha1 = "81753f400872e5074768c9a77d4c44e70d409ef0"
git-tree-sha1 = "6c9040665b2da00d30143261aea22c7427aada1c"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.5.6"
version = "1.5.7"

[[URIs]]
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[deps]
AWSTools = "83bcdc74-1232-581c-948a-f29122bf8259"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"

[compat]
Documenter = "~0.22.4"
19 changes: 7 additions & 12 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
using Documenter, AWSTools, FilePathsBase
using Documenter, AWSTools

makedocs(
makedocs(;
modules=[AWSTools],
format=Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true",
assets=[
"assets/invenia.css",
],
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", nothing) == "true", assets=["assets/invenia.css"]
),
pages=[
"Home" => "index.md",
],
pages=["Home" => "index.md"],
repo="https://github.com/JuliaCloud/AWSTools.jl/blob/{commit}{path}#L{line}",
sitename="AWSTools.jl",
authors="Invenia Technical Computing",
checkdocs = :exports,
strict = true,
checkdocs=:exports,
strict=true,
)
32 changes: 15 additions & 17 deletions src/AWSTools.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
module AWSTools

using AWSCore
using AWSCore.Services: sts
using AWS
using AWSS3
using Mocking
using Random
using Dates: Period, unix2datetime
using Dates: unix2datetime
export assume_role

get_caller_identity() = sts("GetCallerIdentity")
account_id() = (@mock get_caller_identity())["Account"]
@service STS

get_caller_identity() = STS.get_caller_identity()["GetCallerIdentityResult"]
account_id() = (@mock get_caller_identity())["GetCallerIdentityResult"]["Account"]

"""
assume_role(role_arn, [role_session_name]) -> AWSConfig
Expand All @@ -28,36 +29,33 @@ to use this config in the various AWS calls you perform.
function assume_role(
role_arn::AbstractString,
role_session_name::AbstractString=randstring(16);
config::AWSConfig=aws_config(),
config::AWSConfig=global_aws_config(),
)
function get_role_creds(role_arn, role_session_name, config)
response = @mock sts(
config,
"AssumeRole",
RoleArn=role_arn,
RoleSessionName=role_session_name,
)
response = @mock STS.assume_role(role_arn, role_session_name; aws_config=config)
response = response["AssumeRoleResult"]
credentials = response["Credentials"]
AWSCredentials(
return AWSCredentials(
credentials["AccessKeyId"],
credentials["SecretAccessKey"],
credentials["SessionToken"],
expiry = unix2datetime(credentials["Expiration"])
credentials["SessionToken"];
expiry=unix2datetime(credentials["Expiration"]),
)
end

renew = () -> get_role_creds(role_arn, role_session_name, config)
creds = renew()
creds.renew = renew

return aws_config(creds=creds)
return AWSConfig(; creds=creds)
end

include("timeout.jl")
include("CloudFormation.jl")
include("EC2.jl")
include("ECR.jl")
include("Docker.jl")
include("S3.jl")

Base.@deprecate_binding S3 AWSS3

end # AWSTools
52 changes: 19 additions & 33 deletions src/CloudFormation.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
module CloudFormation

using AWSCore
using AWSCore.Services: cloudformation
using AWS
using AWS: AWSExceptions.AWSException
using EzXML
using MbedTLS: MbedException
using Memento
using Mocking
using OrderedCollections: OrderedDict
using XMLDict

# Improper casing to avoid issues with Module name and AWS.AWSService
@service cloudFormation

const logger = getlogger(@__MODULE__)

# Register the module level logger at runtime so that folks can access the logger via `getlogger(MyModule)`
# NOTE: If this line is not included then the precompiled `MyModule.logger` won't be registered at runtime.
__init__() = Memento.register(logger)

export raw_stack_description, stack_output, stack_description

describe_stacks(config; kwargs...) = cloudformation(config, "DescribeStacks"; kwargs...)
export raw_stack_description, stack_output

function describe_stacks(config::AWSConfig, params::AbstractDict)
dep_msg = """
`describe_stacks(config::AWSConfig, params::AbstractDict)` is deprecated and will be removed.
Use the AWS @service CloudFormation.describe_stacks() functionality instead.
"""
Base.depwarn(dep_msg, :get_authorization_token)
return cloudFormation.describe_stacks(params; aws_config=config)
end

const _NRETRIES = 5

Expand All @@ -38,8 +47,7 @@ Returns the description for the specified stack. Can optionally pass in the aws
as a keyword argument.
"""
function raw_stack_description(
stack_name::AbstractString;
config::AWSConfig=aws_config()
stack_name::AbstractString; config::AWSConfig=global_aws_config()
)
function retry_cond(s, e)
if e isa AWSException
Expand All @@ -58,10 +66,8 @@ function raw_stack_description(
return (s, false)
end

f = retry(delays=cautious_delays(; jitter=0.2), check=retry_cond) do
aws_raw_config = deepcopy(config)
aws_raw_config[:return_raw] = true
@mock describe_stacks(aws_raw_config, StackName=stack_name)
f = retry(; delays=cautious_delays(; jitter=0.2), check=retry_cond) do
@mock describe_stacks(config, Dict("StackName" => stack_name, "return_raw" => true))
end

response = String(f())
Expand All @@ -75,8 +81,8 @@ end
The stack's OutputKey and OutputValue values as a dictionary. Can pass in the aws `config`
as a keyword argument.
"""
function stack_output(stack_name::AbstractString; config::AWSConfig=aws_config())
outputs = OrderedDict{String, String}()
function stack_output(stack_name::AbstractString; config::AWSConfig=global_aws_config())
outputs = OrderedDict{String,String}()
description = raw_stack_description(stack_name; config=config)

xml = root(parsexml(description))
Expand Down Expand Up @@ -105,24 +111,4 @@ function output_pair(item::AbstractDict)
return key => value
end

# BEGIN AWSTools.Cloudformation 0.8.1 deprecations

function stack_description(
stack_name::AbstractString;
config::AWSConfig=aws_config()
)
dep_msg = """
`stack_description(::AbstractString; ::AWSConfig)` is deprecated and will be removed.
Please use `raw_stack_description(::AbstractString; ::AWSConfig)` instead and handle XML parsing in the calling function.
We recommend using EzXML.
"""
Base.depwarn(dep_msg, :stack_description)

response = xml_dict(raw_stack_description(stack_name))

return response["DescribeStacksResponse"]["DescribeStacksResult"]["Stacks"]["member"]
end

# END AWSTools.Cloudformation 0.8.1 deprecations

end # CloudFormation
7 changes: 3 additions & 4 deletions src/Docker.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Docker

using AWSCore
using AWS
using ..ECR

export login, pull, push, build
Expand All @@ -12,10 +12,9 @@ Gets the AWS ECR authorization token and runs the corresponding docker login com
Takes an optional AWS `config` keyword argument or uses the default.
"""
function login(
registry_id::Union{AbstractString, Integer}="";
config::AWSConfig=aws_config()
registry_id::Union{AbstractString,Integer}=""; config::AWSConfig=global_aws_config()
)
login(ECR.get_login(registry_id; config=config))
return login(ECR.get_login(registry_id; config=config))
end

function login(docker_login::Cmd)
Expand Down
Loading

2 comments on commit 8130a01

@morris25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/45035

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.0.0 -m "<description of version>" 8130a01c39849ab4aac354e7aa19bcde9b618fd7
git push origin v2.0.0

Please sign in to comment.