Skip to content

Instantly share code, notes, and snippets.

View KyMidd's full-sized avatar

Kyler Middleton KyMidd

View GitHub Profile
resource "aws_kms_alias" "hub_secrets_manager_cmk_alias" {
name = "alias/hub_secrets_manager_cmk"
target_key_id = aws_kms_key.hub_secrets_manager_cmk.key_id
}
resource "aws_ecr_repository_policy" "hub_ecr_repository_policy" {
repository = aws_ecr_repository.hub_ecr_repository.name
policy = jsonencode(
{
"Version" : "2008-10-17",
"Statement" : [
{
"Sid" : "AllowSpokeAccountsToPull",
"Effect" : "Allow",
"Principal" : {
resource "aws_ecr_repository" "hub_ecr_repository" {
name = "hub_ecr_repository"
image_tag_mutability = "MUTABLE"
image_scanning_configuration {
scan_on_push = true
}
tags = {
name = "hub_ecr_repository"
terraform = "true"
}
# If all happy, return 0 exit code. Else return 1 and fail
if [ $job1_results = "SUCCEEDED" ] && [ $job2_results = "SUCCEEDED" ]; then
echo "##[section]All tests pass"
exit 0
else
echo "##[error]At least one test has failed. Either your code or our tests aren't valid."
echo "##[error]Feel free to run the validations again"
exit 1
fi
while [ 0=0 ]; do
echo "##[command]Checking Job status"
if [ $job1_still_checking = "yes" ]; then
job1_results=$(aws batch describe-jobs --jobs $job1 --region us-east-1 | jq -r '.jobs[].status')
echo $job1_name "has status:" $job1_results
case $job1_results in
"SUCCEEDED")
echo "##[section]"$job1_name "job succeeded"
job1_still_checking="no"
# Initialize tracking variables
job1_still_checking="yes"
job2_still_checking="yes"
# Submit Job 1
job1_name="job1"
job1=$(aws batch submit-job --job-name BatchJob1Name_int_$date --job-definition BatchJob1JobDef:2 --job-queue arn:aws:batch:us-east-1:1234567890:job-queue/batch-job-queue-1 --region us-east-1 --container-overrides vcpus=4,memory=8192,command='["-a=foo","-b=bar"]' | jq -r '.jobId')
echo "##[command]"$job1_name "job submitted, ID:" $job1
# Submit Job 2
job2_name="job2"
job2=$(aws batch submit-job --job-name BatchJob2Name_int_$date --job-definition BatchJob2JobDef:2 --job-queue arn:aws:batch:us-east-1:1234567890:job-queue/batch-job-queue-1 --region us-east-1 --container-overrides vcpus=4,memory=8192,command='["-a=foo","-b=bar"]' | jq -r '.jobId')
echo "##[command]"$job2_name "job submitted, ID:" $job2
echo "**************************"
echo "##[section]Spinning up batch jobs to test the proposed changes"
echo "**************************"
# Set date, format YYYYMMDD, used to name batch jobs
date=$(date '+%Y%m%d')
echo ""
- task: Bash@3
displayName: Trigger Batch Testing Jobs
inputs:
targetType: inline
workingDirectory: $(System.DefaultWorkingDirectory)
failOnStderr: true
script: |
chmod +x ./pipelines/batch_testing/$(batch_test_script)
./pipelines/batch_testing/$(batch_test_script)
- task: Bash@3
displayName: Build Docker Images
inputs:
targetType: inline
workingDirectory: $(docker_dest_config_directory)
failOnStderr: true
script: |
docker build -f Dockerfile -t $(docker_tag1) .
- task: Bash@3