From 7ef6501d38c38a897632b812a8b85aec96bd0c76 Mon Sep 17 00:00:00 2001 From: Carl Waldbieser Date: Tue, 28 Feb 2023 13:24:42 -0500 Subject: [PATCH 1/3] Lint & format. Lint & format. --- codecommit_backup_trigger_lambda.py | 14 ++++++++++---- deploy.sh | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) 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" From de98b524d10b9c3dde6cf339395b8b69203d034a Mon Sep 17 00:00:00 2001 From: Carl Waldbieser Date: Tue, 28 Feb 2023 15:51:59 -0500 Subject: [PATCH 2/3] Lint. Lint. --- backup_repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From b5381d261eeba6e6ca22a1adce7d9216a92ec119 Mon Sep 17 00:00:00 2001 From: Carl Waldbieser Date: Tue, 28 Feb 2023 15:52:51 -0500 Subject: [PATCH 3/3] Use modern Python and build image. Use modern Python and build image. Python 3.6 has been EOL for a while now. The latest Python runtime supported by Lambda is 3.9. The build image doesn't seem to be relatively modern, either. I just chose the latet Ubuntu LTS image from: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html That image should be good until 2027. --- codecommit_backup_cfn_template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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