diff --git a/backup_repo.sh b/backup_repo.sh index 7a7459b..368af59 100755 --- a/backup_repo.sh +++ b/backup_repo.sh @@ -28,5 +28,5 @@ zipfile="${codecommitrepo}_backup_${dt}_UTC.tar.gz" echo "Compressing repository: ${codecommitrepo} into file: ${zipfile} and uploading to S3 bucket: ${backup_s3_bucket}/${codecommitrepo}" tar -zcvf "${zipfile}" "${codecommitrepo}/" -aws s3 cp "${zipfile}" "s3://${backup_s3_bucket}/${codecommitrepo}/${zipfile}" --region $AWS_DEFAULT_REGION +aws s3 cp "${zipfile}" "s3://${backup_s3_bucket}/${codecommitrepo}/${zipfile}" --region "$AWS_DEFAULT_REGION" diff --git a/codecommit_backup_cfn_template.yaml b/codecommit_backup_cfn_template.yaml index e165fd3..2d6cbf1 100644 --- a/codecommit_backup_cfn_template.yaml +++ b/codecommit_backup_cfn_template.yaml @@ -59,7 +59,7 @@ Resources: Properties: FunctionName: CodeCommitBackupLambda Handler: codecommit_backup_trigger_lambda.handler - Runtime: python3.6 + Runtime: python3.9 MemorySize: 128 Timeout: 30 Role: !GetAtt CodeCommitBackupLambdaRole.Arn @@ -160,7 +160,7 @@ Resources: Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_MEDIUM - Image: aws/codebuild/python:3.5.2 + Image: aws/codebuild/standard:6.0-23.02.16 EnvironmentVariables: - Name: CodeCommitBackupsS3Bucket diff --git a/codecommit_backup_trigger_lambda.py b/codecommit_backup_trigger_lambda.py index 98a8115..a055d8f 100644 --- a/codecommit_backup_trigger_lambda.py +++ b/codecommit_backup_trigger_lambda.py @@ -2,9 +2,15 @@ # SPDX-License-Identifier: MIT-0 import boto3 -client = boto3.client('codebuild') -def handler(event, context): - response = client.start_build(projectName='CodeCommitBackup') - output = "Triggered CodeBuild project: 'CodeCommitBackup' to back all CodeCommit repos in this account/region. Status={}".format(response["build"]["buildStatus"]) + +client = boto3.client("codebuild") + + +def handler(event, context): + response = client.start_build(projectName="CodeCommitBackup") + output = ( + "Triggered CodeBuild project: 'CodeCommitBackup' to back" + " all CodeCommit repos in this account/region. Status={}" + ).format(response["build"]["buildStatus"]) print(output) return output diff --git a/deploy.sh b/deploy.sh index 973a307..fe45672 100755 --- a/deploy.sh +++ b/deploy.sh @@ -13,7 +13,6 @@ stack_name="codecommit-backups" # You can also change these parameters but it's not required cfn_template="codecommit_backup_cfn_template.yaml" -cfn_parameters="codecommit_backup_cfn_parameters.json" zipfile="codecommit_backup_scripts.zip" cfn_gen_template="/tmp/gen_codecommit_backup_cfn_template.yaml"