Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update validation_testing to use ECR #2351

Merged
merged 3 commits into from
Oct 23, 2024
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
1 change: 0 additions & 1 deletion .github/workflows/run_release_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ jobs:
RESULTS_LOCATION: ${{ secrets.RESULTS_LOCATION }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
S3_DATA_PATH: ${{ secrets.S3_DATA_PATH }}
S3_JARS_BUCKET: ${{ secrets.S3_JARS_BUCKET }}
SPILL_BUCKET: ${{ secrets.SPILL_BUCKET }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as cdk from 'aws-cdk-lib';
import * as glue from '@aws-cdk/aws-glue-alpha';
import * as ddb from 'aws-cdk-lib/aws-dynamodb';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Repository } from 'aws-cdk-lib/aws-ecr';
import { CfnInclude } from 'aws-cdk-lib/cloudformation-include';
import { Construct } from 'constructs';
import tpcdsJson from '../../resources/tpcds_specs.json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as glue from '@aws-cdk/aws-glue-alpha';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Repository } from 'aws-cdk-lib/aws-ecr';
import { CfnInclude } from 'aws-cdk-lib/cloudformation-include';
const path = require('path');
import {FederationStackProps} from './stack-props'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as rds from 'aws-cdk-lib/aws-rds';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as glue from '@aws-cdk/aws-glue-alpha';
import * as iam from 'aws-cdk-lib/aws-iam'
import { Repository } from 'aws-cdk-lib/aws-ecr';
import { CfnInclude } from 'aws-cdk-lib/cloudformation-include';
import { Construct } from 'constructs';
const path = require('path')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
import * as ssm from 'aws-cdk-lib/aws-ssm';
import { Repository } from 'aws-cdk-lib/aws-ecr';
import { CfnInclude } from 'aws-cdk-lib/cloudformation-include';
import { Construct } from 'constructs';
const path = require('path');
Expand Down
24 changes: 18 additions & 6 deletions validation_testing/deploy_infra.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@

CONNECTOR_NAME=$1
VALIDATION_TESTING_ROOT=$REPOSITORY_ROOT/validation_testing

# upload connector jar to s3 and update yaml to s3 uri, redirect to /dev/null to not log the s3 path
aws s3 cp $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/target/athena-$CONNECTOR_NAME-2022.47.1.jar "$S3_JARS_BUCKET/" > /dev/null
sed -i "s#CodeUri: \"./target/athena-$CONNECTOR_NAME-2022.47.1.jar\"#CodeUri: \"$S3_JARS_BUCKET/athena-$CONNECTOR_NAME-2022.47.1.jar\"#" $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml
# ecr repository must be created and an image pushed before the cdk stack is deployed for the lambda to create successfully
# get the AWS account ID from the current roll (for use in ECR repo name)
ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"

# create the ECR repository
aws ecr create-repository --repository-name athena-federation-repository-$CONNECTOR_NAME --region us-east-1

# push the ECR image for the connector to the ECR repository
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
docker build -t athena-federation-repository-$CONNECTOR_NAME $REPOSITORY_ROOT/athena-$CONNECTOR_NAME
docker tag athena-federation-repository-$CONNECTOR_NAME\:latest $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/athena-federation-repository-$CONNECTOR_NAME\:latest
docker push $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/athena-federation-repository-$CONNECTOR_NAME\:latest

# update the template to use the correct ImageUri
sed -i "s|292517598671|$ACCOUNT_ID|g" "$REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml"
aimethed marked this conversation as resolved.
Show resolved Hide resolved
sed -i "s#\(/athena-federation-repository-$CONNECTOR_NAME:\)[0-9]\{4\}\.[0-9]\{1,2\}\.[0-9]\{1\}#\1latest#" $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml

echo "FINISHED PUSHING CONNECTOR IMAGE TO ECR REPOSITORY"

# go to cdk dir, build/synth/deploy
cd $(dirname $(find . -name ATHENA_INFRA_SPINUP_ROOT))/app;
Expand All @@ -20,6 +34,4 @@ npm run build;
npm run cdk synth;
npm run cdk deploy ${CONNECTOR_NAME}CdkStack > /dev/null;

sed -i "s#CodeUri: \"$S3_JARS_BUCKET/athena-$CONNECTOR_NAME-2022.47.1.jar\"#CodeUri: \"./target/athena-$CONNECTOR_NAME-2022.47.1.jar\"#" $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml

echo "FINISHED DEPLOYING INFRA FOR ${CONNECTOR_NAME}."
1 change: 0 additions & 1 deletion validation_testing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def assert_required_env_vars_set():
'REPOSITORY_ROOT',
'DATABASE_PASSWORD',
'S3_DATA_PATH',
'S3_JARS_BUCKET',
'SPILL_BUCKET'
]
if not all([os.environ.get(env_var) for env_var in required_env_vars]):
Expand Down
26 changes: 21 additions & 5 deletions validation_testing/run_release_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@
CONNECTOR_NAME=$1
VALIDATION_TESTING_ROOT=$REPOSITORY_ROOT/validation_testing

# upload connector jar to s3 and update yaml to s3 uri, redirect to /dev/null to not log the s3 path
aws s3 cp $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/target/athena-$CONNECTOR_NAME-2022.47.1.jar $S3_JARS_BUCKET > /dev/null
sed -i "s#CodeUri: \"./target/athena-$CONNECTOR_NAME-2022.47.1.jar\"#CodeUri: \"$S3_JARS_BUCKET/athena-$CONNECTOR_NAME-2022.47.1.jar\"#" $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml
# ecr repository must be created and an image pushed before the cdk stack is deployed for the lambda to create successfully
# get the AWS account ID from the current roll (for use in ECR repo name)
ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"

# create the ECR repository
aws ecr create-repository --repository-name athena-federation-repository-$CONNECTOR_NAME --region us-east-1

# push the ECR image for the connector to the ECR repository
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
docker build -t athena-federation-repository-$CONNECTOR_NAME $REPOSITORY_ROOT/athena-$CONNECTOR_NAME
docker tag athena-federation-repository-$CONNECTOR_NAME\:latest $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/athena-federation-repository-$CONNECTOR_NAME\:latest
docker push $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/athena-federation-repository-$CONNECTOR_NAME\:latest

# update the template to use the correct ImageUri
sed -i "s|292517598671|$ACCOUNT_ID|g" "$REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml"
aimethed marked this conversation as resolved.
Show resolved Hide resolved
sed -i "s#\(/athena-federation-repository-$CONNECTOR_NAME:\)[0-9]\{4\}\.[0-9]\{1,2\}\.[0-9]\{1\}#\1latest#" $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml

echo "FINISHED PUSHING CONNECTOR IMAGE TO ECR REPOSITORY"

# go to cdk dir, build/synth/deploy
cd $(dirname $(find . -name ATHENA_INFRA_SPINUP_ROOT))/app;
Expand All @@ -25,8 +40,6 @@ npm run build;
npm run cdk synth;
npm run cdk deploy ${CONNECTOR_NAME}CdkStack > /dev/null;

sed -i "s#CodeUri: \"$S3_JARS_BUCKET/athena-$CONNECTOR_NAME-2022.47.1.jar\"#CodeUri: \"./target/athena-$CONNECTOR_NAME-2022.47.1.jar\"#" $REPOSITORY_ROOT/athena-$CONNECTOR_NAME/athena-$CONNECTOR_NAME.yaml

echo "FINISHED DEPLOYING INFRA FOR ${CONNECTOR_NAME}."

# cd back to validation root
Expand Down Expand Up @@ -61,6 +74,9 @@ cd $(dirname $(find . -name ATHENA_INFRA_SPINUP_ROOT))/app;
# cannot use --force because npm is stripping the flags, so pipe yes through
yes | npm run cdk destroy ${CONNECTOR_NAME}CdkStack;

# delete the ecr repository
aws ecr delete-repository --repository-name athena-federation-repository-$CONNECTOR_NAME --force

echo "FINISHED CLEANING UP RESOURCES FOR ${CONNECTOR_NAME}."


Expand Down