An error occurs while using
awslocal cloudformation deploy --template-file infrastructure.yaml --stack-name teststack
on this infrastructure.yaml
Parameters:
Environment:
Default: svts
Description: Deployment environment
Type: String
AwsSt:
Default: test
Description: Project technical service
Type: String
AwsTeam:
Default: fra
Description: Team id
Type: String
Component:
Default: relm-adapter
Description: An identifier for the app
Type: String
Resources:
CreateAccountEventQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub "${AwsTeam}_${AwsSt}_${Environment}_sqs_create_account_event"
RedrivePolicy:
deadLetterTargetArn: !GetAtt CreateAccountEventDLQueue.Arn
maxReceiveCount: 3
CreateAccountEventDLQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Sub "${AwsTeam}_${AwsSt}_${Environment}_sqs_dlq_create_account_event"
QueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- !Ref CreateAccountEventQueue
PolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: sns.amazonaws.com
Action:
- sqs:SendMessage
Resource: "*"
Condition:
ArnEquals:
aws:SourceArn:
!Sub "${AwsTeam}_${AwsSt}_${Environment}_sns_create_account_event_topic"
CreateAccountEventSubscription:
Type: AWS::SNS::Subscription
Properties:
TopicArn: !Sub "${AwsTeam}_${AwsSt}_${Environment}_sns_create_account_event_topic"
Endpoint: !GetAtt CreateAccountEventQueue.Arn
Protocol: sqs
CreateAccountEventTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: !Sub "${AwsTeam}_${AwsSt}_${Environment}_sns_create_account_event_topic"
TopicName: !Sub "${AwsTeam}_${AwsSt}_${Environment}_sns_create_account_event_topic"
The stack creation fails with this error (retrieved from awslocal describe-stack-events
):
{
"StackId": "arn:aws:cloudformation:us-east-1:000000000000:stack/teststack/f91977a8",
"EventId": "36f1855e-d41e-410a-a2cb-2d08b61f8918",
"StackName": "teststack",
"LogicalResourceId": "CreateAccountEventSubscription",
"PhysicalResourceId": "arn:aws:cloudformation:us-east-1:000000000000:stack/teststack/f91977a8",
"ResourceType": "AWS::SNS::Subscription",
"Timestamp": "2024-01-30T09:42:19.531000Z",
"ResourceStatus": "CREATE_FAILED",
"ResourceStatusReason": "An error occurred (InternalError) when calling the Subscribe operation (reached max retries: 4): exception while calling sns.Subscribe: not enough values to unpack (expected 6, got 1)"
},
This is the error log:
2024-01-30 10:47:53 2024-01-30T09:47:53.376 ERROR --- [ asgi_gw_0] l.aws.handlers.logging : exception during call chain: not enough values to unpack (expected 6, got 1)
2024-01-30 10:47:54 2024-01-30T09:47:54.202 ERROR --- [ asgi_gw_0] l.aws.handlers.logging : exception during call chain: not enough values to unpack (expected 6, got 1)
2024-01-30 10:47:54 2024-01-30T09:47:54.932 ERROR --- [ asgi_gw_0] l.aws.handlers.logging : exception during call chain: not enough values to unpack (expected 6, got 1)
2024-01-30 10:47:56 2024-01-30T09:47:56.430 ERROR --- [ asgi_gw_0] l.aws.handlers.logging : exception during call chain: not enough values to unpack (expected 6, got 1)
2024-01-30 10:47:58 2024-01-30T09:47:58.517 ERROR --- [ asgi_gw_0] l.aws.handlers.logging : exception during call chain: not enough values to unpack (expected 6, got 1)
2024-01-30 10:47:58 2024-01-30T09:47:58.521 WARN --- [functhread12] l.s.c.resource_provider : Error calling <bound method ClientCreator._create_api_method.<locals>._api_call of <botocore.client.SNS object at 0xffff4efcfc10>> with params: {'TopicArn': 'test_fra_svts_sns_create_account_event_topic', 'Protocol': 'sqs', 'Endpoint': 'arn:aws:sqs:us-east-1:000000000000:test_fra_svts_sqs_create_account_event', 'Attributes': {}} for resource: {'Type': 'AWS::SNS::Subscription', 'LogicalResourceId': 'CreateAccountEventSubscription', 'Properties': {'TopicArn': 'test_fra_svts_sns_create_account_event_topic', 'Endpoint': 'arn:aws:sqs:us-east-1:000000000000:prov_fra_svts_sqs_create_account_event', 'Protocol': 'sqs'}, 'SpecifiedProperties': {'TopicArn': 'test_fra_svts_sns_create_account_event_topic', 'Endpoint': 'arn:aws:sqs:us-east-1:000000000000:test_fra_svts_sqs_create_account_event', 'Protocol': 'sqs'}}
It should create my stack resources
With a docker run
command
Running localstack from Docker Desktop with port 4566 exposed and /var/run/docker.sock mounted
- OS: Ubuntu 23.10 / MacOs Sonoma 14.3
- LocalStack: LocalStack version: 3.1.1.dev
Try changing it to reference the topic ARN using !Ref
to ensure the topic is done being created before CloudFormation tries to subscribe to it and to ensure it is getting the ARN and not the name.
The topic ARN in your example does not look like an ARN, so it could be that. It looks like you have specified the topic name.
CreateAccountEventSubscription:
Type: AWS::SNS::Subscription
Properties:
TopicArn: !Ref CreateAccountEventTopic
Endpoint: !GetAtt CreateAccountEventQueue.Arn
Protocol: sqs
The examples on this documentation page show referencing the topic ARN as TopicArn: !Ref CarSalesTopic
as a reference.