Created
June 22, 2018 16:54
-
-
Save spyoungtech/5fa304ad21210bb9c347184dace4c508 to your computer and use it in GitHub Desktop.
A lambda function intended to be triggered by S3 object creations made by Appveyor S3 deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
client = boto3.client('codedeploy') | |
def lambda_handler(event, context): | |
s3_event = event['Records'][0].get('s3') | |
bucket_name = s3_event['bucket']['name'] | |
key = s3_event['object']['key'] | |
etag = s3_event['object']['eTag'] | |
application_name, deployment_group, version, filename = key.split('/') | |
bundle_type = filename.split('.')[-1].lower() | |
s3_location = { | |
'bucket': bucket_name, | |
'key': key, | |
'bundleType': bundle_type, | |
'eTag': etag | |
} | |
response = client.create_deployment( | |
applicationName=application_name, | |
deploymentGroupName=deployment_group, | |
revision={ | |
'revisionType': 'S3', | |
's3Location': s3_location, | |
}, | |
description='Appveyor automatic deployment via lambda' | |
) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment