I am trying to deploy a cross account sqs policy with serverless. The serverless.yml file looks like as follows:
provider:
name: aws
runtime: python3.11
region: ${opt:region, 'ap-southeast-2'}
stage: ${opt:stage, 'dev'}
lambdaHashingVersion: 20201221
.
.
.
.
resources:
Resources:
MySQSQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: ${self:custom.data-transfer-queue-name}
RedrivePolicy:
deadLetterTargetArn: !GetAtt DataTransferQueueDLQ.Arn
maxReceiveCount: 3
DataTransferQueueDLQ:
Type: "AWS::SQS::Queue"
Properties:
QueueName: ${self:custom.data-transfer-queue-name}-dlq
CrossAccountsSqsPolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
- Sid: "Allow cross accounts access to SQS"
Effect: "Allow"
Principal:
AWS: arn:aws:iam::${self:custom.env-accounts.${self:provider.stage}}:role/middleware-${self:provider.stage}-data-flow-ap-southeast-2-lambdaRole
Resource:
Fn::GetAtt: [MySQSQueue, Arn]
Action:
- sqs:ReceiveMessage
- sqs:DeleteMessage
Queues:
- Ref: MySQSQueue
package:
patterns:
- '!**'
- lambdas/**
custom:
env-accounts:
test: 123456789012
int: 098765432112
int-two: 678901234567
prod: 654321098765
data-transfer-queue-name: data-transfering-queue
prune:
automatic: true
number: 3
warmup:
default:
enabled: true
pythonRequirements:
layer: true
I am receiving an error saying
× Stack data-transfer-int-two failed to deploy (95s)
Environment: linux, node 16.20.2, framework 3.38.0 (local), plugin 7.2.0, SDK 4.5.1
Error:
Credentials: Local, environment variables
UPDATE_FAILED: CrossAccountsSqsPolicy (AWS::SQS::QueuePolicy)
Docs: docs.serverless.com
Resource handler returned message: "Invalid value for the parameter Policy. (Service: Sqs, Status Code: 400, Request ID: 6a17e5b2-952b-58b4-8bcb-bbe36510a7fc)" (RequestToken: b8d50c78-0035-6323-0ca7-9900040761b0, HandlerErrorCode: GeneralServiceException)
Support: forum.serverless.com
View the full error: https://ap-southeast-2.console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stack/detail?stackId=.............................xxxxxxx........
Bugs: github.com/serverless/serverless/issues
3 deprecations found: run 'serverless doctor' for more details
Error: Process completed with exit code 1.
i am new to the serverless and was trying to deploy using a /deploy int-two
command.
Its throwing error and exit without deploy. Please help me to find what i am doing wrong.