I have the following code that works for me.
params := &cloudformation.CreateStackInput{
StackName: aws.String(d.MachineName),
TemplateURL: aws.String(d.CloudFormationURL),
Parameters: []*cloudformation.Parameter{
{
ParameterKey: aws.String("KeyName"),
ParameterValue: aws.String(d.KeyPairName),
},
},
}
I would like to externalize the creation of the Parameters, so I have created the following method.
func (d *Driver) createParams() []cloudformation.Parameter {
val := "KeyName=Foo|KeyName2=bar"
s := strings.Split(val, "|")
a := []cloudformation.Parameter{}
for _, element := range s {
pairs := strings.Split(element, "=")
key := pairs[0]
value := pairs[1]
par := cloudformation.Parameter{
ParameterKey: aws.String(key),
ParameterValue: aws.String(value),
}
a = append(a, par)
}
return a
}
My issue is how to I pass the output of createParams to the Parameters from CreateStackInput?
params := &cloudformation.CreateStackInput{
StackName: aws.String(d.MachineName),
TemplateURL: aws.String(d.CloudFormationURL),
Parameters: d.createParam(),
}
The above yields
cannot use d.createParam() (type []cloudformation.Parameter) as type []*cloudformation.Parameter in field value