CloudFormation stack outputs can be used to advertise information about a service.
Sparta provides different publishing output decorators depending on the type of CloudFormation resource output:
Ref
: PublishRefOutputDecoratorFn::Att
: PublishAttOutputDecoratorFor example, to publish the dynamically lambda resource name for a given AWS Lambda function, use PublishRefOutputDecorator such as:
lambdaFunctionName := "Hello World"
lambdaFn, _ := sparta.NewAWSLambda(lambdaFunctionName,
helloWorld,
sparta.IAMRoleDefinition{})
lambdaFn.Decorators = append(lambdaFn.Decorators,
spartaDecorators.PublishRefOutputDecorator(fmt.Sprintf("%s FunctionName", lambdaFunctionName),
fmt.Sprintf("%s Lambda ARN", lambdaFunctionName)))
}
For example, to publish the dynamically determined ARN for a given AWS Lambda function, use PublishAttOutputDecorator such as:
lambdaFunctionName := "Hello World"
lambdaFn, _ := sparta.NewAWSLambda(lambdaFunctionName,
helloWorld,
sparta.IAMRoleDefinition{})
lambdaFn.Decorators = append(lambdaFn.Decorators,
spartaDecorators.PublishAttOutputDecorator(fmt.Sprintf("%s FunctionARN", lambdaFunctionName),
fmt.Sprintf("%s Lambda ARN", lambdaFunctionName), "Arn"))
}