Created
March 11, 2018 22:18
-
-
Save devonartis/26975cd3400c2e57dcd7b642dd648b35 to your computer and use it in GitHub Desktop.
Example of using Paramaters with GoFormation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/awslabs/goformation/cloudformation" | |
) | |
func main() { | |
// Create a new CloudFormation template | |
template := cloudformation.NewTemplate() | |
instanceParam := map[string]string{ | |
"Type": "String", | |
"Default": "t2.micro", | |
"Description": "Paramaters for EC2 Information", | |
} | |
template.Parameters["InstanceTypeParamater"] = instanceParam | |
// An an example SNS Topic | |
template.Resources["MySNSTopic"] = &cloudformation.AWSSNSTopic{ | |
DisplayName: "test-sns-topic-display-name", | |
TopicName: "test-sns-topic-name", | |
Subscription: []cloudformation.AWSSNSTopic_Subscription{ | |
cloudformation.AWSSNSTopic_Subscription{ | |
Endpoint: "test-sns-topic-subscription-endpoint", | |
Protocol: "test-sns-topic-subscription-protocol", | |
}, | |
}, | |
} | |
// ...and a Route 53 Hosted Zone too | |
template.Resources["MyRoute53HostedZone"] = &cloudformation.AWSRoute53HostedZone{ | |
Name: "example.com", | |
} | |
// Let's see the JSON | |
j, err := template.JSON() | |
if err != nil { | |
fmt.Printf("Failed to generate JSON: %s\n", err) | |
} else { | |
fmt.Printf("%s\n", string(j)) | |
} | |
y, err := template.YAML() | |
if err != nil { | |
fmt.Printf("Failed to generate YAML: %s\n", err) | |
} else { | |
fmt.Printf("%s\n", string(y)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment