From 3600038a3fb107bbcce71ccc20685b86a05c7d0f Mon Sep 17 00:00:00 2001 From: Mario Toffia Date: Fri, 4 Sep 2026 08:09:19 +0200 Subject: [PATCH] fix(ssm): set the Arn attribute on AWS::SSM::Parameter (#3019) The registry schema lists Arn as the type's only read-only property, but the provisioner never set it, so Fn::GetAtt [Param, Arn] resolved to the literal "Param.Arn" and CfnSchemaCoverageTest fails on main once the schema corpus is present. The ARN uses AWS's parameter/ form: a name without a leading slash gets one inserted, a name with one is not doubled. --- docs/services/cloudformation.md | 2 +- .../provisioners/SsmCfnProvisioner.java | 8 ++++++++ .../provisioners/LeafCfnProvisionerTest.java | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/services/cloudformation.md b/docs/services/cloudformation.md index 2340d7a379..ecc809ce52 100644 --- a/docs/services/cloudformation.md +++ b/docs/services/cloudformation.md @@ -233,7 +233,7 @@ before provisioning: - `AWS::SSM::Parameter::Value>` and `AWS::SSM::Parameter::Name` typed parameters are **not yet** resolved — they are passed through as their literal input. -The `AWS::SSM::Parameter` **resource** type exposes `Value`, `Type`, and `Name` attributes through +The `AWS::SSM::Parameter` **resource** type exposes `Value`, `Type`, `Name`, and `Arn` attributes through `Ref` / `Fn::GetAtt` so downstream resources can consume a parameter the same stack creates. ## AWS::Include (`Fn::Transform`) diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SsmCfnProvisioner.java b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SsmCfnProvisioner.java index 0105371259..f0910cbb71 100644 --- a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SsmCfnProvisioner.java +++ b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SsmCfnProvisioner.java @@ -1,6 +1,7 @@ package io.github.hectorvent.floci.services.cloudformation.provisioners; import com.fasterxml.jackson.databind.JsonNode; +import io.github.hectorvent.floci.core.common.AwsArnUtils; import io.github.hectorvent.floci.services.cloudformation.model.StackResource; import io.github.hectorvent.floci.services.ssm.SsmService; import jakarta.enterprise.context.ApplicationScoped; @@ -41,6 +42,13 @@ public class SsmCfnProvisioner implements CfnResourceProvisioner { r.getAttributes().put("Name", name); r.getAttributes().put("Type", type); r.getAttributes().put("Value", value); + r.getAttributes().put("Arn", parameterArn(name, ctx)); + } + + /** AWS's form is {@code parameter/} whether or not the name starts with a slash. */ + private static String parameterArn(String name, ProvisionContext ctx) { + String path = name.startsWith("/") ? name : "/" + name; + return AwsArnUtils.Arn.of("ssm", ctx.region(), ctx.accountId(), "parameter" + path).toString(); } @Override diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LeafCfnProvisionerTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LeafCfnProvisionerTest.java index 3d554cbff2..01b66821d5 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LeafCfnProvisionerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LeafCfnProvisionerTest.java @@ -166,7 +166,20 @@ class LeafCfnProvisionerTest { verify(ssm).putParameter("/app/db", "secret", "String", null, true, REGION); assertEquals("/app/db", r.getPhysicalId()); - assertEquals(Map.of("Name", "/app/db", "Type", "String", "Value", "secret"), r.getAttributes()); + assertEquals(Map.of("Name", "/app/db", "Type", "String", "Value", "secret", + "Arn", "arn:aws:ssm:us-east-1:000000000000:parameter/app/db"), r.getAttributes()); + } + + @Test + void arnOfANameWithoutALeadingSlashStillHasTheParameterPrefix() { + // AWS ARNs are always arn:...:parameter/; a name without a leading slash gets the + // slash inserted, a name with one is not doubled. + StackResource r = resource("Param", "AWS::SSM::Parameter"); + provisioner.provision(r, props(""" + {"Name": "db-host", "Value": "localhost"} + """), ctx); + + assertEquals("arn:aws:ssm:us-east-1:000000000000:parameter/db-host", r.getAttributes().get("Arn")); } @Test