aws-cloudformation / rain

A development workflow tool for working with AWS CloudFormation.
Apache License 2.0
811 stars 73 forks source link

Outputs aren't carried over when formatting with rain from json to pkl #524

Closed edfanchermat closed 1 month ago

edfanchermat commented 1 month ago

I'm converting some existing templates from json to pkl. The templates seem to be losing the Outputs configuration though. I believe this should work, unless there's another approach I should be taking? Repo:

 more outputsrepo.json 
{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Generated by rain",
    "Resources": {
        "T100Subnet": {
            "Type": "AWS::EC2::Subnet",
            "Properties": {
                "CidrBlock": "11.0.0.0/16",
                "AvailabilityZone" : "us-west-2a"
}
        }},
    "Outputs": {
      "T100SubnetId" : {
          "Description": "Subnet Id",
          "Value" : { "Ref" : "T100Subnet" },
          "Export": { "Name": {"Fn::Sub":"${AWS::StackName}-T100SubnetId"}}
      },
   }

}
~/rain fmt -p outputsrepo.json
amends "@cfn/template.pkl"
import "@cfn/cloudformation.pkl" as cfn
import "@cfn/aws/ec2/subnet.pkl"

AWSTemplateFormatVersion = "2010-09-09"

Description = "Generated by rain"

Resources {
    ["T100Subnet"] = new subnet.Subnet {
        Type = "AWS::EC2::Subnet"
        CidrBlock = "11.0.0.0/16"
        AvailabilityZone = "us-west-2a"
    }

}
~/rain --version
Rain v1.12.0 linux/amd64
more PklProject
amends "pkl:Project"

dependencies {
    ["cfn"] {
        uri = "package://github.com/aws-cloudformation/cloudformation-pkl/releases/download/cloudformation@0.1.3/cloudformation@0.1.3"
    }
}
edfanchermat commented 1 month ago

Just tried it with rain v1.15.0 with the same result.