I have created a codepipline using the following git link
https://github.com/aws-samples/aws-serverless-samfarm/blob/master/pipeline/pipeline.yaml
The Pipeline has been created and I have connected the source to my Git repo(V2). I am using the following file as a SAM Input for lambda creation. How can I make the lambda function fetch the function code stored in a git folder in the same branch where I want to deploy the pipeline? Do I need to create a build spec file or something?
AWSTemplateFormatVersion: '2010-09-09'
Description: Lambda function and EventBridge rule for EC2 Instance State Change
Resources:
LambdaFunction:
Type: AWS::Lambda::Function
Properties:
FunctionName: xxxxx_xxxx
Handler: main.lambda_handler
Role: arn:aws:iam::xxxxx:role/xxxxxxxxxx
Runtime: python3.8
Timeout: 60
EventBridgeRule:
Type: AWS::Events::Rule
Properties:
Name: sk-poc-usstg-ec2-state-change
EventPattern:
source:
- aws.ec2
detail-type:
- EC2 Instance State-change Notification
detail:
state:
- stopped
- stopping
Targets:
- Arn: !GetAtt LambdaFunction.Arn
Id: TargetLambda
Outputs:
LambdaFunctionArn:
Description: ARN of the Lambda function
Value: !GetAtt LambdaFunction.Arn
EventBridgeRuleArn:
Description: ARN of the Amazon EventBridge rule
Value: !Ref EventBridgeRule # Reference the EventBridge rule's ARN