mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudformation): populate SQS queue ARN in resource attributes (#396)
When provisioning AWS::SQS::Queue via CloudFormation, the resource's
'Arn' attribute was being read from Queue#getAttributes(), but QueueArn
is a computed attribute in SqsService#getQueueAttributes() — it is not
stored on the Queue object itself. As a result, the Arn attribute was
set to an empty string.
This broke Fn::GetAtt references to queue ARNs. For example, an
EventBridge Rule target built with CDK's SqsQueue target construct
would end up with an empty Arn, silently dropping all events:
"Targets": [{
"Arn": {"Fn::GetAtt": ["MyQueue", "Arn"]}
}]
Fix: build the ARN from region + accountId + queueName, matching the
format used by SqsService#getQueueAttributes.
Added integration test that verifies Fn::GetAtt resolves correctly
when used for an EventBridge Rule target ARN.
This commit is contained in:
1 parent
cd62fda111
commit
bc8caa43f8
2 files changed
+71
-1
No files matched your search
+67
@@ -1582,6 +1582,73 @@ class CloudFormationIntegrationTest {
|
||||
.body("Targets[0].Arn", equalTo("arn:aws:sqs:us-east-1:000000000000:cfn-eventbridge-target-queue"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_withEventBridgeRule_resolvesFnGetAttOnTargetArn() {
|
||||
// This template uses Fn::GetAtt to reference the SQS queue's ARN as an EventBridge
|
||||
// rule target — the pattern produced by AWS CDK when wiring an SqsQueue target.
|
||||
// The queue ARN must be resolved during target provisioning, otherwise the rule
|
||||
// ends up with an empty target ARN and events are never delivered.
|
||||
String template = """
|
||||
{
|
||||
"Resources": {
|
||||
"TargetQueue": {
|
||||
"Type": "AWS::SQS::Queue",
|
||||
"Properties": {
|
||||
"QueueName": "cfn-eb-getatt-queue"
|
||||
}
|
||||
},
|
||||
"MyRule": {
|
||||
"Type": "AWS::Events::Rule",
|
||||
"Properties": {
|
||||
"Name": "cfn-eb-getatt-rule",
|
||||
"EventPattern": {
|
||||
"source": ["my.getatt.test"]
|
||||
},
|
||||
"Targets": [
|
||||
{
|
||||
"Id": "Target0",
|
||||
"Arn": {"Fn::GetAtt": ["TargetQueue", "Arn"]}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "cfn-eb-getatt-stack")
|
||||
.formParam("TemplateBody", template)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackId>"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "cfn-eb-getatt-stack")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.header("X-Amz-Target", "AWSEvents.ListTargetsByRule")
|
||||
.body("{\"Rule\":\"cfn-eb-getatt-rule\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Targets[0].Id", equalTo("Target0"))
|
||||
.body("Targets[0].Arn", equalTo("arn:aws:sqs:us-east-1:000000000000:cfn-eb-getatt-queue"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_withEventBridgeRuleAutoName() {
|
||||
String template = """
|
||||
|
||||
Reference in new issue
Block a user