Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Field Export on type Output should be pointer #299

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudformation/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Parameter struct {
type Output struct {
Value interface{} `json:"Value"`
Description string `json:"Description,omitempty"`
Export Export `json:"Export,omitempty"`
Export *Export `json:"Export,omitempty"`
}

type Export struct {
Expand Down
44 changes: 44 additions & 0 deletions goformation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/awslabs/goformation/v4"
"github.com/awslabs/goformation/v4/cloudformation"
"github.com/awslabs/goformation/v4/cloudformation/ec2"
"github.com/awslabs/goformation/v4/cloudformation/lambda"
"github.com/awslabs/goformation/v4/cloudformation/policies"
"github.com/awslabs/goformation/v4/cloudformation/route53"
Expand Down Expand Up @@ -1252,4 +1253,47 @@ var _ = Describe("Goformation", func() {

})

Context("with a template that contains outputs with no exports", func() {

Context("described as Go structs", func() {

template := cloudformation.NewTemplate()

template.Resources["Vpc"] = &ec2.VPC{
CidrBlock: "192.168.0.0/20",
}

template.Outputs["VpcId"] = cloudformation.Output{
Value: cloudformation.Ref("Vpc"),
}

expected := `{
"AWSTemplateFormatVersion": "2010-09-09",
"Outputs": {
"VpcId": {
"Value": {
"Ref": "Vpc"
}
}
},
"Resources": {
"Vpc": {
"Properties": {
"CidrBlock": "192.168.0.0/20"
},
"Type": "AWS::EC2::VPC"
}
}
}`

got, err := template.JSON()
It("should marshal template successfully", func() {
Expect(err).To(BeNil())
})

It("should be equal to expected output", func() {
Expect(string(got)).To(Equal(expected))
})
})
})
})