Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 4 additions & 30 deletions docker/run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,7 @@
entrypoint="$1"
command="$2"


PREFIX=$(cat ../terraform/terraform.tfstate | jq '.outputs.environment.value // empty' -r)
STAGE=$(cat ../terraform/terraform.tfstate | jq '.outputs.stage.value // empty' -r)
ARCH=$(cat ../terraform/terraform.tfstate | jq '.outputs.arch.value // empty' -r)

if [ -z "$STAGE" ]
then
echo "STAGE must be set!"
exit 1;
fi

if [ -z "$PREFIX" ]
then
echo "PREFIX must be set!"
exit 1;
fi

if [ -z "$ARCH" ]
then
echo "ARCH must be set!"
exit 1;
fi

CONTAINER="$PREFIX-$STAGE-pdal_runner"
CONTAINER=$(cat ../terraform/terraform.tfstate | jq '.outputs.container.value // empty' -r)

REGION=$AWS_DEFAULT_REGION
if [ -z "$REGION" ]
Expand All @@ -40,13 +17,11 @@ fi
LOCALPORT=9000
REMOTEPORT=8080

identity=$(aws sts get-caller-identity --query 'Account' --output text)

KEY_ID=$(aws --profile $AWS_DEFAULT_PROFILE configure get aws_access_key_id)
SECRET_ID=$(aws --profile $AWS_DEFAULT_PROFILE configure get aws_secret_access_key)


echo "running $identity.dkr.ecr.$region.amazonaws.com/$container:$ARCH"
echo "Starting container $CONTAINER"

if [ -z "$entrypoint" ]
then
Expand All @@ -55,7 +30,7 @@ then
-e AWS_DEFAULT_REGION=$REGION \
-e AWS_ACCESS_KEY_ID=${KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=${SECRET_ID} \
$identity.dkr.ecr.$REGION.amazonaws.com/$CONTAINER:$ARCH "$command"
$CONTAINER "$command"
else
echo "executing with $entrypoint and command '$command'"
docker run -p $LOCALPORT:$REMOTEPORT \
Expand All @@ -65,7 +40,6 @@ else
-t -i \
-v $(pwd):/data \
--entrypoint=$entrypoint \
$identity.dkr.ecr.$REGION.amazonaws.com/$CONTAINER:$ARCH \
"$command"
$CONTAINER "$command"
fi

13 changes: 13 additions & 0 deletions docker/test-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

eventfilename=$1

if [ -z "$AWS_ACCESS_KEY_ID" ]
then
echo "AWS_ACCESS_KEY_ID must be set in environment!"
exit 1;
fi

if [ -z "$AWS_SECRET_ACCESS_KEY" ]
then
echo "AWS_SECRET_ACCESS_KEY must be set in environment!"
exit 1;
fi


event=$(<$eventfilename)
echo $event
curl -POST -v "http://localhost:9000/2015-03-31/functions/function/invocations" -d @$eventfilename
Expand Down
11 changes: 11 additions & 0 deletions docker/test-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ eventfilename=$1

FUNCTION_NAME=$(cat ../terraform/terraform.tfstate | jq '.outputs.info_lambda_name.value // empty' -r)

if [ -z "$AWS_ACCESS_KEY_ID" ]
then
echo "AWS_ACCESS_KEY_ID must be set in environment!"
exit 1;
fi

if [ -z "$AWS_SECRET_ACCESS_KEY" ]
then
echo "AWS_SECRET_ACCESS_KEY must be set in environment!"
exit 1;
fi

aws lambda invoke \
--function-name "$FUNCTION_NAME" \
Expand Down
5 changes: 5 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ output "bucket" {
description = "Storage bucket"
value = module.resources.bucket
}

output "container" {
description = "Container ARN"
value = module.resources.container
}
4 changes: 4 additions & 0 deletions terraform/resources/ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ data aws_ecr_image runner_image {
image_tag = var.arch
depends_on = [ null_resource.ecr_image, aws_ecr_repository.runner_ecr_repo ]
}

output "container" {
value = "${aws_ecr_repository.runner_ecr_repo.repository_url}:${var.arch}"
}