Skip to content

Commit

Permalink
Expose AWS sub-types, fix bug with AWSRolePolicyStatement
Browse files Browse the repository at this point in the history
  • Loading branch information
harris-chris committed Mar 26, 2023
1 parent 63b5dbb commit 864c790
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ timing_notes.md
**/append_string.jl
jot_temp
interval_testing*

notes_on_this_branch.md

2 changes: 1 addition & 1 deletion src/AWS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
@with_kw mutable struct AWSRolePolicyStatement
Effect::Union{Missing, String} = missing
Principal::Union{Missing, Dict{String, Any}} = missing
Action::Union{Missing, String} = missing
Action::Union{Missing, String, Vector{String}} = missing
end
StructTypes.StructType(::Type{AWSRolePolicyStatement}) = StructTypes.Mutable()
Base.:(==)(a::AWSRolePolicyStatement, b::AWSRolePolicyStatement) = (
Expand Down
8 changes: 7 additions & 1 deletion src/Jot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import Base.delete!
# EXPORTS
export AWSConfig, LambdaException
export get_responder, AbstractResponder, LocalPackageResponder
export LocalImage, Container, RemoteImage, ECRRepo, AWSRole, LambdaFunction
export LocalImage, Container, RemoteImage, ECRRepo, LambdaFunction
export AWSRole, AWSRolePolicyDocument, AWSRolePolicyStatement
export LambdaFunctionInvocationLog, LogEvent, InvocationTimeBreakdown
export get_aws_role, get_user_labels
export LambdaFunctionState, pending, active
Expand Down Expand Up @@ -357,6 +358,7 @@ function create_local_image(
image_name_plus_tag = get_image_full_name_plus_tag(aws_config,
image_suffix,
image_tag)
@show image_name_plus_tag
# Build the actual image
build_cmd = get_dockerfile_build_cmd(dockerfile,
image_name_plus_tag,
Expand Down Expand Up @@ -595,6 +597,8 @@ function push_to_ecr!(image::LocalImage)::RemoteImage
else
existing_repo
end
@show image
@show get_image_full_name_plus_tag(image)
push_script = get_image_full_name_plus_tag(image) |> get_docker_push_script
@info "Pushing image to ECR; this may take a few minutes"
readchomp(`bash -c $push_script`)
Expand Down Expand Up @@ -624,6 +628,7 @@ function create_lambda_function(
timeout::Int64 = 60,
memory_size::Int64 = 2000,
)::LambdaFunction
@info "Creating lambda function for remote image $(remote_image.ecr_repo.repositoryName)"
function_name = isnothing(function_name) ? remote_image.ecr_repo.repositoryName : function_name
role = isnothing(role) ? create_aws_role(create_role_name(function_name)) : role
image_uri = "$(remote_image.ecr_repo.repositoryUri):$(remote_image.imageTag)"
Expand Down Expand Up @@ -662,6 +667,7 @@ function create_lambda_function(
role = isnothing(role) ? create_aws_role(get_lambda_name(repo) * "-lambda-role") : role
function_name = isnothing(function_name) ? repo.repositoryName : function_name
image_uri = "$(repo.repositoryUri):$image_tag"
@info "Creating lambda function for ECR repo $(image_uri)"
labels = get_labels(repo)
create_lambda_function(image_uri, role, function_name, timeout, memory_size, labels)
end
Expand Down
12 changes: 6 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function get_multi_tests_data()::Vector{SingleTestData}
),
true,
"UpperCaseSuffix",
nothing
"latest"
),
get_empty_test_state(),
)
Expand Down Expand Up @@ -346,7 +346,7 @@ function get_multi_tests_data()::Vector{SingleTestData}
),
true,
nothing,
nothing
"latest"
),
get_empty_test_state(),
)
Expand Down Expand Up @@ -376,7 +376,7 @@ function get_multi_tests_data()::Vector{SingleTestData}
),
false,
nothing,
nothing
"latest"
),
get_empty_test_state(),
)
Expand Down Expand Up @@ -406,7 +406,7 @@ function get_multi_tests_data()::Vector{SingleTestData}
),
true,
nothing,
nothing
"latest"
),
get_empty_test_state(),
)
Expand Down Expand Up @@ -719,7 +719,7 @@ function test_lambda_function(
responder_function_test_args::ResponderFunctionTestArgs,
skip_test::Bool,
)::LambdaFunction
lambda_function = create_lambda_function(ecr_repo; role = aws_role)
lambda_function = create_lambda_function(remote_image; role = aws_role)
@test Jot.is_jot_generated(lambda_function)
@test Jot.matches(remote_image, lambda_function)
# Check that we can find it
Expand Down Expand Up @@ -757,7 +757,7 @@ function test_compiled_lambda_function(
remote_image = push_to_ecr!(compiled_local_image)
ecr_repo = remote_image.ecr_repo
compiled_lambda_function = create_lambda_function(
ecr_repo; role = aws_role, function_name = "addl" * ecr_repo.repositoryName
remote_image; role = aws_role, function_name = "addl" * ecr_repo.repositoryName
)
(average_compiled_run_time, average_uncompiled_run_time) = compare_lambda_function_test_times(
compiled_lambda_function,
Expand Down

0 comments on commit 864c790

Please sign in to comment.