Please help. I have an AWS Lambda defined in an AWS SAM YAML file that has been deployed but does not create the event source along with it. Please, what could I likely be missing here? I have already tried adding certain permissions to the SQS and SQSPoller permissions to the Lambda but that did not work. I have already spent too much time on this already. Thank you very much
BootstrapFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Zip
FunctionName: !Sub '${appName}-${env}-${sourceCodeName}-bootstrap'
CodeUri:
Bucket: !Ref sourceCodeBucketName
Key: !Sub '${sourceCodeName}/${sourceCodeTag}.zip'
Description: Bootstrap the Project State Machine
Handler: build/src/bootstrapHandler.bootstrap
Policies:
- AWSLambdaExecute
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 30
Environment:
Variables:
LOG_LEVEL: 'debug'
REGION: !Ref AWS::Region
VpcConfig:
SecurityGroupIds:
- !Ref clusterSecurityGroupId
SubnetIds: !Ref subnetIds
Events:
BootstrapFunctionSQSEvent:
Type: SQS
Properties:
Queue: !GetAtt TaskQueue.Arn
BatchSize: 1
Enabled: true
TaskQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub '${appName}-${env}-${sourceCodeName}-task'
MessageRetentionPeriod: !Ref sqsMessageRetentionSeconds
RedrivePolicy:
deadLetterTargetArn: !GetAtt TaskDlQueue.Arn
maxReceiveCount: !Ref maxReceiveCountForDlq
TaskQueueWritePolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: !Sub '${appName}-${env}-${sourceCodeName}-task-queue-write-policy'
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: AllowQueueAccess
Effect: Allow
Action:
- sqs:SendMessage
- sqs:ChangeMessageVisibility
Resource:
- !GetAtt TaskQueue.Arn
TaskQueueReadPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: !Sub '${appName}-${env}-${sourceCodeName}-task-queue-read-policy'
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: AllowQueueAccess
Effect: Allow
Action:
- sqs:ChangeMessageVisibility
- sqs:ReceiveMessage
- sqs:DeleteMessage
Resource:
- !GetAtt TaskQueue.Arn
Events
should be indented underneath Properties
in your BootstrapFunction
resource:
BootstrapFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Zip
FunctionName: !Sub '${appName}-${env}-${sourceCodeName}-bootstrap'
CodeUri:
Bucket: !Ref sourceCodeBucketName
Key: !Sub '${sourceCodeName}/${sourceCodeTag}.zip'
Description: Bootstrap the Project State Machine
Handler: build/src/bootstrapHandler.bootstrap
Policies:
- AWSLambdaExecute
Runtime: nodejs14.x
MemorySize: 1024
Timeout: 30
Environment:
Variables:
LOG_LEVEL: 'debug'
REGION: !Ref AWS::Region
VpcConfig:
SecurityGroupIds:
- !Ref clusterSecurityGroupId
SubnetIds: !Ref subnetIds
Events:
BootstrapFunctionSQSEvent:
Type: SQS
Properties:
Queue: !GetAtt TaskQueue.Arn
BatchSize: 1
Enabled: true