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/<name> form: a name without a leading
slash gets one inserted, a name with one is not doubled.
This commit is contained in:
Mario Toffia authored and GitHub committed 2026-09-04 01:09:19 -05:00
1 parent 9220c057b7
commit 3600038a3f
3 files changed
+23 -2

No files matched your search

+1 -1
View File
@@ -233,7 +233,7 @@ before provisioning:
- `AWS::SSM::Parameter::Value<List<String>>` 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`)
@@ -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/<name>} 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
@@ -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/<name>; 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