SlideShare a Scribd company logo
Let CodeCommit
work for you
What features are you missing?
Did you ever used GitHub or GitLab?
Yes, I did use GitHub or GitLab before
Thumb Up
No, I did not use GitHub or GitLab before
Thumb Down
Did you ever used CodeCommit?
Yes, I did use CodeCommit before
Thumb Up
No, I did not use CodeCommit before
Thumb Down
What did
you miss?
Talk to your neighbor.
Discuss what you are
missing in CodeCommit
Notifications
You create a pull request!
How do you request someone to review?
Your pull request gets approved!
How will you know that?
Are there open pull requests?
How do I know that there are open pull requests?
I really missed notifications
Event
Amazon EventBridge
Lambda function
AWS Lambda
Email
Amazon SES
AWS Cloud
User Default
event bus
AWS CodeCommit
Repository
Create
Pull Request
Rule
source: ["aws.codecommit"]
detail:
event: ["pullRequestCreated"]
destinationReference: ["refs/heads/main"]
{
"version": "0",
"id": "d929f7c1-5e5c-c301-b585-d2b4d8aea7a7",
"detail-type": "CodeCommit Pull Request State Change",
"source": "aws.codecommit",
"account": "111122223333",
"time": "2022-09-23T14:28:16Z",
"region": "eu-west-1",
"resources": [
"arn:aws:codecommit:eu-west-1:111122223333:my-repository"
],
"detail": {
"author": "arn:aws:sts::111122223333:assumed-role/Developer/john.doe@xebia.com",
"callerUserArn": "arn:aws:sts::111122223333:assumed-role/Developer/john.doe@xebia.com",
"creationDate": "Fri Sep 23 14:28:05 UTC 2022",
"destinationCommit": "68fa0e37f8fa9c30d86efbe4f1b1d60ab99b2d41",
"destinationReference": "refs/heads/main",
"event": "pullRequestCreated",
"isMerged": "False",
"lastModifiedDate": "Fri Sep 23 14:28:05 UTC 2022",
"notificationBody": "A pull request event occurred in the following AWS CodeCommit repository: [TRUNCATED]",
"revisionId": "e6b08feca87491275975315807c742374b3339cb61878a3c88b556b72e2dc25e",
"sourceCommit": "9a6659bb6601009c3677be92a0582595fe24bc5e",
"sourceReference": "refs/heads/docs/describe-plan",
"title": "docs: describe the initial plan"
}
}
source: ["aws.codecommit"]
detail:
event: ["pullRequestCreated"]
destinationReference: ["refs/heads/main"]
Who knows CloudFormation?
Yes, I know what it is!
Thumb Up
No, I don’t know what it is!
Thumb Down
Serverless Application Model or SAM?
Yes, I know what it is!
Thumb Up
No, I don’t know what it is!
Thumb Down
AWS Lambda Powertools
Yes, I know what it is!
Thumb Up
No, I don’t know what it is!
Thumb Down
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
CodeCommit Automation
Globals:
Function:
Timeout: 10
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: codecommit-automation
LOG_LEVEL: INFO
Resources:
PullRequestFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/pull_request
Handler: function.handler
Runtime: python3.9
Architectures: ["arm64"]
Events:
EventRule:
Type: EventBridgeRule
Properties:
Pattern:
source: ["aws.codecommit"]
detail:
event: ["pullRequestCreated"]
destinationReference: ["refs/heads/main"]
aws-lambda-powertools==1.29.2
aws-lambda-powertools[pydantic]==1.29.2
from typing import List
from aws_lambda_powertools.utilities.parser import BaseModel, root_validator
class PullRequestEvent(BaseModel):
__supported_events = ["pullRequestCreated"]
author: str
callerUserArn: str
creationDate: str
destinationCommit: str
destinationReference: str
event: str
isMerged: str
lastModifiedDate: str
mergeOption: Optional[str]
notificationBody: str
revisionId: str
sourceCommit: str
sourceReference: str
title: str
@root_validator
def validate_event(cls, values):
event = values.get("event", "")
if event not in cls.__supported_events:
raise ValueError(f"The {event} event is not supported!")
return values
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext
from aws_lambda_powertools.utilities.parser import event_parser, envelopes
from .event import PullRequestEvent
logger = Logger()
@event_parser(model=PullRequestEvent, envelope=envelopes.EventBridgeEnvelope)
def handler(event: PullRequestEvent, context: LambdaContext) -> None:
logger.info(f"{event.event} detected, by: {event.callerUserArn}")
logger.info(event.notificationBody)
Invoking function.handler (python3.9)
Skip pulling image and use local one: public.ecr.aws/sam/emulation-python3.9:rapid-
Mounting /Users/jorisconijn/workspace/binx/my-repository/.aws-sam/build/PullReque
START RequestId: bb0fa509-8431-475a-9313-8cd1785cbfea Version: $LATEST
{"level":"INFO","location":"handler:14","message":"pullRequestMergeStatusUpdated
{"level":"INFO","location":"handler:15","message":"A pull request event occurred in t
END RequestId: bb0fa509-8431-475a-9313-8cd1785cbfea
REPORT RequestId: bb0fa509-8431-475a-9313-8cd1785cbfea Init Duration: 0.1
Creating a pull request
Using the console?
When using the console, you need to be logged in with
the correct role.
Using the console?
Select the correct repository
Using the console?
Select the select the branch
Using the console?
Type in a title and description
How do you create a pull request?
pull-request-codecommit
Push Compare
Write
Create
Merge
https://github.com/Nr18/pull-request-codecommit
Open pull requests
We could have multiple repositories
Each repository could have multiple pull
requests
Collect the information of each pull request
What pull requests are open?
AWS Step Functions
Yes, I know what it is!
Thumb Up
No, I don’t know what it is!
Thumb Down
"ListRepositories": {
"Type": "Task",
"Next": "Process Repositories",
"Parameters": {
"Order": "ascending",
"SortBy": "repositoryName"
},
"Resource": "arn:aws:states:::aws-sdk:codecommit:listRepositories"
}
"ListPullRequests": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:codecommit:listPullRequests",
"Parameters": {
"RepositoryName.$": "$.MessageDetails.RepositoryName",
"PullRequestStatus": "OPEN"
},
"Next": "Fetch Pull Request Information"
}
"GetPullRequest": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:codecommit:getPullRequest",
"Parameters": {
"PullRequestId.$": "$.PullRequestId"
},
"End": true
}
Conclusion
Its about recognizing a problem!
Finding an event that you could use as a trigger!
Automate the wanted result!
It’s not about CodeCommit
Thank You
Joris Conijn

More Related Content

Similar to Let CodeCommit work for you

Going Serverless
Going ServerlessGoing Serverless
Going Serverless
Mattias Severson
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
FIDO Alliance
 
Bucks County Tech Meetup: node.js introduction
Bucks County Tech Meetup: node.js introductionBucks County Tech Meetup: node.js introduction
Bucks County Tech Meetup: node.js introduction
dshkolnikov
 
Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)
남균 김
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)
Python Ireland
 
Ruby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVCRuby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVC
Simone Chiaretta
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwrdeimos
 
Frameworkless Web Development in Clojure
Frameworkless Web Development in ClojureFrameworkless Web Development in Clojure
Frameworkless Web Development in Clojure
Kungi2342
 
Building an api using golang and postgre sql v1.0
Building an api using golang and postgre sql v1.0Building an api using golang and postgre sql v1.0
Building an api using golang and postgre sql v1.0
Frost
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
Katy Slemon
 
Serverless
ServerlessServerless
Serverless
Iegor Fadieiev
 
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019
corehard_by
 
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsSF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
Philip Stehlik
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work TogetherSubbu Allamaraju
 
Debugging & profiling node.js
Debugging & profiling node.jsDebugging & profiling node.js
Debugging & profiling node.js
tomasperezv
 
CGI Presentation
CGI PresentationCGI Presentation
CGI Presentation
Sopan Shewale
 

Similar to Let CodeCommit work for you (20)

Going Serverless
Going ServerlessGoing Serverless
Going Serverless
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
 
Bucks County Tech Meetup: node.js introduction
Bucks County Tech Meetup: node.js introductionBucks County Tech Meetup: node.js introduction
Bucks County Tech Meetup: node.js introduction
 
Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)Build resource server & client for OCF Cloud (2018.8.30)
Build resource server & client for OCF Cloud (2018.8.30)
 
2310 b 05
2310 b 052310 b 05
2310 b 05
 
ql.io at NodePDX
ql.io at NodePDXql.io at NodePDX
ql.io at NodePDX
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)
 
Ruby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVCRuby on Rails vs ASP.NET MVC
Ruby on Rails vs ASP.NET MVC
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
 
Frameworkless Web Development in Clojure
Frameworkless Web Development in ClojureFrameworkless Web Development in Clojure
Frameworkless Web Development in Clojure
 
Building an api using golang and postgre sql v1.0
Building an api using golang and postgre sql v1.0Building an api using golang and postgre sql v1.0
Building an api using golang and postgre sql v1.0
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
 
Serverless
ServerlessServerless
Serverless
 
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019
Функции обратного вызова в C++. Виталий Ткаченко. CoreHard Spring 2019
 
Synergy CLI
Synergy CLISynergy CLI
Synergy CLI
 
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsSF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work Together
 
Debugging & profiling node.js
Debugging & profiling node.jsDebugging & profiling node.js
Debugging & profiling node.js
 
CGI Presentation
CGI PresentationCGI Presentation
CGI Presentation
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 

Let CodeCommit work for you

  • 1. Let CodeCommit work for you What features are you missing?
  • 2. Did you ever used GitHub or GitLab? Yes, I did use GitHub or GitLab before Thumb Up No, I did not use GitHub or GitLab before Thumb Down
  • 3. Did you ever used CodeCommit? Yes, I did use CodeCommit before Thumb Up No, I did not use CodeCommit before Thumb Down
  • 4. What did you miss? Talk to your neighbor. Discuss what you are missing in CodeCommit
  • 5. Notifications You create a pull request! How do you request someone to review? Your pull request gets approved! How will you know that? Are there open pull requests? How do I know that there are open pull requests? I really missed notifications
  • 6. Event Amazon EventBridge Lambda function AWS Lambda Email Amazon SES AWS Cloud User Default event bus AWS CodeCommit Repository Create Pull Request Rule source: ["aws.codecommit"] detail: event: ["pullRequestCreated"] destinationReference: ["refs/heads/main"]
  • 7. { "version": "0", "id": "d929f7c1-5e5c-c301-b585-d2b4d8aea7a7", "detail-type": "CodeCommit Pull Request State Change", "source": "aws.codecommit", "account": "111122223333", "time": "2022-09-23T14:28:16Z", "region": "eu-west-1", "resources": [ "arn:aws:codecommit:eu-west-1:111122223333:my-repository" ], "detail": { "author": "arn:aws:sts::111122223333:assumed-role/Developer/john.doe@xebia.com", "callerUserArn": "arn:aws:sts::111122223333:assumed-role/Developer/john.doe@xebia.com", "creationDate": "Fri Sep 23 14:28:05 UTC 2022", "destinationCommit": "68fa0e37f8fa9c30d86efbe4f1b1d60ab99b2d41", "destinationReference": "refs/heads/main", "event": "pullRequestCreated", "isMerged": "False", "lastModifiedDate": "Fri Sep 23 14:28:05 UTC 2022", "notificationBody": "A pull request event occurred in the following AWS CodeCommit repository: [TRUNCATED]", "revisionId": "e6b08feca87491275975315807c742374b3339cb61878a3c88b556b72e2dc25e", "sourceCommit": "9a6659bb6601009c3677be92a0582595fe24bc5e", "sourceReference": "refs/heads/docs/describe-plan", "title": "docs: describe the initial plan" } } source: ["aws.codecommit"] detail: event: ["pullRequestCreated"] destinationReference: ["refs/heads/main"]
  • 8. Who knows CloudFormation? Yes, I know what it is! Thumb Up No, I don’t know what it is! Thumb Down
  • 9. Serverless Application Model or SAM? Yes, I know what it is! Thumb Up No, I don’t know what it is! Thumb Down
  • 10. AWS Lambda Powertools Yes, I know what it is! Thumb Up No, I don’t know what it is! Thumb Down
  • 11. AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > CodeCommit Automation Globals: Function: Timeout: 10 Environment: Variables: POWERTOOLS_SERVICE_NAME: codecommit-automation LOG_LEVEL: INFO Resources: PullRequestFunction: Type: AWS::Serverless::Function Properties: CodeUri: src/pull_request Handler: function.handler Runtime: python3.9 Architectures: ["arm64"] Events: EventRule: Type: EventBridgeRule Properties: Pattern: source: ["aws.codecommit"] detail: event: ["pullRequestCreated"] destinationReference: ["refs/heads/main"] aws-lambda-powertools==1.29.2 aws-lambda-powertools[pydantic]==1.29.2
  • 12. from typing import List from aws_lambda_powertools.utilities.parser import BaseModel, root_validator class PullRequestEvent(BaseModel): __supported_events = ["pullRequestCreated"] author: str callerUserArn: str creationDate: str destinationCommit: str destinationReference: str event: str isMerged: str lastModifiedDate: str mergeOption: Optional[str] notificationBody: str revisionId: str sourceCommit: str sourceReference: str title: str @root_validator def validate_event(cls, values): event = values.get("event", "") if event not in cls.__supported_events: raise ValueError(f"The {event} event is not supported!") return values from aws_lambda_powertools import Logger from aws_lambda_powertools.utilities.typing import LambdaContext from aws_lambda_powertools.utilities.parser import event_parser, envelopes from .event import PullRequestEvent logger = Logger() @event_parser(model=PullRequestEvent, envelope=envelopes.EventBridgeEnvelope) def handler(event: PullRequestEvent, context: LambdaContext) -> None: logger.info(f"{event.event} detected, by: {event.callerUserArn}") logger.info(event.notificationBody) Invoking function.handler (python3.9) Skip pulling image and use local one: public.ecr.aws/sam/emulation-python3.9:rapid- Mounting /Users/jorisconijn/workspace/binx/my-repository/.aws-sam/build/PullReque START RequestId: bb0fa509-8431-475a-9313-8cd1785cbfea Version: $LATEST {"level":"INFO","location":"handler:14","message":"pullRequestMergeStatusUpdated {"level":"INFO","location":"handler:15","message":"A pull request event occurred in t END RequestId: bb0fa509-8431-475a-9313-8cd1785cbfea REPORT RequestId: bb0fa509-8431-475a-9313-8cd1785cbfea Init Duration: 0.1
  • 13. Creating a pull request Using the console? When using the console, you need to be logged in with the correct role. Using the console? Select the correct repository Using the console? Select the select the branch Using the console? Type in a title and description How do you create a pull request?
  • 14.
  • 16. Open pull requests We could have multiple repositories Each repository could have multiple pull requests Collect the information of each pull request What pull requests are open?
  • 17. AWS Step Functions Yes, I know what it is! Thumb Up No, I don’t know what it is! Thumb Down
  • 18. "ListRepositories": { "Type": "Task", "Next": "Process Repositories", "Parameters": { "Order": "ascending", "SortBy": "repositoryName" }, "Resource": "arn:aws:states:::aws-sdk:codecommit:listRepositories" } "ListPullRequests": { "Type": "Task", "Resource": "arn:aws:states:::aws-sdk:codecommit:listPullRequests", "Parameters": { "RepositoryName.$": "$.MessageDetails.RepositoryName", "PullRequestStatus": "OPEN" }, "Next": "Fetch Pull Request Information" } "GetPullRequest": { "Type": "Task", "Resource": "arn:aws:states:::aws-sdk:codecommit:getPullRequest", "Parameters": { "PullRequestId.$": "$.PullRequestId" }, "End": true }
  • 19. Conclusion Its about recognizing a problem! Finding an event that you could use as a trigger! Automate the wanted result! It’s not about CodeCommit